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