Skip to content

Commit

Permalink
fixup previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Exirel committed Jul 20, 2019
1 parent 7a6cb06 commit a168c57
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions sopel/cli/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,47 +406,47 @@ def handle_disable(options):
return 0


def _handle_enable_plugin(settings, usable_plugins, name, allow_only):
def _handle_enable_plugin(settings, usable_plugins, plugin_name, allow_only):
enabled = settings.core.enable
excluded = settings.core.exclude

# coretasks is sacred
if name == 'coretasks':
if plugin_name == 'coretasks':
tools.stderr('Plugin coretasks is always enabled.')
return False

# is it already enabled, but should we enforce anything?
is_enabled = usable_plugins[name][1]
is_enabled = usable_plugins[plugin_name][1]
if is_enabled and not allow_only:
# already enabled, and no allow-only option: all good
if name in enabled:
tools.stderr('Plugin %s is already enabled.' % name)
if plugin_name in enabled:
tools.stderr('Plugin %s is already enabled.' % plugin_name)
else:
# suggest to use --allow-only option
tools.stderr(
'Plugin %s is enabled; '
'use option -a/--allow-only to enforce allow only policy.'
% name)
% plugin_name)

return False

# not enabled, or option allow_only to enforce
if name in excluded:
if plugin_name in excluded:
# remove from excluded
settings.core.exclude = [
name
for name in settings.core.exclude
if name != name
if plugin_name != name
]
elif name in enabled:
elif plugin_name in enabled:
# not excluded, and already in enabled list: all good
tools.stderr('Plugin %s is already enabled' % name)
tools.stderr('Plugin %s is already enabled' % plugin_name)
return False

if name not in enabled and (enabled or allow_only):
if plugin_name not in enabled and (enabled or allow_only):
# not excluded, but not enabled either: allow-only mode required
# either because of the current configuration, or by request
settings.core.enable = enabled + [name]
settings.core.enable = enabled + [plugin_name]

return True

Expand Down

0 comments on commit a168c57

Please sign in to comment.