mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
readers: Ensure the reader class is enabled before instantiating
Otherwise the MarkdownReader fails with: 'bool' object is not callable if Markdown is not installed. Reported-by: Deniz Turgut <dturgut@gmail.com>
This commit is contained in:
parent
4058cfdea4
commit
38c22e83b6
1 changed files with 6 additions and 4 deletions
|
|
@ -361,15 +361,17 @@ def read_file(base_path, path, content_class=Page, fmt=None,
|
||||||
if settings is None:
|
if settings is None:
|
||||||
settings = {}
|
settings = {}
|
||||||
|
|
||||||
reader = EXTENSIONS[fmt](settings)
|
reader_class = EXTENSIONS[fmt]
|
||||||
|
if not reader_class.enabled:
|
||||||
|
raise ValueError('Missing dependencies for {}'.format(fmt))
|
||||||
|
|
||||||
|
reader = reader_class(settings)
|
||||||
|
|
||||||
settings_key = '%s_EXTENSIONS' % fmt.upper()
|
settings_key = '%s_EXTENSIONS' % fmt.upper()
|
||||||
|
|
||||||
if settings and settings_key in settings:
|
if settings and settings_key in settings:
|
||||||
reader.extensions = settings[settings_key]
|
reader.extensions = settings[settings_key]
|
||||||
|
|
||||||
if not reader.enabled:
|
|
||||||
raise ValueError("Missing dependencies for %s" % fmt)
|
|
||||||
|
|
||||||
metadata = default_metadata(
|
metadata = default_metadata(
|
||||||
settings=settings, process=reader.process_metadata)
|
settings=settings, process=reader.process_metadata)
|
||||||
metadata.update(path_metadata(
|
metadata.update(path_metadata(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue