Ejemplo n.º 1
0
 def __repr__(self):
     r = []
     if self._cannot_match:
         r.append("%s None" % self.name)
     elif self._equal:
         r.append("%s == %s" % (self.name, self._equal))
     else:
         if self._min_bound != MinVersion():
             r.append("%s >= %s" % (self.name, self._min_bound))
         if self._max_bound != MaxVersion():
             r.append("%s <= %s" % (self.name, self._max_bound))
         if self._min_bound == MinVersion(
         ) and self._max_bound == MaxVersion():
             r.append("%s *" % self.name)
     return ", ".join(r)
Ejemplo n.º 2
0
    def test_max_reflexive(self):
        m = MaxVersion()

        self.assertFalse(m < m)
        self.assertTrue(m <= m)
        self.assertFalse(m > m)
        self.assertTrue(m >= m)
Ejemplo n.º 3
0
    def __init__(self, name, specs):
        self.name = name

        self._min_bound = MinVersion()
        self._max_bound = MaxVersion()

        # transform GE and LE into NOT + corresponding GEQ/LEQ
        # Take the min of GEQ, max of LEQ
        equals = [req for req in specs if isinstance(req, Equal)]
        if len(equals) > 1:
            self._cannot_match = True
            self._equal = None
        elif len(equals) == 1:
            self._cannot_match = False
            self._equal = V(equals[0].version)
            self._min_bound = self._max_bound = self._equal
        else:
            self._cannot_match = False
            self._equal = None

        geq = [req for req in specs if isinstance(req, GEQ)]
        geq_versions = [V(g.version) for g in geq]
        if len(geq_versions) > 0:
            self._min_bound = max(geq_versions)

        leq = [req for req in specs if isinstance(req, LEQ)]
        leq_versions = [V(l.version) for l in leq]
        if len(leq_versions) > 0:
            self._max_bound = min(leq_versions)

        if self._min_bound > self._max_bound:
            self._cannot_match = True
Ejemplo n.º 4
0
    def test_min_max_version(self):
        mi = MinVersion()
        ma = MaxVersion()

        self.assertTrue(mi < ma)
        self.assertTrue(mi <= ma)
        self.assertFalse(mi > ma)
        self.assertFalse(mi >= ma)
        self.assertFalse(mi == ma)
        self.assertTrue(mi != ma)
Ejemplo n.º 5
0
 def package_id_to_version(package_id):
     if package_id in installed_map:
         return MaxVersion()
     else:
         package = pool.package_by_id(package_id)
         return package.version
Ejemplo n.º 6
0
 def test_max_version(self):
     max_version = MaxVersion()
     self.assertTrue(max_version > V("99.99.99"))
     self.assertTrue(max_version >= V("99.99.99"))
     self.assertFalse(max_version < V("99.99.99"))
     self.assertFalse(max_version <= V("99.99.99"))