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