当前位置: 首页>>代码示例>>Python>>正文


Python extension.ExtensionManager类代码示例

本文整理汇总了Python中stevedore.extension.ExtensionManager的典型用法代码示例。如果您正苦于以下问题:Python ExtensionManager类的具体用法?Python ExtensionManager怎么用?Python ExtensionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ExtensionManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_available_plugins

def get_available_plugins(namespace):
    """Return names of the available / installed plugins for a given namespace.
    """
    from stevedore.extension import ExtensionManager

    manager = ExtensionManager(namespace=namespace, invoke_on_load=False)
    return manager.names()
开发者ID:lyandut,项目名称:st2,代码行数:7,代码来源:loader.py

示例2: list_providers

def list_providers():
    """
    Return a list of installed providers.
    """
    em = ExtensionManager(NAMESPACE)
    return em.map(lambda p:
                  {'name': p.name, 'version': p.plugin().get_version()})
开发者ID:billingstack,项目名称:python-fakturo,代码行数:7,代码来源:__init__.py

示例3: get_available_backends

def get_available_backends():
    """
    Return names of the available / installed authentication backends.

    :rtype: ``list`` of ``str``
    """
    manager = ExtensionManager(namespace=BACKENDS_NAMESPACE, invoke_on_load=False)
    return manager.names()
开发者ID:AlexeyDeyneko,项目名称:st2,代码行数:8,代码来源:__init__.py

示例4: get_scripts_by_name

def get_scripts_by_name(namespace):
    scripts_by_name = defaultdict(list)
    extension_manager = ExtensionManager(namespace, invoke_on_load=True)
    for name, extension in zip(extension_manager.names(), extension_manager.extensions):
        scripts_by_name[name].append(extension.obj)
    for name, scripts in scripts_by_name.items():
        scripts_by_name[name] = sorted(scripts, key=lambda x: x.priority)
    return scripts_by_name
开发者ID:invisibleroads,项目名称:invisibleroads,代码行数:8,代码来源:scripts.py

示例5: get_available_backends

def get_available_backends():
    """
    Return names of the available / installed action runners.

    :rtype: ``list`` of ``str``
    """
    from stevedore.extension import ExtensionManager

    manager = ExtensionManager(namespace=BACKENDS_NAMESPACE, invoke_on_load=False)
    return manager.names()
开发者ID:lyandut,项目名称:st2,代码行数:10,代码来源:__init__.py

示例6: get_available_plugins

 def get_available_plugins(cls, namespace=None):
     """
     Returns a dict of all the plugins that have been made available through the platform.
     """
     # Note: we're creating the extension manager lazily to ensure that the Python path
     # has been correctly set up. Trying to create this statically will fail, unfortunately.
     plugins = OrderedDict()
     extension_manager = ExtensionManager(namespace=namespace or cls.NAMESPACE)  # pylint: disable=no-member
     for plugin_name in extension_manager.names():
         plugins[plugin_name] = extension_manager[plugin_name].plugin
     return plugins
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:11,代码来源:plugins.py

示例7: __init__

 def __init__(self, filename):
     super(VarLoader, self).__init__()
     self.filename = filename
     loaders = ExtensionManager(
         namespace='usagi.var_loaders',
     )
     self.loaders = dict(
         (name, loaders[name].plugin)
         for name in loaders.names()
     )
     self.loader_keys = set(self.loaders.keys())
开发者ID:sjagoe,项目名称:usagi,代码行数:11,代码来源:var_loader.py

示例8: get_available_backends

def get_available_backends(namespace, invoke_on_load=False):
    """
    Return names of the available / installed backends.

    :rtype: ``list`` of ``str``
    """
    # NOTE: We use lazy import because importing from stevedore adds significat import time
    # overhead to other modules which don't need this package (stevedore needs to inspect various
    # entrypoint files on disk for all the installed Python packages which is slow)
    from stevedore.extension import ExtensionManager

    manager = ExtensionManager(namespace=namespace, invoke_on_load=invoke_on_load)
    return manager.names()
