def load(self, s: AbstractIO): self.clear() curblock = self left = s.get_uint() level = 0 stack = list() while level > -1: if left > 0: type = s.get_byte() name = s.get_widestr() if type == ElementKind.PARAM: curblock.add(name, s.get_widestr()) left -= 1 elif type == ElementKind.BLOCK: stack.append((curblock, left)) prevblock = curblock curblock = CacheData() prevblock.add(name, curblock) left = s.get_uint() level += 1 continue else: if level > 0: curblock, left = stack.pop() left -= 1 level -= 1
def load(self, s: AbstractIO): self.name = s.get_widestr() self.kind, compressed = get_kind(s.get_uint()) size = s.get_uint() if compressed: self.datatable = DataTable(get_size_by_kind(self.kind)) tempbuf = Buffer.from_bytes(s.decompress(size)) self.datatable.load(tempbuf, tempbuf.size()) tempbuf.close() del tempbuf else: self.datatable = DataTable(get_size_by_kind(self.kind)) self.datatable.load(s, size)
def load(self, s: AbstractIO, size: int): initpos = s.pos() header = _header(s.get_uint(), s.get_int(), s.get_int()) for i in range(header.arrays_number): header_size = 4 * 3 # uint, uint, int offset = initpos + header.alloc_table_offset + i * header_size s.seek(offset) entry = _table_entry( s.get_uint(), s.get_int(), s.get_int(), ) start = initpos + entry.offset length = header.element_type_size * entry.number s.seek(start) self.entries.append(s.get(length)) endpos = initpos + size s.seek(endpos)
def load(self, s: AbstractIO): magic = s.get(4) if magic != b'STRG': s.close() raise Exception("Storage.load: wrong magic") version = s.get_uint() if version > 1: s.close() raise Exception("Storage.load: wrong version") if version == 1: tempbuf = Buffer.from_bytes(s.decompress()) s.close() s = tempbuf for i in range(s.get_uint()): record = StorageRecord() record.load(s) self.records.append(record)
def load(self, s: AbstractIO, *, new_format: bool = False): self.clear() curblock = self curblock.sorted = s.get_bool() left = s.get_uint() level = 0 stack = list() while level > -1: if left > 0: if new_format and curblock.sorted: s.get(8) type = s.get_byte() name = s.get_widestr() if type == ElementKind.PARAM: curblock.add(name, s.get_widestr()) left -= 1 elif type == ElementKind.BLOCK: stack.append((curblock, left)) prevblock = curblock curblock = BlockPar() prevblock.add(name, curblock) curblock.sorted = s.get_bool() left = s.get_uint() level += 1 continue else: if level > 0: curblock, left = stack.pop() left -= 1 level -= 1
def load(self, s: AbstractIO): self.name = s.get_widestr() for i in range(s.get_uint()): item = StorageItem() item.load(s) self.items.append(item)