當前位置: 首頁>>代碼示例>>Python>>正文


Python EnpkgVersion.from_upstream_and_build方法代碼示例

本文整理匯總了Python中enstaller.versions.enpkg.EnpkgVersion.from_upstream_and_build方法的典型用法代碼示例。如果您正苦於以下問題:Python EnpkgVersion.from_upstream_and_build方法的具體用法?Python EnpkgVersion.from_upstream_and_build怎麽用?Python EnpkgVersion.from_upstream_and_build使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在enstaller.versions.enpkg.EnpkgVersion的用法示例。


在下文中一共展示了EnpkgVersion.from_upstream_and_build方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: find_package_from_requirement

# 需要導入模塊: from enstaller.versions.enpkg import EnpkgVersion [as 別名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 別名]
    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,代碼行數:35,代碼來源:repository.py

示例2: _version_factory

# 需要導入模塊: from enstaller.versions.enpkg import EnpkgVersion [as 別名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 別名]
 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,代碼行數:9,代碼來源:repository.py

示例3: from_json_dict

# 需要導入模塊: from enstaller.versions.enpkg import EnpkgVersion [as 別名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 別名]
 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,代碼行數:10,代碼來源:repository.py

示例4: from_json_dict

# 需要導入模塊: from enstaller.versions.enpkg import EnpkgVersion [as 別名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 別名]
 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,代碼行數:11,代碼來源:package.py

示例5: test_no_egg_install

# 需要導入模塊: from enstaller.versions.enpkg import EnpkgVersion [as 別名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 別名]
    def test_no_egg_install(self):
        # Given
        prefix = self.prefix
        package_name = "enstaller"
        r_version = EnpkgVersion.from_upstream_and_build(enstaller.__version__,
                                                         1)

        # When
        version = _get_enstaller_comparable_version(prefix, package_name)

        # Then
        self.assertEqual(version, r_version)
開發者ID:cguwilliams,項目名稱:HmyApp,代碼行數:14,代碼來源:test_main.py

示例6: from_installed_meta_dict

# 需要導入模塊: from enstaller.versions.enpkg import EnpkgVersion [as 別名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 別名]
    def from_installed_meta_dict(cls, json_dict, prefix=None):
        prefix = prefix or sys.prefix

        key = json_dict["key"]
        name = json_dict["name"]
        upstream_version = json_dict["version"]
        build = json_dict.get("build", 1)
        version = EnpkgVersion.from_upstream_and_build(upstream_version, build)
        packages = json_dict.get("packages", [])
        python = json_dict.get("python", PY_VER)
        ctime = json_dict.get("ctime", time.ctime(0.0))
        return cls(key, name, version, packages, python, ctime, prefix)
開發者ID:JoelB,項目名稱:enstaller,代碼行數:14,代碼來源:package.py

示例7: from_installed_meta_dict

# 需要導入模塊: from enstaller.versions.enpkg import EnpkgVersion [as 別名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 別名]
 def from_installed_meta_dict(cls, json_dict):
     key = json_dict["key"]
     name = json_dict["name"]
     upstream_version = json_dict["version"]
     build = json_dict.get("build", 1)
     version = EnpkgVersion.from_upstream_and_build(upstream_version, build)
     packages = json_dict.get("packages", [])
     python = json_dict.get("python", PY_VER)
     ctime = json_dict.get("ctime", time.ctime(0.0))
     store_location = json_dict.get("store_location", "")
     return cls(key, name, version, packages, python, ctime,
                store_location)
開發者ID:cguwilliams,項目名稱:HmyApp,代碼行數:14,代碼來源:repository.py

示例8: dummy_repository_package_factory

# 需要導入模塊: from enstaller.versions.enpkg import EnpkgVersion [as 別名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 別名]
def dummy_repository_package_factory(name, version, build, key=None,
                                     py_ver=PY_VER, store_location="",
                                     dependencies=None, mtime=0.0):
    dependencies = dependencies or []
    key = key if key else "{0}-{1}-{2}.egg".format(name, version, build)
    fake_size = FAKE_SIZE
    fake_md5 = FAKE_MD5
    fake_mtime = mtime
    version = EnpkgVersion.from_upstream_and_build(version, build)
    return RepositoryPackageMetadata(key, name.lower(), version,
                                     dependencies, py_ver, fake_size,
                                     fake_md5, fake_mtime, "commercial",
                                     True, store_location)
