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


Python enpkg.EnpkgVersion类代码示例

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


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

示例1: test_find_package

    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"))
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:34,代码来源:test_repository.py

示例2: test_normalize_php_version

    def test_normalize_php_version(self):
        # Given
        version = EnpkgVersion.from_string("10.3-1")
        r_normalized = "10.3.0.0-patch1"

        # When
        normalized = _normalize_php_version(version)

        # Then
        self.assertEqual(normalized, r_normalized)

        # Given
        version = EnpkgVersion.from_string("0.14.1rc1-1")
        r_normalized = "0.14.1.0-patch1"

        # When
        normalized = _normalize_php_version(version)

        # Then
        self.assertEqual(normalized, r_normalized)

        # Given
        version = EnpkgVersion.from_string("2011n-1")
        r_normalized = "2011.14.0.0-patch1"

        # When
        normalized = _normalize_php_version(version)

        # Then
        self.assertEqual(normalized, r_normalized)
开发者ID:JoelB,项目名称:enstaller,代码行数:30,代码来源:test__composer_utils.py

示例3: test_has_package

    def test_has_package(self):
        # Given
        version = EnpkgVersion.from_string("1.3.0-1")
        available_package = PackageMetadata("nose-1.3.0-1.egg", "nose",
                                            version, [], "2.7")

        version = EnpkgVersion.from_string("1.4.0-1")
        unavailable_package = PackageMetadata("nose-1.4.0-1.egg", "nose",
                                              version, [], "2.7")

        # When/Then
        self.assertTrue(self.repository.has_package(available_package))
        self.assertFalse(self.repository.has_package(unavailable_package))
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:13,代码来源:test_repository.py

示例4: test_normalize_php_version_constraint

    def test_normalize_php_version_constraint(self):
        # Given
        version = EnpkgVersion.from_string("10.3-1")
        r_normalized = "10.3.0.0-patch1"

        # When
        normalized = _normalize_php_version(version)

        # Then
        self.assertEqual(normalized, r_normalized)

        # Given
        version = EnpkgVersion.from_string("10.3")
        r_normalized = "10.3.0.0"
开发者ID:JoelB,项目名称:enstaller,代码行数:14,代码来源:test__composer_utils.py

示例5: _version_factory

 def _version_factory(upstream, build):
     if (upstream, build) in cache:
         version = cache[(upstream, build)]
     else:
         version = EnpkgVersion.from_upstream_and_build(upstream, build)
         cache[(upstream, build)] = version
     return version
开发者ID:JoelB,项目名称:enstaller,代码行数:7,代码来源:repository.py

示例6: test_sorted_insertion

    def test_sorted_insertion(self):
        # Given
        eggs = ["nose-1.3.0-1.egg", "nose-1.2.1-1.egg"]
        repository = Repository()

        # When
        for egg in eggs:
            path = os.path.join(_EGGINST_COMMON_DATA, egg)
            package = RemotePackageMetadata.from_egg(path)
            repository.add_package(package)

        # Then
        self.assertEqual([m.version
                          for m in repository._name_to_packages["nose"]],
                         [EnpkgVersion.from_string("1.2.1-1"),
                          EnpkgVersion.from_string("1.3.0-1")])
开发者ID:pombreda,项目名称:enstaller,代码行数:16,代码来源:test_repository.py

示例7: find_package_from_requirement

    def find_package_from_requirement(self, requirement):
        """Search for latest package matching the given requirement.

        Parameters
        ----------
        requirement : Requirement
            The requirement to match for.

        Returns
        -------
        package : RemotePackageMetadata
            The corresponding metadata.
        """
        name = requirement.name
        version = requirement.version
        build = requirement.build
        if version is None:
            return self.find_latest_package(name)
        else:
            if build is None:
                upstream = PEP386WorkaroundVersion.from_string(version)
                candidates = [p for p in self.find_packages(name)
                              if p.version.upstream == upstream]
                candidates.sort(key=operator.attrgetter("version"))

                if len(candidates) == 0:
                    msg = "No package found for requirement {0!r}"
                    raise NoSuchPackage(msg.format(requirement))

                return candidates[-1]
            else:
                version = EnpkgVersion.from_upstream_and_build(version, build)
                return self.find_package(name, str(version))
