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


Python PackageIndex.prescan方法代码示例

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


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

示例1: HTMLRepository

# 需要导入模块: from setuptools.package_index import PackageIndex [as 别名]
# 或者: from setuptools.package_index.PackageIndex import prescan [as 别名]
class HTMLRepository(RemoteRepository):
    """\
    A remote repository which easy_install can cope with.

    """
    def __init__(self, location, index=False, verbose=False):
        self.location = format_as_url(location)
        self.index = index
        if index:
            self.environment = PackageIndex(index_url=self.location,
                                            search_path=[])
        else:
            self.environment = PackageIndex(no_default_index=True)
            self.environment.add_find_links([self.location])
        self._projects = None
        self.tmpdir = mkdtemp(prefix="ensetuptools-")
        self.verbose = verbose

    @property
    def projects(self):
        if self._projects == None:
            self._projects = {}
            info("Scanning repository at %s..." % self.location)
            self.environment.prescan()
            self.environment.scan_all()
            for project in self.environment:
                self._projects[project] = HTMLProject(self, project,
                    verbose=self.verbose)
            for project in self.environment.package_pages:
                if project not in self._projects:
                    self._projects[project] = HTMLProject(self, project,
                        verbose=self.verbose)
                self._projects[project].scan_needed = True
        return self._projects

    def search(self, combiner='and', **kwargs):
        if 'project' not in kwargs:
            raise SearchError("EasyInstall-based remote repositories require"
                              " a 'project' search term.")
        if isinstance(kwargs['project'], basestring):
            return self.projects[kwargs['project']].match(combiner, **kwargs)
        partial_match_names = set(project_name
                                  for project_name in self.projects
                                  if kwargs['project'].match(project_name))
        matches = []
        for project in partial_match_names:
            matches += self.projects[project].search(combiner, **kwargs)
        return matches
开发者ID:pombredanne,项目名称:ensetuptools,代码行数:50,代码来源:repository.py


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