コード例 #1
0
def enumerate_backend_plugins(all_plugins_paths):
    plugin_places = [Path(root) for root in all_plugins_paths]
    for path in plugin_places:
        plugfiles = path.glob('**/*.plug')
        for plugfile in plugfiles:
            plugin_info = PluginInfo.load(plugfile)
            yield plugin_info
コード例 #2
0
def enumerate_backend_plugins(all_plugins_paths):
    plugin_places = [Path(root) for root in all_plugins_paths]
    for path in plugin_places:
        plugfiles = path.glob('**/*.plug')
        for plugfile in plugfiles:
            plugin_info = PluginInfo.load(plugfile)
            yield plugin_info
コード例 #3
0
ファイル: cmbot_testcase.py プロジェクト: codemute/cmbot
 def load_plugin_templates(self, klass):
     plug_filename = klass.__module__.split('.')[-1] + '.plug'
     plug_file_path = (Path(__file__).parent / '..' / 'plugins' /
                       plug_filename)
     with plug_file_path.open() as plugfile:
         plug_info = PluginInfo.load_file(plugfile, plug_file_path)
         self.plug_files[klass.__name__] = plug_info
         add_plugin_templates_path(plug_info)
コード例 #4
0
def enumerate_backend_plugins(
        all_plugins_paths: List[Union[str, Path]]) -> Iterator[PluginInfo]:
    plugin_places = [Path(root) for root in all_plugins_paths]
    for path in plugin_places:
        plugfiles = path.glob("**/*.plug")
        for plugfile in plugfiles:
            plugin_info = PluginInfo.load(plugfile)
            yield plugin_info
コード例 #5
0
ファイル: plugin_info_test.py プロジェクト: zzszmyf/errbot
def test_load_from_plugfile_path():
    pi = PluginInfo.load(plugfile_path)
    assert pi.name == 'Config'
    assert pi.module == 'config'
    assert pi.doc is None
    assert pi.python_version == (3, 0, 0)
    assert pi.errbot_minversion is None
    assert pi.errbot_maxversion is None
コード例 #6
0
ファイル: plugin_management_test.py プロジェクト: zoni/errbot
def test_errbot_version_check():
    real_version = plugin_manager.VERSION

    too_high_min_1 = dummy_config_parser()
    too_high_min_1.set('Errbot', 'Min', '1.6.0')

    too_high_min_2 = dummy_config_parser()
    too_high_min_2.set('Errbot', 'Min', '1.6.0')
    too_high_min_2.set('Errbot', 'Max', '2.0.0')

    too_low_max_1 = dummy_config_parser()
    too_low_max_1.set('Errbot', 'Max', '1.0.1-beta')

    too_low_max_2 = dummy_config_parser()
    too_low_max_2.set('Errbot', 'Min', '0.9.0-rc2')
    too_low_max_2.set('Errbot', 'Max', '1.0.1-beta')

    ok1 = dummy_config_parser()  # empty section

    ok2 = dummy_config_parser()
    ok2.set('Errbot', 'Min', '1.4.0')

    ok3 = dummy_config_parser()
    ok3.set('Errbot', 'Max', '1.5.2')

    ok4 = dummy_config_parser()
    ok4.set('Errbot', 'Min', '1.2.1')
    ok4.set('Errbot', 'Max', '1.6.1-rc1')

    try:
        plugin_manager.VERSION = '1.5.2'
        for config in (too_high_min_1,
                       too_high_min_2,
                       too_low_max_1,
                       too_low_max_2):
            pi = PluginInfo.parse(config)
            with pytest.raises(IncompatiblePluginException):
                plugin_manager.check_errbot_version(pi)

        for config in (ok1, ok2, ok3, ok4):
            pi = PluginInfo.parse(config)
            plugin_manager.check_errbot_version(pi)
    finally:
        plugin_manager.VERSION = real_version
