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


Python Repository.add_package方法代码示例

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


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

示例1: repository_factory

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
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,代码行数:9,代码来源:yaml_utils.py

示例2: repository_factory_from_egg

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
 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,代码行数:9,代码来源:test_repository.py

示例3: test_simple_scenario

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
    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,代码行数:30,代码来源:test_enpkg.py

示例4: repository_factory

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
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,代码行数:30,代码来源:utils.py

示例5: test_simple_installed

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
    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,代码行数:29,代码来源:test_core.py

示例6: test_find_packages_sorting

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
    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,代码行数:28,代码来源:test_repository.py

示例7: _downloader_factory

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
    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,代码行数:10,代码来源:test_enpkg.py

示例8: _create_store_and_repository

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
    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,代码行数:10,代码来源:test_fetch.py

示例9: _create_repositories

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
    def _create_repositories(self, entries, installed_entries):
        repository = Repository()
        for entry in entries:
            repository.add_package(entry)

        installed_repository = Repository()
        for entry in installed_entries:
            installed_repository.add_package(entry)

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

示例10: _install_eggs

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
    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,代码行数:14,代码来源:test_enpkg.py

示例11: remote_enstaller_available

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
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,代码行数:16,代码来源:common.py

示例12: create_repositories

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def create_repositories(remote_entries=None, installed_entries=None):
    if remote_entries is None:
        remote_entries = []
    if installed_entries is None:
        installed_entries = []

    remote_repository = Repository()
    for remote_entry in remote_entries:
        remote_repository.add_package(remote_entry)
    installed_repository = Repository()
    for installed_entry in installed_entries:
        installed_repository.add_package(installed_entry)

    return remote_repository, installed_repository
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:16,代码来源:common.py

示例13: test_fetch_invalid_md5

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
    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,代码行数:16,代码来源:test_fetch.py

示例14: _retry_common_setup

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
    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,代码行数:16,代码来源:test_enpkg.py

示例15: _retry_common_setup

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
    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,代码行数:16,代码来源:test_enpkg.py


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