當前位置: 首頁>>代碼示例>>Python>>正文


Python LooseVersion.__init__方法代碼示例

本文整理匯總了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]
開發者ID:MekliCZ,項目名稱:positron,代碼行數:10,代碼來源:util.py

示例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)
開發者ID:harshach,項目名稱:kafka,代碼行數:15,代碼來源:version.py

示例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
開發者ID:darvid,項目名稱:borealis,代碼行數:15,代碼來源:objects.py

示例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)
開發者ID:lovejavaee,項目名稱:kafka_enhancement,代碼行數:18,代碼來源:version.py

示例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
開發者ID:coala-analyzer,項目名稱:coala-quickstart,代碼行數:42,代碼來源:setup.py

示例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)
開發者ID:H1d3r,項目名稱:cobra,代碼行數:6,代碼來源:dependencies.py

示例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))
開發者ID:jgiannuzzi,項目名稱:pypi-server,代碼行數:5,代碼來源:hash_version.py


注:本文中的distutils.version.LooseVersion.__init__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。