提交 4c774a77 编写于 作者: P peng.xu

fix PluginBase import bug

上级 63997d55
import os
import logging
from functools import partial
# from pluginbase import PluginBase
# import importlib
from utils.pluginextension import MiPluginBase
from utils.pluginextension import MiPluginBase as PluginBase
logger = logging.getLogger(__name__)
......@@ -11,8 +9,8 @@ here = os.path.abspath(os.path.dirname(__file__))
get_path = partial(os.path.join, here)
PLUGIN_PACKAGE_NAME = 'router.plugins'
plugin_base = MiPluginBase(package=PLUGIN_PACKAGE_NAME,
searchpath=[get_path('./plugins')])
plugin_base = PluginBase(package=PLUGIN_PACKAGE_NAME,
searchpath=[get_path('./plugins')])
class RouterFactory(object):
......
import os
import logging
from functools import partial
from pluginbase import PluginBase
from utils.pluginextension import MiPluginBase as PluginBase
# from pluginbase import PluginBase
from tracer import Tracer
......
import importlib
import importlib.util
from pluginbase import PluginBase, PluginSource
class MiPluginSource(PluginSource):
def load_plugin(self, name):
if '.' in name:
raise ImportError('Plugin names cannot contain dots.')
with self:
return importlib.import_module(self.base.package + '.' + name)
plugin = super().load_plugin(name)
spec = importlib.util.spec_from_file_location(self.base.package + '.' + name, plugin.__file__)
plugin = importlib.util.module_from_spec(spec)
spec.loader.exec_module(plugin)
return plugin
class MiPluginBase(PluginBase):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册