本文整理汇总了Python中apt.apt_pkg.upstream_version方法的典型用法代码示例。如果您正苦于以下问题:Python apt_pkg.upstream_version方法的具体用法?Python apt_pkg.upstream_version怎么用?Python apt_pkg.upstream_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apt.apt_pkg
的用法示例。
在下文中一共展示了apt_pkg.upstream_version方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_upstream_version
# 需要导入模块: from apt import apt_pkg [as 别名]
# 或者: from apt.apt_pkg import upstream_version [as 别名]
def get_upstream_version(package):
"""Determine upstream version based on installed package
@returns None (if not installed) or the upstream version
"""
import apt_pkg
cache = apt_cache()
try:
pkg = cache[package]
except Exception:
# the package is unknown to the current apt cache.
return None
if not pkg.current_ver:
# package is known, but no version is currently installed.
return None
return apt_pkg.upstream_version(pkg.current_ver.ver_str)
示例2: get_upstream_version
# 需要导入模块: from apt import apt_pkg [as 别名]
# 或者: from apt.apt_pkg import upstream_version [as 别名]
def get_upstream_version(package):
"""Determine upstream version based on installed package
@returns None (if not installed) or the upstream version
"""
import apt_pkg
cache = apt_cache()
try:
pkg = cache[package]
except:
# the package is unknown to the current apt cache.
return None
if not pkg.current_ver:
# package is known, but no version is currently installed.
return None
return apt_pkg.upstream_version(pkg.current_ver.ver_str)
示例3: get_pkg_version
# 需要导入模块: from apt import apt_pkg [as 别名]
# 或者: from apt.apt_pkg import upstream_version [as 别名]
def get_pkg_version(name):
from apt import apt_pkg
pkg = apt_cache()[name]
version = apt_pkg.upstream_version(pkg.current_ver.ver_str)
return version