mirror of
https://github.com/datafolklabs/cement.git
synced 2026-02-06 13:26:45 +00:00
Resoves Issue #380
This commit is contained in:
parent
d830412d15
commit
9bfcdcedb1
@ -44,6 +44,7 @@ Features:
|
||||
* :issue:`373` - Switch over to using Flake8 for PEP8 and style compliance
|
||||
* :pr:`375` - Redis cache handler support
|
||||
* :issue:`379` - Support for alternative config file extensions
|
||||
* :issue:`380` - Support for Cython/Compiled Plugins
|
||||
* :issue:`389` - ConfigObj support for Python 3
|
||||
|
||||
Refactoring;
|
||||
|
||||
@ -15,7 +15,7 @@ from ..utils import fs
|
||||
# The `imp` module is deprecated in favor of `importlib` in 3.4, but it
|
||||
# wasn't introduced until 3.1. Finally, reload is a builtin on Python < 3
|
||||
pyver = sys.version_info
|
||||
if pyver[0] >= 3 and pyver[1] >= 1: # pragma: nocover # noqa
|
||||
if pyver[0] >= 3 and pyver[1] >= 4: # pragma: nocover # noqa
|
||||
from importlib import reload as reload_module # pragma: nocover # noqa
|
||||
elif pyver[0] >= 3: # pragma: nocover # noqa
|
||||
from imp import reload as reload_module # pragma: nocover # noqa
|
||||
|
||||
@ -163,33 +163,31 @@ class CementPluginHandler(plugin.CementPluginHandler):
|
||||
|
||||
"""
|
||||
|
||||
paths = [
|
||||
os.path.join(plugin_dir, "%s.py" % plugin_name),
|
||||
os.path.join(plugin_dir, plugin_name, "__init__.py")
|
||||
]
|
||||
# FIX ME: `imp` is deprecated in Python 3.4 and will be going away
|
||||
# so we need to update forward compatibility for ``importlib``.
|
||||
#
|
||||
# See: https://github.com/datafolklabs/cement/issues/386
|
||||
|
||||
for path in paths:
|
||||
LOG.debug("attempting to load '%s' from '%s'" % (plugin_name,
|
||||
path))
|
||||
if os.path.exists(path):
|
||||
# We don't catch this because it would make debugging a
|
||||
# nightmare
|
||||
#
|
||||
# FIX ME: `imp` is deprecated in Python 3.4 and will be
|
||||
# going away... need to update forward compatibility for
|
||||
# ``importlib``.
|
||||
#
|
||||
# See: https://github.com/datafolklabs/cement/issues/386
|
||||
f, path, desc = imp.find_module(plugin_name, [plugin_dir])
|
||||
mod = imp.load_module(plugin_name, f, path, desc)
|
||||
if mod and hasattr(mod, 'load'):
|
||||
mod.load(self.app)
|
||||
return True
|
||||
LOG.debug("attempting to load '%s' from '%s'" % (plugin_name,
|
||||
plugin_dir))
|
||||
|
||||
LOG.debug("plugin '%s' does not exist in '%s'." %
|
||||
(plugin_name, plugin_dir))
|
||||
if not os.path.exists(plugin_dir):
|
||||
LOG.debug("plugin directory '%s' does not exist." % plugin_dir)
|
||||
return False
|
||||
|
||||
return False
|
||||
try:
|
||||
f, path, desc = imp.find_module(plugin_name, [plugin_dir])
|
||||
except ImportError:
|
||||
LOG.debug("plugin '%s' does not exist in '%s'." %
|
||||
(plugin_name, plugin_dir))
|
||||
return False
|
||||
|
||||
# We don't catch this because it would make debugging a
|
||||
# nightmare
|
||||
mod = imp.load_module(plugin_name, f, path, desc)
|
||||
if mod and hasattr(mod, 'load'):
|
||||
mod.load(self.app)
|
||||
return True
|
||||
|
||||
def _load_plugin_from_bootstrap(self, plugin_name, base_package):
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user