Ejemplo n.º 1
0
    def get_a_plugin(self, file_type=None, library=None):
        """get a plugin to handle the file type
        """
        PluginManager.get_a_plugin(self, file_type=file_type, library=library)
        __file_type = None
        if file_type:
            __file_type = file_type.lower()
        plugin_cls = self.load_me_now(file_type, library=library)

        return plugin_cls(__file_type)
Ejemplo n.º 2
0
 def get_a_plugin(self,
                  target=None,
                  action=None,
                  source_library=None,
                  **keywords):
     """obtain a source plugin for pyexcel signature functions"""
     PluginManager.get_a_plugin(self,
                                target=target,
                                action=action,
                                **keywords)
     key = REGISTRY_KEY_FORMAT % (target, action)
     source_cls = self.load_me_now(key,
                                   action=action,
                                   library=source_library,
                                   **keywords)
     source_instance = source_cls(**keywords)
     return source_instance
Ejemplo n.º 3
0
def test_get_a_plugin():
    test_plugin = 'test plugin'

    manager = PluginManager(test_plugin)
    plugin_info = make_me_a_plugin_info('my')
    plugin_info.cls = TestClass
    manager.register_a_plugin(TestClass, plugin_info)
    the_plugin = manager.get_a_plugin('my')
    assert isinstance(the_plugin, TestClass)
Ejemplo n.º 4
0
 def get_a_plugin(self,
                  plugin_match_title=None,
                  plugin_name=None,
                  **keywords):
     """
     根据插件名称获取对应插件实例
     如果有egg包插件则加载egg插件(定制优先原则)
     :param plugin_match_title: 插件匹配头
     :param plugin_name: 具体插件名(定制插件为egg包目录名)
     :param keywords: 参数
     :return:
     """
     egg_plugin = self.get_egg_plugin(plugin_match_title)
     key_plugin = egg_plugin if egg_plugin else plugin_name
     return PluginManager.get_a_plugin(self, key=key_plugin, **keywords)
Ejemplo n.º 5
0
Archivo: plugin.py Proyecto: ayan-b/lml
 def get_a_plugin(self, food_name=None, **keywords):
     return PluginManager.get_a_plugin(self, key=food_name, **keywords)