예제 #1
0
 def deserialize_safe(cls, byts):
     subtype, = cls.subtypes
     numelements = uint16_unpack(byts[:2])
     p = 2
     result = []
     for n in xrange(numelements):
         itemlen = uint16_unpack(byts[p:p+2])
         p += 2
         item = byts[p:p+itemlen]
         p += itemlen
         result.append(subtype.from_binary(item))
     return cls.adapter(result)
예제 #2
0
 def deserialize_safe(cls, byts):
     subtype, = cls.subtypes
     numelements = uint16_unpack(byts[:2])
     p = 2
     result = []
     for n in xrange(numelements):
         itemlen = uint16_unpack(byts[p:p + 2])
         p += 2
         item = byts[p:p + itemlen]
         p += itemlen
         result.append(subtype.from_binary(item))
     return cls.adapter(result)
예제 #3
0
 def deserialize_safe(cls, byts):
     subkeytype, subvaltype = cls.subtypes
     numelements = uint16_unpack(byts[:2])
     p = 2
     themap = {}
     for n in xrange(numelements):
         key_len = uint16_unpack(byts[p:p+2])
         p += 2
         keybytes = byts[p:p+key_len]
         p += key_len
         val_len = uint16_unpack(byts[p:p+2])
         p += 2
         valbytes = byts[p:p+val_len]
         p += val_len
         key = subkeytype.from_binary(keybytes)
         val = subvaltype.from_binary(valbytes)
         themap[key] = val
     return themap
예제 #4
0
 def deserialize_safe(cls, byts):
     subkeytype, subvaltype = cls.subtypes
     numelements = uint16_unpack(byts[:2])
     p = 2
     themap = {}
     for n in xrange(numelements):
         key_len = uint16_unpack(byts[p:p + 2])
         p += 2
         keybytes = byts[p:p + key_len]
         p += key_len
         val_len = uint16_unpack(byts[p:p + 2])
         p += 2
         valbytes = byts[p:p + val_len]
         p += val_len
         key = subkeytype.from_binary(keybytes)
         val = subvaltype.from_binary(valbytes)
         themap[key] = val
     return themap
예제 #5
0
    def deserialize_safe(cls, byts):
        p = 0
        result = []
        for col_name, col_type in zip(cls.fieldnames, cls.subtypes):
            if p == len(byts):
                break
            itemlen = uint16_unpack(byts[p:p + 2])
            p += 2
            item = byts[p:p + itemlen]
            p += itemlen
            result.append((str(col_name), col_type.from_binary(item)))
            p += 1

        return result
예제 #6
0
def read_short(f):
    return uint16_unpack(f.read(2))
예제 #7
0
def read_short(f):
    return uint16_unpack(f.read(2))