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


Python Repository.find_package方法代码示例

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


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

示例1: TestRepository

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import find_package [as 别名]
class TestRepository(unittest.TestCase):
    def setUp(self):
        eggs = [
            "dummy-1.0.1-1.egg",
            "dummy_with_appinst-1.0.0-1.egg",
            "dummy_with_entry_points-1.0.0-1.egg",
            "dummy_with_proxy-1.3.40-3.egg",
            "dummy_with_proxy_scripts-1.0.0-1.egg",
            "dummy_with_proxy_softlink-1.0.0-1.egg",
            "nose-1.2.1-1.egg",
            "nose-1.3.0-1.egg",
            "nose-1.3.0-2.egg",
        ]
        self.repository = Repository()
        for egg in eggs:
            path = os.path.join(_EGGINST_COMMON_DATA, egg)
            package = RemotePackageMetadata.from_egg(path)
            self.repository.add_package(package)

    @mock_brood_repository_indices({}, ["enthought/free"])
    def test_from_repository_infos_empty(self):
        # Given
        repository_info = BroodRepositoryInfo("https://api.enthought.com",
                                              "enthought/free")
        config = Configuration(use_webservice=False,
                               auth=("nono", "password"))
        config._store_kind = STORE_KIND_BROOD

        session = Session.authenticated_from_configuration(config)

        # When
        repository = Repository.from_repository_infos(
            session, (repository_info,)
        )

        # Then
        self.assertEqual(len(repository), 0)

    @mock_brood_repository_indices(
        SIMPLE_INDEX, ["enthought/free", "enthought/commercial"]
    )
    def test_from_repository_infos_nonempty(self):
        # Given
        repository_infos = (
            BroodRepositoryInfo("https://api.enthought.com", "enthought/free"),
            BroodRepositoryInfo(
                "https://api.enthought.com", "enthought/commercial"
            ),
        )
        config = Configuration(use_webservice=False,
                               auth=("nono", "password"))
        config._store_kind = STORE_KIND_BROOD

        session = Session.authenticated_from_configuration(config)

        # When
        repository = Repository.from_repository_infos(session, repository_infos)

        # Then
        self.assertEqual(len(repository), 2)
        self.assertEqual(len(repository.find_packages("nose")), 2)

    def test_ctor(self):
        # When
        repository = Repository()

        # Then
        self.assertEqual(len(repository), 0)

        # Given
        eggs = [
            "dummy-1.0.1-1.egg",
            "dummy_with_appinst-1.0.0-1.egg",
            "dummy_with_entry_points-1.0.0-1.egg",
            "dummy_with_proxy-1.3.40-3.egg",
            "dummy_with_proxy_scripts-1.0.0-1.egg",
            "dummy_with_proxy_softlink-1.0.0-1.egg",
            "nose-1.2.1-1.egg",
            "nose-1.3.0-1.egg",
            "nose-1.3.0-2.egg",
        ]
        paths = (os.path.join(_EGGINST_COMMON_DATA, egg) for egg in eggs)
        packages = [RemotePackageMetadata.from_egg(path) for path in paths]

        # When
        repository = Repository(packages)

        # Then
        self.assertEqual(len(repository), len(eggs))

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

        # When
        metadata = self.repository.find_package("nose", "1.3.0-1")

        # Then
        self.assertEqual(metadata.key, "nose-1.3.0-1.egg")

#.........这里部分代码省略.........
开发者ID:enthought,项目名称:enstaller,代码行数:103,代码来源:test_repository.py

示例2: TestRepository

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import find_package [as 别名]
class TestRepository(unittest.TestCase):
    def setUp(self):
        eggs = [
            "dummy-1.0.1-1.egg",
            "dummy_with_appinst-1.0.0-1.egg",
            "dummy_with_entry_points-1.0.0-1.egg",
            "dummy_with_proxy-1.3.40-3.egg",
            "dummy_with_proxy_scripts-1.0.0-1.egg",
            "dummy_with_proxy_softlink-1.0.0-1.egg",
            "nose-1.2.1-1.egg",
            "nose-1.3.0-1.egg",
            "nose-1.3.0-2.egg",
        ]
        self.repository = Repository()
        for egg in eggs:
            path = os.path.join(_EGGINST_COMMON_DATA, egg)
            package = RepositoryPackageMetadata.from_egg(path)
            self.repository.add_package(package)

    def test_ctor(self):
        # When
        repository = Repository()

        # Then
        self.assertEqual(len(repository), 0)

        # Given
        eggs = [
            "dummy-1.0.1-1.egg",
            "dummy_with_appinst-1.0.0-1.egg",
            "dummy_with_entry_points-1.0.0-1.egg",
            "dummy_with_proxy-1.3.40-3.egg",
            "dummy_with_proxy_scripts-1.0.0-1.egg",
            "dummy_with_proxy_softlink-1.0.0-1.egg",
            "nose-1.2.1-1.egg",
            "nose-1.3.0-1.egg",
            "nose-1.3.0-2.egg",
        ]
        paths = (os.path.join(_EGGINST_COMMON_DATA, egg) for egg in eggs)
        packages = [RepositoryPackageMetadata.from_egg(path) for path in paths]

        # When
        repository = Repository(packages)

        # Then
        self.assertEqual(len(repository), len(eggs))

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

        # When
        metadata = self.repository.find_package("nose", "1.3.0-1")

        # Then
        self.assertEqual(metadata.key, "nose-1.3.0-1.egg")

        self.assertEqual(metadata.name, "nose")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.3.0-1"))

        self.assertEqual(metadata.packages, [])
        self.assertEqual(metadata.python, "2.7")

        self.assertEqual(metadata.available, True)
        self.assertEqual(metadata.store_location,
                         "{0}/".format(path_to_uri(_EGGINST_COMMON_DATA)))

        self.assertEqual(metadata.size, os.path.getsize(path))
        self.assertEqual(metadata.md5, compute_md5(path))

        # Given
        path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-2.egg")

        # When
        metadata = self.repository.find_package("nose", "1.3.0-2")

        # Then
        self.assertEqual(metadata.key, "nose-1.3.0-2.egg")

        self.assertEqual(metadata.name, "nose")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.3.0-2"))

    def test_find_unavailable_package(self):
        # Given/When/Then
        with self.assertRaises(NoSuchPackage):
            self.repository.find_package("nono", "1.4.0-1")

    def test_find_packages(self):
        V = EnpkgVersion.from_string
        # Given/When
        metadata = list(self.repository.find_packages("nose"))
        metadata = sorted(metadata, key=operator.attrgetter("version"))

        # Then
        self.assertEqual(len(metadata), 3)

        self.assertEqual(metadata[0].version, V("1.2.1-1"))
        self.assertEqual(metadata[1].version, V("1.3.0-1"))
        self.assertEqual(metadata[2].version, V("1.3.0-2"))

