本文整理汇总了Python中distutils.version.LooseVersion.version方法的典型用法代码示例。如果您正苦于以下问题:Python LooseVersion.version方法的具体用法?Python LooseVersion.version怎么用?Python LooseVersion.version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distutils.version.LooseVersion
的用法示例。
在下文中一共展示了LooseVersion.version方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deprecated
# 需要导入模块: from distutils.version import LooseVersion [as 别名]
# 或者: from distutils.version.LooseVersion import version [as 别名]
def deprecated(self, msg, cur_ver, max_ver, depth=2, exception=None, *args, **kwargs):
"""
Log deprecation message, throw error if current version is passed given threshold.
Checks only major/minor version numbers (MAJ.MIN.x) by default, controlled by 'depth' argument.
"""
loose_cv = LooseVersion(cur_ver)
loose_mv = LooseVersion(max_ver)
loose_cv.version = loose_cv.version[:depth]
loose_mv.version = loose_mv.version[:depth]
if loose_cv >= loose_mv:
self.raiseException("DEPRECATED (since v%s) functionality used: %s" % (max_ver, msg), exception=exception)
else:
deprecation_msg = "Deprecated functionality, will no longer work in v%s: %s" % (max_ver, msg)
self.warning(deprecation_msg)