hashin.py 文件源码

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

项目:hashin 作者: peterbe 项目源码 文件源码
def get_latest_version(data):
    """
    Return the version string of what we think is the latest version.
    In the data blob from PyPI there is the info->version key which
    is just the latest in time. Ideally we want the latest non-pre-release.
    """
    if not data.get('releases'):
        # If there were no releases, fall back to the old way of doing
        # things with the info->version key.
        # This feels kinda strange but it has worked for years
        return data['info']['version']
    all_versions = []
    for version in data['releases']:
        v = parse(version)
        if not v.is_prerelease:
            all_versions.append((v, version))
    all_versions.sort(reverse=True)
    # return the highest non-pre-release version
    return str(all_versions[0][1])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号