def unpack(cls, data): payload, data = LongString.unpack(data) payload = payload.value values = [] try: while payload: type_specifier, payload = eat(payload, 1) field_type = FIELD_TYPES[type_specifier] value, payload = field_type.unpack(payload) values.append(value) except Incomplete: _, _, tb = sys.exc_info() ex = ValueError("FieldArray payload reported Incomplete") raise type(ex), ex, tb return cls(values), data
def unpack(cls, data): payload, data = LongString.unpack(data) payload = payload.value values = {} try: while payload: name, payload = FieldName.unpack(payload) name = name.value type_specifier, payload = eat(payload, 1) field_type = FIELD_TYPES[type_specifier] value, payload = field_type.unpack(payload) values[name] = value except Incomplete: _, _, tb = sys.exc_info() ex = ValueError("FieldTable payload reported Incomplete") raise type(ex), ex, tb return cls(values), data