Python oslo_utils.importutils 模块,import_versioned_module() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用oslo_utils.importutils.import_versioned_module()

项目:python-adjutantclient    作者:openstack    | 项目源码 | 文件源码
def Client(version, *args, **kwargs):
    module = importutils.import_versioned_module(
        'adjutantclient', version, 'client')
    client_class = getattr(module, 'Client')
    return client_class(*args, **kwargs)
项目:python-cratonclient    作者:openstack    | 项目源码 | 文件源码
def get_subcommand_parser(self, api_version):
        """Get subcommands by parsing COMMAND_MODULES."""
        parser = self.get_base_parser()

        self.subcommands = {}
        subparsers = parser.add_subparsers(metavar='<subcommand>',
                                           dest='subparser_name')
        shell = importutils.import_versioned_module(
            'cratonclient.shell',
            api_version,
            'shell',
        )
        command_modules = shell.COMMAND_MODULES
        for command_module in command_modules:
            self._find_subparsers(subparsers, command_module)
        self._find_subparsers(subparsers, self)
        return parser

    # NOTE(cmspence): Credit for this function goes to the
    # magnumclient developers and contributors.
项目:python-iotronicclient    作者:openstack    | 项目源码 | 文件源码
def get_subcommand_parser(self, version):
        parser = self.get_base_parser()

        self.subcommands = {}
        subparsers = parser.add_subparsers(metavar='<subcommand>',
                                           dest='subparser_name')
        try:
            submodule = importutils.import_versioned_module('iotronicclient',
                                                            version, 'shell')
        except ImportError as e:
            msg = _("Invalid client version '%(version)s'. "
                    "Major part must be one of: '%(major)s'") % {
                "version": version,
                "major": ", ".join(self.get_available_major_versions())}
            raise exceptions.UnsupportedVersion(
                _('%(message)s, error was: %(error)s') %
                {'message': msg, 'error': e})
        submodule.enhance_parser(parser, subparsers, self.subcommands)
        utils.define_commands_from_module(subparsers, self, self.subcommands)
        return parser
项目:python-qinlingclient    作者:openstack    | 项目源码 | 文件源码
def Client(version, *args, **kwargs):
    module = importutils.import_versioned_module('qinlingclient',
                                                 version, 'client')
    client_class = getattr(module, 'Client')
    return client_class(*args, **kwargs)
项目:python-karborclient    作者:openstack    | 项目源码 | 文件源码
def Client(version, *args, **kwargs):
    module = importutils.import_versioned_module(
        'karborclient', version, 'client'
    )
    client_class = getattr(module, 'Client')
    return client_class(*args, **kwargs)
项目:python-karborclient    作者:openstack    | 项目源码 | 文件源码
def get_subcommand_parser(self, version, argv=None):
        parser = self.get_base_parser(argv)

        self.subcommands = {}
        subparsers = parser.add_subparsers(metavar='<subcommand>')
        submodule = importutils.import_versioned_module(
            'karborclient', version, 'shell'
        )
        self._find_actions(subparsers, submodule)
        self._find_actions(subparsers, self)

        return parser
项目:python-iotronicclient    作者:openstack    | 项目源码 | 文件源码
def Client(version, *args, **kwargs):
    module = importutils.import_versioned_module('iotronicclient',
                                                 version, 'client')
    client_class = getattr(module, 'Client')
    return client_class(*args, **kwargs)