本文整理汇总了Python中enstaller.versions.enpkg.EnpkgVersion.from_string方法的典型用法代码示例。如果您正苦于以下问题:Python EnpkgVersion.from_string方法的具体用法?Python EnpkgVersion.from_string怎么用?Python EnpkgVersion.from_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enstaller.versions.enpkg.EnpkgVersion
的用法示例。
在下文中一共展示了EnpkgVersion.from_string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_find_package
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
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
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
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
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
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
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
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: test_sorted_insertion
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
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")])
示例6: test_iter_packages
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
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")]))
示例7: test_find_packages_with_version
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
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"))
示例8: test_casing
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
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")
示例9: test_fix_php_version
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
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)
示例10: test_from_egg
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
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"))
示例11: test_from_pretty_string
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
def test_from_pretty_string(self):
# Given
pretty_string = "numpy 1.8.1-1; depends (MKL ~= 10.3)"
# When
metadata = PackageMetadata._from_pretty_string(pretty_string)
# Then
self.assertEqual(metadata.name, "numpy")
self.assertEqual(metadata.version, EnpkgVersion.from_string("1.8.1-1"))
self.assertEqual(metadata.dependencies, frozenset(("MKL 10.3",)))
示例12: test_repr
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
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')")
示例13: test_from_egg
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
def test_from_egg(self):
# Given
path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")
repository_info = FSRepositoryInfo(path_to_uri(os.path.dirname(path)))
# When
metadata = RemotePackageMetadata.from_egg(path, repository_info)
# Then
self.assertEqual(metadata.name, "nose")
self.assertEqual(metadata.version, EnpkgVersion.from_string("1.3.0-1"))
self.assertEqual(metadata.source_url, path_to_uri(path))
示例14: test_sorted_packages_invalid
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
def test_sorted_packages_invalid(self):
# Given
entries = [
dummy_installed_package_factory("numpy", "1.6.1", 1),
dummy_installed_package_factory("numpy", "1.8k", 2),
]
repository = Repository()
for entry in entries:
repository.add_package(entry)
# When
packages = repository.find_sorted_packages("numpy")
# Then
self.assertEqual(len(packages), 2)
assertCountEqual(self, [p.version for p in packages],
[EnpkgVersion.from_string(v)
for v in ("1.6.1-1", "1.8k-2")])
示例15: find_package
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_string [as 别名]
def find_package(self, name, version):
"""Search for the first match of a package with the given name and
version.
Parameters
----------
name : str
The package name to look for.
version : str
The full version string to look for (e.g. '1.8.0-1').
Returns
-------
package : RemotePackageMetadata
The corresponding metadata.
"""
version = EnpkgVersion.from_string(version)
candidates = self._name_to_packages.get(name, [])
for candidate in candidates:
if candidate.version == version:
return candidate
raise NoSuchPackage("Package '{0}-{1}' not found".format(name,
version))