本文整理匯總了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