當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。