Example #1
0
 def _norm_int(self, valu, oldval=None):
     if valu < 0:
         self._raiseBadValu(valu, mesg='Cannot norm a negative integer as a semver.')
     if valu > s_version.mask60:
         self._raiseBadValu(valu,
                            mesg='Cannot norm a integer larger than 1152921504606846975 as a semver.')
     major, minor, patch = s_version.unpackVersion(valu)
     valu = s_version.packVersion(major, minor, patch)
     subs = {'major': major,
             'minor': minor,
             'patch': patch}
     return valu, subs
Example #2
0
 def _normPyInt(self, valu):
     if valu < 0:
         raise s_exc.BadTypeValu(valu=valu, name=self.name,
                                 mesg='Cannot norm a negative integer as a semver.')
     if valu > s_version.mask60:
         raise s_exc.BadTypeValu(valu=valu, name=self.name,
                                 mesg='Cannot norm a integer larger than 1152921504606846975 as a semver.')
     major, minor, patch = s_version.unpackVersion(valu)
     valu = s_version.packVersion(major, minor, patch)
     subs = {'major': major,
             'minor': minor,
             'patch': patch}
     return valu, {'subs': subs}
Example #3
0
 def _normPyInt(self, valu):
     if valu < 0:
         raise s_exc.BadTypeValu(valu=valu, name=self.name,
                                 mesg='Cannot norm a negative integer as a semver.')
     if valu > s_version.mask60:
         raise s_exc.BadTypeValu(valu=valu, name=self.name,
                                 mesg='Cannot norm a integer larger than 1152921504606846975 as a semver.')
     major, minor, patch = s_version.unpackVersion(valu)
     valu = s_version.packVersion(major, minor, patch)
     subs = {'major': major,
             'minor': minor,
             'patch': patch}
     return valu, {'subs': subs}
    def test_version_unpack(self):
        tup = s_version.unpackVersion(0)
        self.eq(tup, (0, 0, 0))

        tup = s_version.unpackVersion(0x000010000000000)
        self.eq(tup, (1, 0, 0))

        tup = s_version.unpackVersion(0x000010000200003)
        self.eq(tup, (1, 2, 3))

        tup = s_version.unpackVersion(0xdeadb33f1337133)
        self.eq(tup, (0xdeadb, 0x33f13, 0x37133))

        tup = s_version.unpackVersion(s_version.mask60)
        self.eq(tup, (s_version.mask20, s_version.mask20, s_version.mask20))

        # Ensure we only snag the data from the 96 bits of input
        # XXX Or do we want this to throw an exception?
        tup = s_version.unpackVersion(1 << 60)
        self.eq(tup, (0, 0, 0))
        tup = s_version.unpackVersion(1 << 60 | s_version.mask60)
        self.eq(tup, (s_version.mask20, s_version.mask20, s_version.mask20))
Example #5
0
    def test_version_unpack(self):
        tup = s_version.unpackVersion(0)
        self.eq(tup, (0, 0, 0))

        tup = s_version.unpackVersion(0x000010000000000)
        self.eq(tup, (1, 0, 0))

        tup = s_version.unpackVersion(0x000010000200003)
        self.eq(tup, (1, 2, 3))

        tup = s_version.unpackVersion(0xdeadb33f1337133)
        self.eq(tup, (0xdeadb, 0x33f13, 0x37133))

        tup = s_version.unpackVersion(s_version.mask60)
        self.eq(tup, (s_version.mask20, s_version.mask20, s_version.mask20))

        # Ensure we only snag the data from the 96 bits of input
        # XXX Or do we want this to throw an exception?
        tup = s_version.unpackVersion(1 << 60)
        self.eq(tup, (0, 0, 0))
        tup = s_version.unpackVersion(1 << 60 | s_version.mask60)
        self.eq(tup, (s_version.mask20, s_version.mask20, s_version.mask20))
Example #6
0
 def repr(self, valu):
     major, minor, patch = s_version.unpackVersion(valu)
     valu = s_version.fmtVersion(major, minor, patch)
     return valu
Example #7
0
 def repr(self, valu, defval=None):
     major, minor, patch = s_version.unpackVersion(valu)
     valu = s_version.fmtVersion(major, minor, patch)
     return valu