本文整理汇总了Python中distutils.version.LooseVersion.insert方法的典型用法代码示例。如果您正苦于以下问题:Python LooseVersion.insert方法的具体用法?Python LooseVersion.insert怎么用?Python LooseVersion.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distutils.version.LooseVersion
的用法示例。
在下文中一共展示了LooseVersion.insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: version_tuple
# 需要导入模块: from distutils.version import LooseVersion [as 别名]
# 或者: from distutils.version.LooseVersion import insert [as 别名]
def version_tuple(self):
"""Return a tuple in the format of django.VERSION."""
version = self.version.replace('-', '').replace('_', '')
version = LooseVersion(version).version
if len(version) == 2:
version.append(0)
if not isinstance(version[2], int):
version.insert(2, 0)
if len(version) == 3:
version.append('final')
if version[3] not in ('alpha', 'beta', 'rc', 'final'):
version[3] = {'a': 'alpha', 'b': 'beta', 'c': 'rc'}[version[3]]
if len(version) == 4:
version.append(0)
return tuple(version)
示例2: version_tuple
# 需要导入模块: from distutils.version import LooseVersion [as 别名]
# 或者: from distutils.version.LooseVersion import insert [as 别名]
def version_tuple(self):
"""Return a tuple in the format of django.VERSION."""
version = self.version.replace("-", "").replace("_", "")
version = LooseVersion(version).version
if len(version) == 2:
version.append(0)
if not isinstance(version[2], int):
version.insert(2, 0)
if len(version) == 3:
version.append("final")
if version[3] not in ("alpha", "beta", "rc", "final"):
version[3] = {"a": "alpha", "b": "beta", "c": "rc"}[version[3]]
if len(version) == 4:
version.append(0)
return tuple(version)