开发者ID:StackStorm,项目名称:st2,代码行数:13,代码来源:driver_loader.py

示例9: setUp

    def setUp(self):
        super(PartitionTestCase, self).setUp()
        # Set up two user partition schemes: mock and random
        self.non_random_scheme = MockUserPartitionScheme(self.TEST_SCHEME_NAME)
        self.random_scheme = MockUserPartitionScheme("random")
        extensions = [
            Extension(
                self.non_random_scheme.name, USER_PARTITION_SCHEME_NAMESPACE, self.non_random_scheme, None
            ),
            Extension(
                self.random_scheme.name, USER_PARTITION_SCHEME_NAMESPACE, self.random_scheme, None
            ),
        ]
        UserPartition.scheme_extensions = ExtensionManager.make_test_instance(
            extensions, namespace=USER_PARTITION_SCHEME_NAMESPACE
        )

        # Create a test partition
        self.user_partition = UserPartition(
            self.TEST_ID,
            self.TEST_NAME,
            self.TEST_DESCRIPTION,
            self.TEST_GROUPS,
            extensions[0].plugin,
            self.TEST_PARAMETERS,
        )

        # Make sure the names are set on the schemes (which happens normally in code, but may not happen in tests).
        self.user_partition.get_scheme(self.non_random_scheme.name)
        self.user_partition.get_scheme(self.random_scheme.name)
开发者ID:10clouds,项目名称:edx-platform,代码行数:30,代码来源:test_partitions.py

示例10: test_get_default_driver

    def test_get_default_driver(self):
        # Given
        class OtherRunner(BaseTestRunner):
            pass

        default = Extension(
            'default', None, BaseTestRunner, None)
        other = Extension(
            'other', None, OtherRunner, None)
        driver_managers = [
            (PluginManager.TEST_RUNNER, ExtensionManager.make_test_instance(
                [default, other], namespace=PluginManager.TEST_RUNNER)),
        ]
        plugin_manager = PluginManager.testing_plugin_manager(
            hook_managers=(), driver_managers=driver_managers)
        parser = create_argument_parser()
        plugin_manager.add_plugin_arguments(parser)

        # When
        args = parser.parse_args([])
        plugin_manager.get_driver(plugin_manager.TEST_RUNNER, args)
        runner = plugin_manager.get_driver(plugin_manager.TEST_RUNNER, args)

        # Then
        self.assertNotIsInstance(runner, OtherRunner)
开发者ID:sjagoe,项目名称:haas,代码行数:25,代码来源:test_plugin_manager.py

示例11: test_environment_hook_options

    def test_environment_hook_options(self):
        class TestingPlugin(BaseTestingPlugin):
            add_parser_arguments_called = 0
            from_args_called = 0

            @classmethod
            def add_parser_arguments(cls, parser, name, option_prefix,
                                     dest_prefix):
                cls.add_parser_arguments_called += 1
                return super(TestingPlugin, cls).add_parser_arguments(
                    parser, name, option_prefix, dest_prefix)

            @classmethod
            def from_args(cls, args, name, dest_prefix):
                cls.from_args_called += 1
                return super(TestingPlugin, cls).from_args(
                    args, name, dest_prefix)

        # Given
        extension = Extension(
            'testing-plugin', None, TestingPlugin, None)
        environment_manager = ExtensionManager.make_test_instance(
            [extension], namespace=PluginManager.ENVIRONMENT_HOOK,
        )
        hook_managers = [(PluginManager.ENVIRONMENT_HOOK, environment_manager)]
        plugin_manager = PluginManager.testing_plugin_manager(
            hook_managers=hook_managers, driver_managers=())
        parser = ArgumentParser(add_help=False)

        # When
        plugin_manager.add_plugin_arguments(parser)

        # Then
        self.assertEqual(TestingPlugin.add_parser_arguments_called, 1)
        actions = parser._actions
        self.assertEqual(len(actions), 1)
        action, = actions
        self.assertEqual(action.option_strings, ['--with-testing-plugin'])

        # When
        args = parser.parse_args([])
        enabled_plugins = plugin_manager.get_enabled_hook_plugins(
            plugin_manager.ENVIRONMENT_HOOK, args)

        # Then
        self.assertEqual(enabled_plugins, [])
        self.assertEqual(TestingPlugin.from_args_called, 1)

        # When
        args = parser.parse_args(['--with-testing-plugin'])
        enabled_plugins = plugin_manager.get_enabled_hook_plugins(
            plugin_manager.ENVIRONMENT_HOOK, args)

        # Then
        self.assertEqual(len(enabled_plugins), 1)

        plugin_obj, = enabled_plugins
        self.assertEqual(TestingPlugin.from_args_called, 2)
        self.assertTrue(plugin_obj.enabled)
