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
评论列表
文章目录