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


Python pkg_resources.get_provider方法代码示例

本文整理汇总了Python中pkg_resources.get_provider方法的典型用法代码示例。如果您正苦于以下问题:Python pkg_resources.get_provider方法的具体用法?Python pkg_resources.get_provider怎么用?Python pkg_resources.get_provider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pkg_resources的用法示例。


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

示例1: _get_version_from_pkg_resources

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_provider [as 别名]
def _get_version_from_pkg_resources(self):
        """Obtain a version from pkg_resources or setup-time logic if missing.

        This will try to get the version of the package from the pkg_resources
        record associated with the package, and if there is no such record
        falls back to the logic sdist would use.
        """
        try:
            requirement = pkg_resources.Requirement.parse(self.package)
            provider = pkg_resources.get_provider(requirement)
            result_string = provider.version
        except pkg_resources.DistributionNotFound:
            # The most likely cause for this is running tests in a tree
            # produced from a tarball where the package itself has not been
            # installed into anything. Revert to setup-time logic.
            from pbr import packaging
            result_string = packaging.get_version(self.package)
        return SemanticVersion.from_pip_string(result_string) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:20,代码来源:version.py

示例2: get_package_loader

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_provider [as 别名]
def get_package_loader(self, package, package_path):
        from pkg_resources import DefaultProvider, ResourceManager, get_provider

        loadtime = datetime.utcnow()
        provider = get_provider(package)
        manager = ResourceManager()
        filesystem_bound = isinstance(provider, DefaultProvider)

        def loader(path):
            if path is None:
                return None, None

            path = posixpath.join(package_path, path)

            if not provider.has_resource(path):
                return None, None

            basename = posixpath.basename(path)

            if filesystem_bound:
                return (
                    basename,
                    self._opener(provider.get_resource_filename(manager, path)),
                )

            s = provider.get_resource_string(manager, path)
            return basename, lambda: (BytesIO(s), loadtime, len(s))

        return loader 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:31,代码来源:shared_data.py

示例3: __init__

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_provider [as 别名]
def __init__(self, package_name, package_path="templates", encoding="utf-8"):
        from pkg_resources import DefaultProvider
        from pkg_resources import get_provider
        from pkg_resources import ResourceManager

        provider = get_provider(package_name)
        self.encoding = encoding
        self.manager = ResourceManager()
        self.filesystem_bound = isinstance(provider, DefaultProvider)
        self.provider = provider
        self.package_path = package_path 
开发者ID:pypa,项目名称:pipenv,代码行数:13,代码来源:loaders.py

示例4: __init__

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_provider [as 别名]
def __init__(self):
        """ Initialize CLI.
        """
        self.startup = time.time()
        self.LOG = pymagic.get_class_logger(self)

        # Get version number
        self.version = self.VERSION
        if not self.version:
            # Take version from package
            provider = pkg_resources.get_provider(__name__)
            pkg_meta = (provider.get_metadata("PKG-INFO")
                        or provider.get_metadata("METADATA")
                        or self._get_pkg_meta())
            pkg_dict = dict(line.split(": ", 1)
                for line in pkg_meta.splitlines()
                if ": " in line
            )
            self.version = pkg_dict.get("Version", "DEV")

        where = os.path.commonprefix([__file__, os.path.realpath(sys.argv[0]), sys.prefix])
        where = re.sub('^' + os.path.expanduser('~') + os.sep, '~' + os.sep, where + os.sep).rstrip(os.sep)
        self.version_info = '{}{}{} on Python {}'.format(
           self.version, ' from ' if where else '', where, sys.version.split()[0])

        self.args = None
        self.options = None
        self.return_code = 0
        self.parser = OptionParser(
            "%prog [options] " + self.ARGS_HELP + "\n\n"
            "%prog " + self.version_info + ('\n' + self.COPYRIGHT if self.COPYRIGHT else "") + "\n\n"
            + textwrap.dedent(self.__doc__.rstrip()).lstrip('\n')
            + '\n'.join(self.ADDITIONAL_HELP)
            + "\n\nFor more details, see the full documentation at"
            + "\n\n    https://pyrocore.readthedocs.io/",
            version="%prog " + self.version_info) 
开发者ID:pyroscope,项目名称:pyrocore,代码行数:38,代码来源:base.py

示例5: set_project_info

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_provider [as 别名]
def set_project_info():
    """Set project information from setup tools installation."""
    # CUSTOMIZE THIS VALUE FOR YOUR OWN INSTALLATION
    base_url = 'https://slack-tableflip.herokuapp.com'

    # Get app info from the dist
    app_name = 'slack_tableflip'
    provider = get_provider(app_name)

    return {
        'name': app_name,
        'name_full': 'EM Slack Tableflip',
        'author_url': 'http://www.erinmorelli.com',
        'github_url': 'https://github.com/ErinMorelli/em-slack-tableflip',
        'version': '1.10',
        'version_int': 1.10,
        'package_path': provider.module_path,
        'copyright': '2015-{0}'.format(str(date.today().year)),
        'client_secret': os.environ['SLACK_CLIENT_SECRET'],
        'client_id': os.environ['SLACK_CLIENT_ID'],
        'base_url': base_url,
        'oauth_url': 'https://slack.com/oauth/authorize',
        'auth_url': '{0}/authenticate'.format(base_url),
        'user_url': '{0}/validate'.format(base_url),
        'team_url': '{0}/authorize'.format(base_url),
        'team_scope': [
            'commands'
        ],
        'user_scope': [
            'chat:write:bot',
            'chat:write:user',
            'identify'
        ]
    }


# Project info 
开发者ID:ErinMorelli,项目名称:em-slack-tableflip,代码行数:39,代码来源:__init__.py


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