diff piecrust/plugins/base.py @ 1005:2e5c5d33d62c

Merge changes.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 21 Nov 2017 22:07:12 -0800
parents e7ca3c577305 46025a1b5434
children 8af2ea1f5c34
line wrap: on
line diff
--- a/piecrust/plugins/base.py	Tue Nov 21 21:30:37 2017 -0800
+++ b/piecrust/plugins/base.py	Tue Nov 21 22:07:12 2017 -0800
@@ -130,24 +130,25 @@
         except ImportError as ex:
             mod = None
 
-        if mod is None and self.app.plugins_dir:
+        if mod is None:
             # Import as a loose Python file from the plugins dir.
-            pfile = os.path.join(self.app.plugins_dir, plugin_name + '.py')
-            if os.path.isfile(pfile):
-                if sys.version_info[1] >= 5:
-                    # Python 3.5+
-                    from importlib.util import (spec_from_file_location,
-                                                module_from_spec)
-                    spec = spec_from_file_location(plugin_name, pfile)
-                    mod = module_from_spec(spec)
-                    spec.loader.exec_module(mod)
-                    sys.modules[mod_name] = mod
-                else:
-                    # Python 3.4, 3.3.
-                    from importlib.machinery import SourceFileLoader
-                    mod = SourceFileLoader(
-                        plugin_name, pfile).load_module()
-                    sys.modules[mod_name] = mod
+            for plugins_dir in self.app.plugins_dirs:
+                pfile = os.path.join(plugins_dir, plugin_name + '.py')
+                if os.path.isfile(pfile):
+                    if sys.version_info[1] >= 5:
+                        # Python 3.5+
+                        from importlib.util import (spec_from_file_location,
+                                                    module_from_spec)
+                        spec = spec_from_file_location(plugin_name, pfile)
+                        mod = module_from_spec(spec)
+                        spec.loader.exec_module(mod)
+                        sys.modules[mod_name] = mod
+                    else:
+                        # Python 3.4, 3.3.
+                        from importlib.machinery import SourceFileLoader
+                        mod = SourceFileLoader(
+                            plugin_name, pfile).load_module()
+                        sys.modules[mod_name] = mod
 
         if mod is None:
             logger.error("Failed to load plugin '%s'." % plugin_name)