diff --git a/ifarch.py b/ifarch.py index e1aa022..f9efe66 100644 --- a/ifarch.py +++ b/ifarch.py @@ -1,6 +1,11 @@ import platform +import glob +import os + import dotbot from dotbot.dispatcher import Dispatcher +from dotbot.util import module +from dotbot.plugins import Clean, Create, Link, Shell class IfArch(dotbot.Plugin): _archs = [ @@ -14,6 +19,19 @@ def __init__(self, context): super(IfArch, self).__init__(context) self._directives = ['if'+a for a in self._archs] + def _load_plugins(self): + plugin_paths = self._context.options().plugins + plugins = [] + for dir in self._context.options().plugin_dirs: + for path in glob.glob(os.path.join(dir, '*.py')): + plugin_paths.append(path) + for path in plugin_paths: + abspath = os.path.abspath(path) + plugins.extend(module.load(abspath)) + if not self._context.options().disable_built_in_plugins: + plugins.extend([Clean, Create, Link, Shell]) + return plugins + def can_handle(self, directive): return directive in self._directives @@ -32,6 +50,6 @@ def _run_internal(self, data): dispatcher = Dispatcher(self._context.base_directory(), only=self._context.options().only, skip=self._context.options().skip, - exit_on_failure=self._context.options().exit_on_failure, - options=self._context.options()) - return dispatcher.dispatch(data) + options=self._context.options(), + plugins=self._load_plugins()) + return dispatcher.dispatch(data) \ No newline at end of file