本文整理汇总了Python中distutils.version.LooseVersion.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python LooseVersion.__init__方法的具体用法?Python LooseVersion.__init__怎么用?Python LooseVersion.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distutils.version.LooseVersion
的用法示例。
在下文中一共展示了LooseVersion.__init__方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from distutils.version import LooseVersion [as 别名]
# 或者: from distutils.version.LooseVersion import __init__ [as 别名]
def __init__(self, version):
# Can't use super, LooseVersion's base class is not a new-style class.
LooseVersion.__init__(self, version)
# Take the first three integer components, stopping at the first
# non-integer and padding the rest with zeroes.
(self.major, self.minor, self.patch) = list(itertools.chain(
itertools.takewhile(lambda x:isinstance(x, int), self.version),
(0, 0, 0)))[:3]
示例2: __init__
# 需要导入模块: from distutils.version import LooseVersion [as 别名]
# 或者: from distutils.version.LooseVersion import __init__ [as 别名]
def __init__(self, version_string):
self.is_dev = (version_string.lower() == "dev")
if self.is_dev:
version_string = kafkatest_version()
# Drop dev suffix if present
dev_suffix_index = version_string.find(".dev")
if dev_suffix_index >= 0:
version_string = version_string[:dev_suffix_index]
# Don't use the form super.(...).__init__(...) because
# LooseVersion is an "old style" python class
LooseVersion.__init__(self, version_string)
示例3: __init__
# 需要导入模块: from distutils.version import LooseVersion [as 别名]
# 或者: from distutils.version.LooseVersion import __init__ [as 别名]
def __init__(self, string):
match = re.match(self.version_re, string)
if not match:
raise Exception("invalid version string format")
LooseVersion.__init__(self, string)
self.epoch = match.group(1) or 0
self.version = match.group(2)
# someone please inform foobnix's maintainer that the letter "o" should
# never, ever, ever, *ever* be used to represent zero.
if match.group(3) == "o":
self.release = 0
else:
self.release = int(match.group(3)) if match.group(3) else 1
示例4: __init__
# 需要导入模块: from distutils.version import LooseVersion [as 别名]
# 或者: from distutils.version.LooseVersion import __init__ [as 别名]
def __init__(self, version_string):
self.is_trunk = (version_string.lower() == "trunk")
if self.is_trunk:
# Since "trunk" may actually be a branch that is not trunk,
# use kafkatest_version() for comparison purposes,
# and track whether we're in "trunk" with a flag
version_string = kafkatest_version()
# Drop dev suffix if present
dev_suffix_index = version_string.find(".dev")
if dev_suffix_index >= 0:
version_string = version_string[:dev_suffix_index]
# Don't use the form super.(...).__init__(...) because
# LooseVersion is an "old style" python class
LooseVersion.__init__(self, version_string)
示例5: __init__
# 需要导入模块: from distutils.version import LooseVersion [as 别名]
# 或者: from distutils.version.LooseVersion import __init__ [as 别名]
def __init__(self, vstring=None, v_prefix=None):
self._v_prefix = v_prefix
if isinstance(vstring, (list, tuple)):
type_ = type(vstring)
vstring = '.'.join(str(i) for i in vstring)
else:
type_ = list
vstring = vstring.strip()
if vstring.startswith('v'):
vstring = vstring[1:]
if vstring.startswith('!'):
raise ValueError('Invalid use of epoch')
if v_prefix is not False:
self._v_prefix = True
# Can not use super(..) on Python 2.7
LooseVersion.__init__(self, vstring)
if self._v_prefix:
self.vstring = 'v' + self.vstring
if len(self.version) > 1 and self.version[1] == '!':
self._epoch = self.version[0]
if not isinstance(self._epoch, int) or len(self.version) < 3:
raise ValueError('Invalid use of epoch')
# Normalise to lower case
self.version = [
x if isinstance(x, int) else x.lower() for x in self.version
if x not in ('-', '_')]
if self.version[-1] != '*' and not isinstance(self.version[-1], int):
self.version += (0, )
if type_ is tuple:
self.version = tuple(self.version)
self._final = None
self._previous = None
示例6: __init__
# 需要导入模块: from distutils.version import LooseVersion [as 别名]
# 或者: from distutils.version.LooseVersion import __init__ [as 别名]
def __init__(self, vstring=None):
self.vstring = vstring
self.version = []
LooseVersion.__init__(self, vstring=vstring)
示例7: __init__
# 需要导入模块: from distutils.version import LooseVersion [as 别名]
# 或者: from distutils.version.LooseVersion import __init__ [as 别名]
def __init__(self, vstring=None):
LooseVersion.__init__(self, vstring=vstring)
self.version = tuple(map(str, self.version))