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)
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)
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
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
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
def read_short(f): return uint16_unpack(f.read(2))