コード例 #1
0
ファイル: util.py プロジェクト: Floflis/gecko-b2g
 def _cmp(self, other):
     # LooseVersion checks isinstance(StringType), so work around it.
     if six.PY2 and isinstance(other, six.text_type):
         other = other.encode("ascii")
     if six.PY2:
         return LooseVersion.__cmp__(self, other)
     return LooseVersion._cmp(self, other)
コード例 #2
0
ファイル: versions.py プロジェクト: isabella232/juggler
 def __cmp__(self, other):
     has_esr = set()
     if isinstance(
             other,
             LooseModernMozillaVersion) and str(other).endswith('esr'):
         # If other version ends with esr, coerce through MozillaVersion ending up with
         # a StrictVersion if possible
         has_esr.add('other')
         other = MozillaVersion(
             str(other)[:-3])  # strip ESR from end of string
     if isinstance(self,
                   LooseModernMozillaVersion) and str(self).endswith('esr'):
         # If our version ends with esr, coerce through MozillaVersion ending up with
         # a StrictVersion if possible
         has_esr.add('self')
         self = MozillaVersion(
             str(self)[:-3])  # strip ESR from end of string
     if isinstance(other, LooseModernMozillaVersion) or \
             isinstance(self, LooseModernMozillaVersion):
         # If we're still LooseVersion for self or other, run LooseVersion compare
         # Being sure to pass through Loose Version type first
         val = LooseVersion.__cmp__(LooseModernMozillaVersion(str(self)),
                                    LooseModernMozillaVersion(str(other)))
     else:
         # No versions are loose, therefore we can use StrictVersion
         val = StrictVersion.__cmp__(self, other)
     if has_esr.isdisjoint(set(['other', 'self'])) or \
             has_esr.issuperset(set(['other', 'self'])):
         #  If both had esr string or neither, then cmp() was accurate
         return val
     elif val is not 0:
         # cmp is accurate here even if esr is present in only 1 compare, since
         # versions are not equal
         return val
     elif 'other' in has_esr:
         return -1  # esr is not greater than non esr
     return 1  # non esr is greater than esr
コード例 #3
0
ファイル: util.py プロジェクト: MekliCZ/positron
 def __cmp__(self, other):
     # LooseVersion checks isinstance(StringType), so work around it.
     if isinstance(other, unicode):
         other = other.encode('ascii')
     return LooseVersion.__cmp__(self, other)
コード例 #4
0
ファイル: util.py プロジェクト: soufianos01/juggler
 def __cmp__(self, other):
     # LooseVersion checks isinstance(StringType), so work around it.
     if isinstance(other, six.text_type):
         other = other.encode('ascii')
     return LooseVersion.__cmp__(self, other)