utils.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:charms.openstack 作者: openstack 项目源码 文件源码
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 = fetch.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)


# TODO(AJK): Once this is in charms.reactive, drop it here and just reference
# the charms.reactive version.
# NOTE(AJK): that we are breaking the camalcase rule as this is acting as a
# context manager, which doesn't look like a 'class'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号