From c53a06a5d5183ce54bd94262b3af30611a59ee86 Mon Sep 17 00:00:00 2001 From: Nico Di Rocco Date: Wed, 3 Oct 2012 22:06:45 +0200 Subject: [PATCH] Simplified configuration option to be more flexible As @ametaireau suggested: instead of having logic that prepends the OUTPUT_SOURCES_EXTENSION with a '.' we allow the user more flexibility to control the extension that can be used. --- docs/settings.rst | 4 ++-- pelican/settings.py | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/docs/settings.rst b/docs/settings.rst index 9997f474..e9bf54ff 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -73,8 +73,8 @@ Setting name (default value) What doe original format (e.g. Markdown or ReStructeredText) to the specified OUTPUT_PATH. `OUTPUT_SOURCES_EXTENSION` (``.text``) Controls the extension that will be used by the SourcesGenerator. - Defaults to .text. If the first character is not a `.` the - dot character will be prepended to the extension. + Defaults to ``.text``. If not a valid string the default value + will be used. `RELATIVE_URLS` (``True``) Defines whether Pelican should use document-relative URLs or not. If set to ``False``, Pelican will use the SITEURL setting to construct absolute URLs. diff --git a/pelican/settings.py b/pelican/settings.py index dce1d8ac..cd76aa22 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -177,15 +177,10 @@ def configure_settings(settings, default_settings=None, filename=None): settings['WEBASSETS'] = False if 'OUTPUT_SOURCES_EXTENSION' in settings: - try: - if not isinstance(settings['OUTPUT_SOURCES_EXTENSION'], str): - raise ValueError - elif '.' is not settings['OUTPUT_SOURCES_EXTENSION'][0]: - settings['OUTPUT_SOURCES_EXTENSION'] = '.' + settings['OUTPUT_SOURCES_EXTENSION'] - except(ValueError, IndexError): + if not isinstance(settings['OUTPUT_SOURCES_EXTENSION'], str): + settings['OUTPUT_SOURCES_EXTENSION'] = _DEFAULT_CONFIG['OUTPUT_SOURCES_EXTENSION'] logger.warn("Detected misconfiguration with OUTPUT_SOURCES_EXTENSION." " falling back to the default extension " + _DEFAULT_CONFIG['OUTPUT_SOURCES_EXTENSION']) - settings['OUTPUT_SOURCES_EXTENSION'] = _DEFAULT_CONFIG['OUTPUT_SOURCES_EXTENSION'] return settings