开发者ID:sjagoe,项目名称:haas,代码行数:59,代码来源:test_plugin_manager.py

示例12: __init__

    def __init__(self, loader):
        super(YamlTestLoader, self).__init__()
        self._loader = loader

        assertions = ExtensionManager(
            namespace='usagi.assertions',
        )
        test_parameters = ExtensionManager(
            namespace='usagi.parameters'
        )

        self._assertions_map = dict(
            (name, assertions[name].plugin)
            for name in assertions.names()
        )
        self._test_parameters = dict(
            (name, test_parameters[name].plugin)
            for name in test_parameters.names()
        )
开发者ID:sjagoe,项目名称:usagi,代码行数:19,代码来源:yaml_test_loader.py

示例13: register_runners

def register_runners(experimental=False, fail_on_failure=True):
    """
    Register runners
    """
    LOG.debug('Start : register runners')
    runner_count = 0

    manager = ExtensionManager(namespace=RUNNERS_NAMESPACE, invoke_on_load=False)
    extension_names = manager.names()

    for name in extension_names:
        LOG.debug('Found runner "%s"' % (name))

        manager = DriverManager(namespace=RUNNERS_NAMESPACE, invoke_on_load=False, name=name)
        runner_metadata = manager.driver.get_metadata()
        runner_count += register_runner(runner_metadata, experimental)

    LOG.debug('End : register runners')

    return runner_count
开发者ID:nzlosh,项目名称:st2,代码行数:20,代码来源:runnersregistrar.py

示例14: test_no_driver_hook_found

    def test_no_driver_hook_found(self):
        # Given
        driver_managers = [
            (PluginManager.TEST_RUNNER, ExtensionManager.make_test_instance(
                [], namespace=PluginManager.TEST_RUNNER)),
        ]
        plugin_manager = PluginManager.testing_plugin_manager(
            hook_managers=(), driver_managers=driver_managers)
        parser = ArgumentParser(add_help=False)

        # When
        plugin_manager.add_plugin_arguments(parser)

        # Then
        actions = parser._actions
        self.assertEqual(len(actions), 0)
开发者ID:sjagoe,项目名称:haas,代码行数:16,代码来源:test_plugin_manager.py

示例15: get_insert_cmpt_mgr

 def get_insert_cmpt_mgr():
     return ExtensionManager.make_test_instance([Extension(
         'prepare_data',
         'monasca_transform.component.insert.prepare_data:PrepareData',
         PrepareData(),
         None),
         Extension('insert_data',
                   'tests.functional.component.insert.dummy_insert:'
                   'DummyInsert',
                   DummyInsert(),
                   None),
         Extension('insert_data_pre_hourly',
                   'tests.functional.component.insert.dummy_insert:'
                   'DummyInsert',
                   DummyInsert(),
                   None),
     ])
开发者ID:openstack,项目名称:monasca-transform,代码行数:17,代码来源:mock_component_manager.py


注:本文中的stevedore.extension.ExtensionManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。