コード例 #7
0
def test_errbot_version_check():
    real_version = plugin_manager.VERSION

    too_high_min_1 = dummy_config_parser()
    too_high_min_1.set('Errbot', 'Min', '1.6.0')

    too_high_min_2 = dummy_config_parser()
    too_high_min_2.set('Errbot', 'Min', '1.6.0')
    too_high_min_2.set('Errbot', 'Max', '2.0.0')

    too_low_max_1 = dummy_config_parser()
    too_low_max_1.set('Errbot', 'Max', '1.0.1-beta')

    too_low_max_2 = dummy_config_parser()
    too_low_max_2.set('Errbot', 'Min', '0.9.0-rc2')
    too_low_max_2.set('Errbot', 'Max', '1.0.1-beta')

    ok1 = dummy_config_parser()  # empty section

    ok2 = dummy_config_parser()
    ok2.set('Errbot', 'Min', '1.4.0')

    ok3 = dummy_config_parser()
    ok3.set('Errbot', 'Max', '1.5.2')

    ok4 = dummy_config_parser()
    ok4.set('Errbot', 'Min', '1.2.1')
    ok4.set('Errbot', 'Max', '1.6.1-rc1')

    try:
        plugin_manager.VERSION = '1.5.2'
        for config in (too_high_min_1, too_high_min_2, too_low_max_1,
                       too_low_max_2):
            pi = PluginInfo.parse(config)
            with pytest.raises(IncompatiblePluginException):
                plugin_manager.check_errbot_version(pi)

        for config in (ok1, ok2, ok3, ok4):
            pi = PluginInfo.parse(config)
            plugin_manager.check_errbot_version(pi)
    finally:
        plugin_manager.VERSION = real_version
コード例 #8
0
ファイル: plugin_info_test.py プロジェクト: zzszmyf/errbot
def test_doc():
    f = StringIO("""
    [Core]
    Name = Config
    Module = config

    [Documentation]
    Description = something
    """)

    assert PluginInfo.load_file(f, None).doc == 'something'
コード例 #9
0
ファイル: plugin_info_test.py プロジェクト: zzszmyf/errbot
def test_python_version_parse(test_input, expected):
    f = StringIO("""
    [Core]
    Name = Config
    Module = config

    [Python]
    Version = %s
    """ % test_input)

    assert PluginInfo.load_file(f, None).python_version == expected
コード例 #10
0
ファイル: plugin_info_test.py プロジェクト: zzszmyf/errbot
def test_errbot_version():
    f = StringIO("""
    [Core]
    Name = Config
    Module = config
    [Errbot]
    Min = 1.2.3
    Max = 4.5.6-beta
    """)
    info = PluginInfo.load_file(f, None)
    assert info.errbot_minversion == (1, 2, 3, sys.maxsize)
    assert info.errbot_maxversion == (4, 5, 6, 0)
コード例 #11
0
    def __init__(self, bot_config, base_module: str, plugin_name: str, base_class: Type,
                 base_search_dir, extra_search_dirs=()):
        self._config = bot_config
        self._base_module = base_module
        self._base_class = base_class

        self.plugin_info = None
        all_plugins_paths = collect_roots((base_search_dir, extra_search_dirs))
        plugin_places = [Path(root) for root in all_plugins_paths]
        for path in plugin_places:
            plugfiles = path.glob('**/*.plug')
            for plugfile in plugfiles:
                plugin_info = PluginInfo.load(plugfile)
                if plugin_info.name == plugin_name:
                    self.plugin_info = plugin_info
                    return
        raise PluginNotFoundException(f'Could not find the plugin named {plugin_name} in {all_plugins_paths}.')
コード例 #12
0
    def __init__(self,
                 bot_config,
                 base_module: str,
                 plugin_name: str,
                 base_class: Type,
                 base_search_dir,
                 extra_search_dirs=()):
        self._config = bot_config
        self._base_module = base_module
        self._base_class = base_class

        self.plugin_info = None
        all_plugins_paths = collect_roots((base_search_dir, extra_search_dirs))
        plugin_places = [Path(root) for root in all_plugins_paths]
        for path in plugin_places:
            plugfiles = path.glob('**/*.plug')
            for plugfile in plugfiles:
                plugin_info = PluginInfo.load(plugfile)
                if plugin_info.name == plugin_name:
                    self.plugin_info = plugin_info
                    return
        raise PluginNotFoundException(
            f'Could not find the plugin named {plugin_name} in {all_plugin_paths}.'
        )