def parse_unity_file(file_): s_bytes = b"" t_len = len(t_bytes) with open(file_, "rb") as f: xml_buf = bytearray() for line in f: p = 0 bytes_ = bytearray(line) # Search end of block try: p = bytes_.index(t_bytes) xml_buf += bytes_[p:t_len] save_xml(xml_buf) xml_buf = bytearray() bytes_ = bytes_[p + t_len:] except ValueError: pass # Search start of block (