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


Python repository.Repository类代码示例

本文整理汇总了Python中enstaller.repository.Repository的典型用法代码示例。如果您正苦于以下问题:Python Repository类的具体用法?Python Repository怎么用?Python Repository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_find_packages_sorting

    def test_find_packages_sorting(self):
        # Given
        entries = [
            dummy_installed_package_factory("numpy", "1.6.1", 1),
            dummy_installed_package_factory("numpy", "1.8.0", 2),
            dummy_installed_package_factory("numpy", "1.7.1", 1),
        ]
        repository = Repository()
        for entry in entries:
            repository.add_package(entry)

        r_versions = [
            EnpkgVersion.from_string(v)
            for v in ("1.6.1-1", "1.7.1-1", "1.8.0-2")
        ]

        # When
        packages = repository.find_packages("numpy")

        # Then
        self.assertEqual(len(packages), 3)
        self.assertEqual([p.version for p in packages], r_versions)

        with self.assertWarns(DeprecationWarning):
            deprecated_packages = repository.find_sorted_packages("numpy")
        self.assertEqual([p.version for p in deprecated_packages], r_versions)
开发者ID:enthought,项目名称:enstaller,代码行数:26,代码来源:test_repository.py

示例2: __init__

    def __init__(self, remote_repository, session,
                 prefixes=[sys.prefix], progress_context=None,
                 force=False, max_retries=_DEFAULT_MAX_RETRIES,
                 runtime_info=None):
        self.prefixes = prefixes
        self.top_prefix = prefixes[0]

        self._runtime_info = (
            runtime_info or _default_runtime_info(self.top_prefix)
        )

        self._remote_repository = remote_repository

        self._installed_repository = Repository._from_prefixes(self.prefixes)
        self._top_installed_repository = \
            Repository._from_prefixes([self.top_prefix])

        self._session = session
        self._downloader = _DownloadManager(session, remote_repository)

        self._progress_context = progress_context or \
            ProgressBarContext(dummy_progress_bar_factory)

        self._force = force
        self.max_retries = max_retries
开发者ID:enthought,项目名称:enstaller,代码行数:25,代码来源:enpkg.py

示例3: repository_factory_from_egg

 def repository_factory_from_egg(filenames):
     repository = Repository()
     for filename in filenames:
         path = os.path.join(_EGGINST_COMMON_DATA, filename)
         package = RemotePackageMetadata.from_egg(path)
         repository.add_package(package)
     return repository
开发者ID:enthought,项目名称:enstaller,代码行数:7,代码来源:test_repository.py

示例4: repository_factory

def repository_factory(session, repository_infos, quiet=False,
                       raise_on_error=False):
    unavailables = []
    full_repository = Repository()

    _write_and_flush("Fetching indices: ", quiet)

    with ThreadPoolExecutor(max_workers=4) as executor:
        tasks = {}
        for repository_info in repository_infos:
            task = executor.submit(_fetch_repository, session,
                                   repository_info, raise_on_error)
            tasks[task] = repository_info

        for task in as_completed(tasks):
            repository_or_none = task.result()
            if repository_or_none is None:
                unavailables.append(tasks[task])
            else:
                for package in repository_or_none.iter_packages():
                    full_repository.add_package(package)
            _write_and_flush(".", quiet)

    _write_and_flush("\n\n", quiet)

    if len(unavailables) > 0 and not quiet:
        _print_unavailables_warning(unavailables)
    return full_repository
开发者ID:JoelB,项目名称:enstaller,代码行数:28,代码来源:utils.py

示例5: test_simple_scenario

    def test_simple_scenario(self):
        egg = DUMMY_EGG
        r_actions = {1: [], 0: [("remove", os.path.basename(egg))]}
        config = Configuration()

        repository = Repository()
        package = RepositoryPackageMetadata.from_egg(egg)
        package.python = PY_VER
        repository.add_package(package)

        with open(egg, "rb") as fp:
            responses.add(responses.GET, package.source_url,
                          body=fp.read(), status=200,
                          content_type='application/json')

        session = Session(DummyAuthenticator(), config.repository_cache)

        enpkg = Enpkg(repository, session, prefixes=self.prefixes)
        actions = [("fetch", os.path.basename(egg)),
                   ("install", os.path.basename(egg))]
        enpkg.execute(actions)

        name, version = egg_name_to_name_version(egg)
        enpkg._installed_repository.find_package(name, version)

        for state in [0, 1]:
            actions = enpkg.revert_actions(state)
            self.assertEqual(actions, r_actions[state])
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:28,代码来源:test_enpkg.py

