From 21882fd4a00ffdcee7029d7d5ee5ed355ef34a94 Mon Sep 17 00:00:00 2001 From: Ondrej Grover Date: Wed, 14 May 2014 14:06:58 +0200 Subject: [PATCH] Fix #1344 move PLUGIN_PATH -> PLUGIN_PATHS Pelican uses *_PATHS names for settings that represent a list of paths. --- docs/plugins.rst | 6 +++--- docs/settings.rst | 1 + pelican/__init__.py | 4 ++-- pelican/settings.py | 20 ++++++++++++-------- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/docs/plugins.rst b/docs/plugins.rst index 717019a8..a13d9dce 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -21,10 +21,10 @@ Alternatively, another method is to import them and add them to the list:: PLUGINS = [myplugin,] If your plugins are not in an importable path, you can specify a list of paths -via the ``PLUGIN_PATH`` setting. As shown in the following example, paths in -the ``PLUGIN_PATH`` list can be absolute or relative to the settings file:: +via the ``PLUGIN_PATHS`` setting. As shown in the following example, paths in +the ``PLUGIN_PATHS`` list can be absolute or relative to the settings file:: - PLUGIN_PATH = ["plugins", "/srv/pelican/plugins"] + PLUGIN_PATHS = ["plugins", "/srv/pelican/plugins"] PLUGINS = ["assets", "liquid_tags", "sitemap"] Where to find plugins diff --git a/docs/settings.rst b/docs/settings.rst index 33117a7f..34245ff4 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -125,6 +125,7 @@ Setting name (followed by default value, if any) not. Only set this to ``True`` when developing/testing and only if you fully understand the effect it can have on links/feeds. ``PLUGINS = []`` The list of plugins to load. See :ref:`plugins`. +``PLUGIN_PATHS = []`` A list of directories where to look for plugins. See :ref:`plugins`. ``SITENAME = 'A Pelican Blog'`` Your site name ``SITEURL`` Base URL of your website. Not defined by default, so it is best to specify your SITEURL; if you do not, feeds diff --git a/pelican/__init__.py b/pelican/__init__.py index e9fef163..082e5a58 100644 --- a/pelican/__init__.py +++ b/pelican/__init__.py @@ -63,9 +63,9 @@ class Pelican(object): def init_plugins(self): self.plugins = [] - logger.debug('Temporarily adding PLUGIN_PATH to system path') + logger.debug('Temporarily adding PLUGIN_PATHS to system path') _sys_path = sys.path[:] - for pluginpath in self.settings['PLUGIN_PATH']: + for pluginpath in self.settings['PLUGIN_PATHS']: sys.path.insert(0, pluginpath) for plugin in self.settings['PLUGINS']: # if it's a string, then import it diff --git a/pelican/settings.py b/pelican/settings.py index 219ebbd0..c93050ad 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -114,7 +114,7 @@ DEFAULT_CONFIG = { 'ARTICLE_PERMALINK_STRUCTURE': '', 'TYPOGRIFY': False, 'SUMMARY_MAX_LENGTH': 50, - 'PLUGIN_PATH': [], + 'PLUGIN_PATHS': [], 'PLUGINS': [], 'PYGMENTS_RST_OPTIONS': {}, 'TEMPLATE_PAGES': {}, @@ -147,13 +147,17 @@ def read_settings(path=None, override=None): if p not in ('THEME') or os.path.exists(absp): local_settings[p] = absp - if isinstance(local_settings['PLUGIN_PATH'], six.string_types): - logger.warning("Defining %s setting as string has been deprecated (should be a list)" % 'PLUGIN_PATH') - local_settings['PLUGIN_PATH'] = [local_settings['PLUGIN_PATH']] - else: - if 'PLUGIN_PATH' in local_settings and local_settings['PLUGIN_PATH'] is not None: - local_settings['PLUGIN_PATH'] = [os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(path), pluginpath))) - if not isabs(pluginpath) else pluginpath for pluginpath in local_settings['PLUGIN_PATH']] + if 'PLUGIN_PATH' in local_settings: + logger.warning('PLUGIN_PATH setting has been replaced by ' + 'PLUGIN_PATHS, moving it to the new setting name.') + local_settings['PLUGIN_PATHS'] = local_settings['PLUGIN_PATH'] + del local_settings['PLUGIN_PATH'] + if isinstance(local_settings['PLUGIN_PATHS'], six.string_types): + logger.warning("Defining %s setting as string has been deprecated (should be a list)" % 'PLUGIN_PATHS') + local_settings['PLUGIN_PATHS'] = [local_settings['PLUGIN_PATHS']] + elif local_settings['PLUGIN_PATHS'] is not None: + local_settings['PLUGIN_PATHS'] = [os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(path), pluginpath))) + if not isabs(pluginpath) else pluginpath for pluginpath in local_settings['PLUGIN_PATHS']] else: local_settings = copy.deepcopy(DEFAULT_CONFIG)