開發者ID:cguwilliams,項目名稱:HmyApp,代碼行數:15,代碼來源:common.py

示例9: _get_enstaller_comparable_version

# 需要導入模塊: from enstaller.versions.enpkg import EnpkgVersion [as 別名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 別名]
def _get_enstaller_comparable_version(prefix, package_name):
    runtime_version = \
        EnpkgVersion.from_upstream_and_build(enstaller.__version__, 1)

    egg_info_dir = os.path.join(prefix, EGG_INFO, package_name)
    try:
        # Installed as an egg in sys.prefix
        enstaller_package = \
            InstalledPackageMetadata.from_meta_dir(egg_info_dir)
        if str(enstaller_package.version.upstream) != enstaller.__version__:
            # It is both installed as an egg and from sources/develop mode, the
            # latter takes precedence
            current_comparable_version = runtime_version
        else:
            current_comparable_version = enstaller_package.version
    except EnstallerException:
        # Installed from sources, no build number
        current_comparable_version = runtime_version

    return current_comparable_version
開發者ID:JoelB,項目名稱:enstaller,代碼行數:22,代碼來源:main.py

示例10: test_egg_install_different_versions

# 需要導入模塊: from enstaller.versions.enpkg import EnpkgVersion [as 別名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 別名]
    def test_egg_install_different_versions(self):
        # ensure that we use the build number from installed metadata if
        # version and enstaller.__version__ are the same

        # Given
        prefix = self.prefix
        package_name = "enstaller"
        version_string = "2.7.6"
        build = 4

        json_dict = {
            "arch": None,
            "build": build,
            "ctime": "Mon Oct 20 15:49:19 2014",
            "hook": False,
            "key": "enstaller-{0}-1.egg".format(version_string),
            "name": "enstaller",
            "osdist": None,
            "packages": [],
            "platform": None,
            "python": "2.7",
            "type": "egg",
            "version": version_string,
        }
        r_version = EnpkgVersion.from_upstream_and_build("4.8.0", 1)

        meta_info_path = meta_info_from_prefix(prefix, package_name)
        ensure_dir(meta_info_path)
        with open(meta_info_path, "wt") as fp:
            json.dump(json_dict, fp)

        # When
        with mock.patch("enstaller.__version__", "4.8.0"):
            version = _get_enstaller_comparable_version(prefix, package_name)

        # Then
        self.assertEqual(version, r_version)
開發者ID:cguwilliams,項目名稱:HmyApp,代碼行數:39,代碼來源:test_main.py

示例11: _ensure_valid_version

# 需要導入模塊: from enstaller.versions.enpkg import EnpkgVersion [as 別名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 別名]
def _ensure_valid_version(version, build_number):
    full_version = EnpkgVersion.from_upstream_and_build(version,
                                                        build_number)
    if full_version.upstream.is_worked_around:
        raise InvalidVersion(version)
開發者ID:JoelB,項目名稱:enstaller,代碼行數:7,代碼來源:repack.py

示例12: dummy_installed_package_factory

# 需要導入模塊: from enstaller.versions.enpkg import EnpkgVersion [as 別名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 別名]
def dummy_installed_package_factory(name, version, build, key=None,
                                    py_ver=PY_VER, store_location=""):
    key = key if key else "{0}-{1}-{2}.egg".format(name, version, build)
    version = EnpkgVersion.from_upstream_and_build(version, build)
    return InstalledPackageMetadata(key, name.lower(), version, [], py_ver,
                                    "", store_location)
開發者ID:cguwilliams,項目名稱:HmyApp,代碼行數:8,代碼來源:common.py


注:本文中的enstaller.versions.enpkg.EnpkgVersion.from_upstream_and_build方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。