Skip to content
Permalink
Browse files
fix #2359
  • Loading branch information
ralsina committed Jun 4, 2016
1 parent 39dd48a commit 8cadb4dfd9d0d3e4a95656ee5c15bdc01c27e401
Showing with 32 additions and 28 deletions.
  1. +1 −0 CHANGES.txt
  2. +2 −0 nikola/__main__.py
  3. +29 −28 nikola/nikola.py
@@ -11,6 +11,7 @@ Features
Bugfixes
--------

* When using the plugin command, load ALL plugins (Issue #2359)
* Fix plugin removal for plugins that are a package (Issue #2356)
* Reload English messages for every theme to prevent caching (Issue #2347)
* Cache theme messages after loading once (Issue #2344)
@@ -332,6 +332,8 @@ def run(self, cmd_args):

if args[0] == 'help':
self.nikola.init_plugins(commands_only=True)
elif args[0] == 'plugin':
self.nikola.init_plugins(load_all=True)
else:
self.nikola.init_plugins()

@@ -867,7 +867,7 @@ def __init__(self, **config):
self.state._set_site(self)
self.cache._set_site(self)

def init_plugins(self, commands_only=False):
def init_plugins(self, commands_only=False, load_all=False):
"""Load plugins as needed."""
self.plugin_manager = PluginManager(categories_filter={
"Command": Command,
@@ -901,34 +901,35 @@ def init_plugins(self, commands_only=False):
self.plugin_manager.getPluginLocator().setPluginPlaces(self._plugin_places)
self.plugin_manager.locatePlugins()
bad_candidates = set([])
for p in self.plugin_manager._candidates:
if commands_only:
if p[-1].details.has_option('Nikola', 'plugincategory'):
# FIXME TemplateSystem should not be needed
if p[-1].details.get('Nikola', 'PluginCategory') not in {'Command', 'Template'}:
if not load_all:
for p in self.plugin_manager._candidates:
if commands_only:
if p[-1].details.has_option('Nikola', 'plugincategory'):
# FIXME TemplateSystem should not be needed
if p[-1].details.get('Nikola', 'PluginCategory') not in {'Command', 'Template'}:
bad_candidates.add(p)
else:
bad_candidates.add(p)
else:
bad_candidates.add(p)
elif self.configured: # Not commands-only, and configured
# Remove compilers we don't use
if p[-1].name in self.bad_compilers:
bad_candidates.add(p)
self.disabled_compilers[p[-1].name] = p
utils.LOGGER.debug('Not loading unneeded compiler {}', p[-1].name)
if p[-1].name not in self.config['COMPILERS'] and \
p[-1].details.has_option('Nikola', 'plugincategory') and p[-1].details.get('Nikola', 'PluginCategory') == 'Compiler':
bad_candidates.add(p)
self.disabled_compilers[p[-1].name] = p
utils.LOGGER.debug('Not loading unneeded compiler {}', p[-1].name)
# Remove blacklisted plugins
if p[-1].name in self.config['DISABLED_PLUGINS']:
bad_candidates.add(p)
utils.LOGGER.debug('Not loading disabled plugin {}', p[-1].name)
# Remove compiler extensions we don't need
if p[-1].details.has_option('Nikola', 'compiler') and p[-1].details.get('Nikola', 'compiler') in self.disabled_compilers:
bad_candidates.add(p)
utils.LOGGER.debug('Not loading compiler extension {}', p[-1].name)
self.plugin_manager._candidates = list(set(self.plugin_manager._candidates) - bad_candidates)
elif self.configured: # Not commands-only, and configured
# Remove compilers we don't use
if p[-1].name in self.bad_compilers:
bad_candidates.add(p)
self.disabled_compilers[p[-1].name] = p
utils.LOGGER.debug('Not loading unneeded compiler {}', p[-1].name)
if p[-1].name not in self.config['COMPILERS'] and \
p[-1].details.has_option('Nikola', 'plugincategory') and p[-1].details.get('Nikola', 'PluginCategory') == 'Compiler':
bad_candidates.add(p)
self.disabled_compilers[p[-1].name] = p
utils.LOGGER.debug('Not loading unneeded compiler {}', p[-1].name)
# Remove blacklisted plugins
if p[-1].name in self.config['DISABLED_PLUGINS']:
bad_candidates.add(p)
utils.LOGGER.debug('Not loading disabled plugin {}', p[-1].name)
# Remove compiler extensions we don't need
if p[-1].details.has_option('Nikola', 'compiler') and p[-1].details.get('Nikola', 'compiler') in self.disabled_compilers:
bad_candidates.add(p)
utils.LOGGER.debug('Not loading compiler extension {}', p[-1].name)
self.plugin_manager._candidates = list(set(self.plugin_manager._candidates) - bad_candidates)
self.plugin_manager.loadPlugins()

self._activate_plugins_of_category("SignalHandler")

0 comments on commit 8cadb4d

Please sign in to comment.