本文整理汇总了Python中distutils.version.LooseVersion.replace方法的典型用法代码示例。如果您正苦于以下问题:Python LooseVersion.replace方法的具体用法?Python LooseVersion.replace怎么用?Python LooseVersion.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distutils.version.LooseVersion
的用法示例。
在下文中一共展示了LooseVersion.replace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compare
# 需要导入模块: from distutils.version import LooseVersion [as 别名]
# 或者: from distutils.version.LooseVersion import replace [as 别名]
def compare(current, operator, reference):
# if len(sys.argv) < 4:
# script_name = sys.argv[0]
# print 'Usage:'
# print '{} current-version operator reference-version'.format(script_name)
# print '{} v0.10.29 \'>=\' v0.10.20'.format(script_name)
# print '{} v0.10.29 \'<\' v0.12.00'.format(script_name)
# sys.exit(1)
current = LooseVersion(current.replace('v', ''))
reference = LooseVersion(reference.replace('v', ''))
if operator == '>=':
if not current >= reference:
sys.exit(1)
elif operator == '>':
if not current > reference:
sys.exit(1)
elif operator == '<=':
if not current <= reference:
sys.exit(1)
elif operator == '<':
if not current < reference:
sys.exit(1)
else:
print 'Unknown operator {}'.format(operator)
sys.exit(1)
示例2: am_i_updated
# 需要导入模块: from distutils.version import LooseVersion [as 别名]
# 或者: from distutils.version.LooseVersion import replace [as 别名]
def am_i_updated(version):
version = LooseVersion(version.replace('v', ''))
last_version = get_last()
return last_version <= version