开发者ID:JoelB,项目名称:enstaller,代码行数:33,代码来源:repository.py

示例8: test_iter_packages

    def test_iter_packages(self):
        # Given
        eggs = ["nose-1.3.0-1.egg", "nose-1.2.1-1.egg"]
        repository = Repository()
        for egg in eggs:
            path = os.path.join(_EGGINST_COMMON_DATA, egg)
            package = RepositoryPackageMetadata.from_egg(path)
            repository.add_package(package)

        # When
        metadata = list(repository.iter_packages())

        # Then
        self.assertEqual(len(metadata), 2)
        self.assertEqual(set(m.version for m in metadata),
                         set([EnpkgVersion.from_string("1.2.1-1"),
                              EnpkgVersion.from_string("1.3.0-1")]))
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:17,代码来源:test_repository.py

示例9: from_json_dict

 def from_json_dict(cls, key, json_dict):
     version = EnpkgVersion.from_upstream_and_build(json_dict["version"],
                                                    json_dict["build"])
     return cls(key, json_dict["name"], version, json_dict["packages"],
                json_dict["python"], json_dict["size"], json_dict["md5"],
                json_dict.get("mtime", 0.0), json_dict.get("product", None),
                json_dict.get("available", True),
                json_dict["store_location"])
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:8,代码来源:repository.py

示例10: test_find_packages_with_version

    def test_find_packages_with_version(self):
        # Given/When
        metadata = list(self.repository.find_packages("nose", "1.3.0-1"))

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

        self.assertEqual(metadata[0].version,
                         EnpkgVersion.from_string("1.3.0-1"))
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:9,代码来源:test_repository.py

示例11: from_json_dict

 def from_json_dict(cls, key, json_dict):
     """
     Create an instance from a key (the egg filename) and metadata passed as
     a dictionary
     """
     version = EnpkgVersion.from_upstream_and_build(json_dict["version"],
                                                    json_dict["build"])
     return cls(key, json_dict["name"], version, json_dict["packages"],
                json_dict["python"])
开发者ID:JoelB,项目名称:enstaller,代码行数:9,代码来源:package.py

示例12: test_fix_php_version

    def test_fix_php_version(self):
        # Given
        version = EnpkgVersion.from_string("1.0-1")
        r_fixed_version = "1.0-1"

        # When
        fixed = _fix_php_version(version)

        # Then
        self.assertEqual(fixed, r_fixed_version)
开发者ID:JoelB,项目名称:enstaller,代码行数:10,代码来源:test__composer_utils.py

示例13: test_from_egg

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

        # When
        metadata = PackageMetadata.from_egg(path)

        # Then
        self.assertEqual(metadata.name, "nose")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.3.0-1"))
开发者ID:cguwilliams,项目名称:HmyApp,代码行数:10,代码来源:test_repository.py

示例14: test_casing

    def test_casing(self):
        # Given
        version = EnpkgVersion.from_string("10.3-1")

        # When
        metadata = PackageMetadata("MKL-10.3-1.egg", "mkl", version, [],
                                   "2.7")
        # Then
        self.assertEqual(metadata.name, "mkl")
        self.assertEqual(metadata._egg_name, "MKL")
开发者ID:JoelB,项目名称:enstaller,代码行数:10,代码来源:test_package.py

示例15: test_repr

    def test_repr(self):
        # Given
        version = EnpkgVersion.from_string("1.3.0-1")
        metadata = PackageMetadata("nose-1.3.0-1.egg", "nose", version, [],
                                   "2.7")

        # When
        r = repr(metadata)

        # Then
        self.assertEqual(r, "PackageMetadata('nose-1.3.0-1', key='nose-1.3.0-1.egg')")
开发者ID:JoelB,项目名称:enstaller,代码行数:11,代码来源:test_package.py


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