本文整理汇总了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"))
示例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)
示例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))
示例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"
示例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
示例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")])
示例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))
示例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")]))
示例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"])
示例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"))
示例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"])
示例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)
示例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"))
示例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")
示例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')")