本文整理汇总了Python中stevedore.extension.ExtensionManager类的典型用法代码示例。如果您正苦于以下问题:Python ExtensionManager类的具体用法?Python ExtensionManager怎么用?Python ExtensionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ExtensionManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: get_setter_cmpt_mgr
def get_setter_cmpt_mgr():
return ExtensionManager.make_test_instance([Extension(
'set_aggregated_metric_name',
'monasca_transform.component.setter.'
'set_aggregated_metric_name:SetAggregatedMetricName',
SetAggregatedMetricName(),
None),
Extension('set_aggregated_period',
'monasca_transform.component.setter.'
'set_aggregated_period:SetAggregatedPeriod',
SetAggregatedPeriod(),
None),
Extension('rollup_quantity',
'monasca_transform.component.setter.'
'rollup_quantity:RollupQuantity',
RollupQuantity(),
None)
])
开发者ID:openstack,项目名称:monasca-transform,代码行数:18,代码来源:mock_component_manager.py
示例17: make_plugin_options
def make_plugin_options(self):
plugin_options = []
self.mgr = ExtensionManager(u'pyiupdater.uploaders')
plugin_names = self.mgr.names()
log.debug(u'Plugin names: {}'.format(plugin_names))
for pgn in plugin_names:
# passing none as a place holder for logic in
# cli.ui.menu for processing of plugin menu creation
# Logic will pass this to else since its len is
# more then 2
log.debug(u'Plugin name: {}'.format(pgn))
option = (pgn, self.upload, None)
plugin_options.append(option)
plugin_options.append((u'Main Menu', self.done))
return plugin_options
开发者ID:douglasmccormickjr,项目名称:PyiUpdater,代码行数:18,代码来源:upload.py
示例18: Upload
class Upload(CommonLogic, Menu):
def __init__(self, helpers):
self.unpack_helpers(helpers)
header = u'Upload'
message = (u'Make sure updates are in "new" folder '
'then press "1" to start.')
options = self.make_plugin_options()
super(Upload, self).__init__(header, options, message)
def make_plugin_options(self):
plugin_options = []
self.mgr = ExtensionManager(u'pyiupdater.uploaders')
plugin_names = self.mgr.names()
log.debug(u'Plugin names: {}'.format(plugin_names))
for pgn in plugin_names:
# passing none as a place holder for logic in
# cli.ui.menu for processing of plugin menu creation
# Logic will pass this to else since its len is
# more then 2
log.debug(u'Plugin name: {}'.format(pgn))
option = (pgn, self.upload, None)
plugin_options.append(option)
plugin_options.append((u'Main Menu', self.done))
return plugin_options
def upload(self, name):
# Load plugin & invoke upload method
self.uploader.set_uploader(name)
self.display_menu_header(u'{} Uploader'.format(name))
try:
self.uploader.upload()
time.sleep(3)
except Exception as e:
msg = (u'Looks like you forgot to add USERNAME, PASSWORD '
'and/or REMOTE_DIR')
self.display_msg(msg)
log.debug(str(e), exc_info=True)
input()
开发者ID:douglasmccormickjr,项目名称:PyiUpdater,代码行数:43,代码来源:upload.py
示例19: setUp
def setUp(self):
# Set up two user partition schemes: mock and random
extensions = [
Extension(
self.TEST_SCHEME_NAME, USER_PARTITION_SCHEME_NAMESPACE,
MockUserPartitionScheme(self.TEST_SCHEME_NAME), None
),
Extension(
"random", USER_PARTITION_SCHEME_NAMESPACE, MockUserPartitionScheme("random"), 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
)
开发者ID:JacobWay,项目名称:edx-platform,代码行数:23,代码来源:test_partitions.py
示例20: get_usage_cmpt_mgr
def get_usage_cmpt_mgr():
return ExtensionManager.make_test_instance([Extension(
'fetch_quantity',
'monasca_transform.component.usage.'
'fetch_quantity:'
'FetchQuantity',
FetchQuantity(),
None),
Extension(
'fetch_quantity_util',
'monasca_transform.component.usage.'
'fetch_quantity_util:'
'FetchQuantityUtil',
FetchQuantityUtil(),
None),
Extension(
'calculate_rate',
'monasca_transform.component.usage.'
'calculate_rate:'
'CalculateRate',
CalculateRate(),
None),
])
开发者ID:openstack,项目名称:monasca-transform,代码行数:23,代码来源:mock_component_manager.py
注:本文中的stevedore.extension.ExtensionManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论