Пример #1
0
 def fromBinary(self, uuid, version=None):
     if len(uuid) != 16:
         raise Exception("Must have exactly 16 bytes")
     return UUID(Binary.readInt(Utils.substr(uuid, 0, 4)),
                 Binary.readInt(Utils.substr(uuid, 4, 4)),
                 Binary.readInt(Utils.substr(uuid, 8, 4)),
                 Binary.readInt(Utils.substr(uuid, 12, 4)), version)
Пример #2
0
 def toString(self):
     hex = Utils.bin2hex(self.toBinary())
     if self.version != None:
         return Utils.substr(hex, 0, 8) + "-" + Utils.substr(
             hex, 8, 4) + "-" + int(self.version, 16) + Utils.substr(
                 hex, 13, 3) + "-8" + Utils.substr(
                     hex, 17, 3) + "-" + Utils.substr(hex, 20, 12)
     return Utils.substr(hex, 0, 8) + "-" + Utils.substr(
         hex, 8, 4) + "-" + Utils.substr(hex, 12, 4) + "-" + Utils.substr(
             hex, 16, 4) + "-" + Utils.substr(hex, 20, 12)