Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2361 from getnikola/more-uninstall-fixes
fix #2359
  • Loading branch information
ralsina committed Jun 4, 2016
2 parents 39dd48a + 8cadb4d commit f17e265
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions nikola/__main__.py
Expand Up @@ -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()

Expand Down
57 changes: 29 additions & 28 deletions nikola/nikola.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit f17e265

Please sign in to comment.