#.........这里部分代码省略.........
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:103,代码来源:test_repository.py

示例3: TestRepository

# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import find_package [as 别名]
class TestRepository(unittest.TestCase):
    def setUp(self):
        eggs = [
            "dummy-1.0.1-1.egg",
            "dummy_with_appinst-1.0.0-1.egg",
            "dummy_with_entry_points-1.0.0-1.egg",
            "dummy_with_proxy-1.3.40-3.egg",
            "dummy_with_proxy_scripts-1.0.0-1.egg",
            "dummy_with_proxy_softlink-1.0.0-1.egg",
            "nose-1.2.1-1.egg",
            "nose-1.3.0-1.egg",
            "nose-1.3.0-2.egg",
        ]
        self.repository = Repository()
        for egg in eggs:
            path = os.path.join(_EGGINST_COMMON_DATA, egg)
            package = RemotePackageMetadata.from_egg(path)
            self.repository.add_package(package)

    @mock_brood_repository_indices({}, ["enthought/free"])
    def test_from_repository_info_empty(self):
        # Given
        repository_info = BroodRepositoryInfo("https://api.enthought.com",
                                              "enthought/free")
        config = Configuration(use_webservice=False,
                               auth=("nono", "password"))
        config._store_kind = STORE_KIND_BROOD

        session = Session.authenticated_from_configuration(config)

        # When
        repository = Repository.from_repository_info(session, repository_info)

        # Then
        self.assertEqual(len(repository), 0)

    @mock_brood_repository_indices(SIMPLE_INDEX, ["enthought/free"])
    def test_from_repository_info_nonempty(self):
        # Given
        repository_info = BroodRepositoryInfo("https://api.enthought.com",
                                              "enthought/free")
        config = Configuration(use_webservice=False,
                               auth=("nono", "password"))
        config._store_kind = STORE_KIND_BROOD

        session = Session.authenticated_from_configuration(config)

        # When
        repository = Repository.from_repository_info(session, repository_info)

        # Then
        self.assertEqual(len(repository), 1)
        self.assertEqual(len(repository.find_packages("nose")), 1)

    def test_ctor(self):
        # When
        repository = Repository()

        # Then
        self.assertEqual(len(repository), 0)

        # Given
        eggs = [
            "dummy-1.0.1-1.egg",
            "dummy_with_appinst-1.0.0-1.egg",
            "dummy_with_entry_points-1.0.0-1.egg",
            "dummy_with_proxy-1.3.40-3.egg",
            "dummy_with_proxy_scripts-1.0.0-1.egg",
            "dummy_with_proxy_softlink-1.0.0-1.egg",
            "nose-1.2.1-1.egg",
            "nose-1.3.0-1.egg",
            "nose-1.3.0-2.egg",
        ]
        paths = (os.path.join(_EGGINST_COMMON_DATA, egg) for egg in eggs)
        packages = [RemotePackageMetadata.from_egg(path) for path in paths]

        # When
        repository = Repository(packages)

        # Then
        self.assertEqual(len(repository), len(eggs))

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

        # When
        metadata = self.repository.find_package("nose", "1.3.0-1")

        # Then
        self.assertEqual(metadata.key, "nose-1.3.0-1.egg")

        self.assertEqual(metadata.name, "nose")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.3.0-1"))

        self.assertEqual(metadata.dependencies, frozenset())
        self.assertEqual(metadata.python, "2.7")

        self.assertEqual(metadata.available, True)
        self.assertEqual(metadata.repository_info,
#.........这里部分代码省略.........
开发者ID:pombreda,项目名称:enstaller,代码行数:103,代码来源:test_repository.py


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