示例6: test_simple_installed

    def test_simple_installed(self):
        # Given
        entries = [
            dummy_repository_package_factory("MKL", "10.3", 1),
            dummy_repository_package_factory("numpy", "1.8.0", 2,
                                             dependencies=["MKL 10.3"]),
        ]

        repository = repository_factory(entries)
        installed_repository = Repository()
        installed_repository.add_package(
            dummy_installed_package_factory("MKL", "10.3", 1)
        )

        expected_actions = [
            ('install', "numpy-1.8.0-2.egg"),
        ]

        # When
        request = Request()
        request.install(Requirement("numpy"))

        solver = Solver(repository, installed_repository)
        actions = solver.resolve(request)

        # Then
        self.assertListEqual(actions, expected_actions)
开发者ID:JoelB,项目名称:enstaller,代码行数:27,代码来源:test_core.py

示例7: repository_factory

def repository_factory(package_names, repository_info, reference_packages):
    repository = Repository()
    for package_name in package_names:
        package = reference_packages[package_name]
        package = RepositoryPackageMetadata.from_package(package, repository_info)
        repository.add_package(package)
    return repository
开发者ID:pombreda,项目名称:enstaller,代码行数:7,代码来源:yaml_utils.py

示例8: _downloader_factory

    def _downloader_factory(self, paths):
        repository = Repository()
        for path in paths:
            package = RepositoryPackageMetadata.from_egg(path)
            repository.add_package(package)

        return (_DownloadManager(Session(DummyAuthenticator(), self.tempdir), repository),
                repository)
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:8,代码来源:test_enpkg.py

示例9: _create_store_and_repository

    def _create_store_and_repository(self, eggs):
        repository = Repository()
        for egg in eggs:
            path = os.path.join(_EGGINST_COMMON_DATA, egg)
            package = RepositoryPackageMetadata.from_egg(path)
            repository.add_package(package)

        return repository
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:8,代码来源:test_fetch.py

示例10: test_delete_non_existing

    def test_delete_non_existing(self):
        # Given
        path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")
        to_remove = PackageMetadata.from_egg(path)
        repository = Repository()

        # When/Then
        with self.assertRaises(NoSuchPackage):
            repository.delete_package(to_remove)
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:9,代码来源:test_repository.py

示例11: _install_eggs

    def _install_eggs(self, paths):
        repository = Repository()
        for path in paths:
            package = RepositoryPackageMetadata.from_egg(path)
            repository.add_package(package)

        for path in paths:
            action = InstallAction(path, self.top_prefix, repository,
                                   self.top_installed_repository,
                                   self.installed_repository,
                                   os.path.dirname(path))
            action.execute()
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:12,代码来源:test_enpkg.py

示例12: remote_enstaller_available

def remote_enstaller_available(versions):
    repository = Repository()
    for version in versions:
        package = dummy_repository_package_factory("enstaller", version, build=1)
        repository.add_package(package)

    def dec(f):
        @functools.wraps(f)
        def wrapper(*a, **kw):
            with mock.patch("enstaller.main.repository_factory",
                            return_value=repository):
                return f(*a, **kw)
        return wrapper
    return dec
开发者ID:enthought,项目名称:enstaller,代码行数:14,代码来源:common.py

示例13: test_fetch_invalid_md5

    def test_fetch_invalid_md5(self):
        # Given
        filename = "nose-1.3.0-1.egg"
        path = os.path.join(_EGGINST_COMMON_DATA, filename)

        repository = Repository()
        package = RepositoryPackageMetadata.from_egg(path)
        package.md5 = "a" * 32
        repository.add_package(package)

        downloader = _DownloadManager(mocked_session_factory(self.tempdir),
                                      repository)
        with self.assertRaises(InvalidChecksum):
            downloader.fetch(filename)
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:14,代码来源:test_fetch.py

示例14: _retry_common_setup

    def _retry_common_setup(self):
        store_location = "http://acme.com/"
        filename = "nose-1.3.0-1.egg"

        path = os.path.join(_EGGINST_COMMON_DATA, filename)

        repository = Repository()
        package = RepositoryPackageMetadata.from_egg(path,
                                                     store_location=store_location)
        repository.add_package(package)

        downloader = _DownloadManager(mocked_session_factory(self.tempdir),
                                      repository)
        return path, downloader, repository
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:14,代码来源:test_enpkg.py

示例15: _retry_common_setup

    def _retry_common_setup(self):
        store_url = "http://acme.com"
        repository_info = OldstyleRepositoryInfo(store_url)
        filename = "nose-1.3.0-1.egg"

        path = os.path.join(_EGGINST_COMMON_DATA, filename)

        repository = Repository()
        package = RemotePackageMetadata.from_egg(path, repository_info)
        repository.add_package(package)

        downloader = _DownloadManager(mocked_session_factory(self.tempdir),
                                      repository)
        return path, downloader, repository
开发者ID:JoelB,项目名称:enstaller,代码行数:14,代码来源:test_enpkg.py


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