versions.py 文件源码

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

项目:katana-sdk-python2 作者: kusanagi 项目源码 文件源码
def compare(cls, ver1, ver2):
        # Versions are equal
        if ver1 == ver2:
            return 0

        for part1, part2 in izip_longest(ver1.split('.'), ver2.split('.')):
            # One of the parts is None
            if part1 is None or part2 is None:
                return cls.compare_none(part1, part2)

            for sub1, sub2 in izip_longest(part1.split('-'), part2.split('-')):
                # One of the sub parts is None
                if sub1 is None or sub2 is None:
                    # Sub parts are different, because one have a
                    # value and the other not.
                    return cls.compare_none(sub1, sub2)

                # Both sub parts have a value
                result = cls.compare_sub_parts(sub1, sub2)
                if result:
                    # Sub parts are not equal
                    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号