def unpack(reader): subtype, = reader.peek('!H', 0) subclass = instruction_id.subtypes.get(subtype) if subclass: return subclass.unpack(reader) obj = instruction_id() obj.type = reader.read("!H")[0] _len = reader.read("!H")[0] orig_reader = reader reader = orig_reader.slice(_len - (2 + 2)) return obj
def unpack(reader): subtype, = reader.peek('!H', 0) subclass = instruction_id.subtypes.get(subtype) if subclass: return subclass.unpack(reader) obj = instruction_id() obj.type = reader.read("!H")[0] _len = reader.read("!H")[0] orig_reader = reader reader = orig_reader.slice(_len, 4) return obj