def parse_list(self, file, identifier): size_field = file.read(4) list_identifier = file.read(4) size = get_chunk_size(size_field) offset = file.tell() if list_identifier == 'cmpr': file.seek(offset) self.stream_start = offset self.stream_size = get_chunk_size(size_field) chunk = file.read(size - 4) return self.parse_cmpr_list(identifier + size_field + \ list_identifier + chunk) class_ = self.get_class(identifier, list_identifier) obj = class_(identifier + size_field + list_identifier) while file.tell() <= offset + size - 8: ret = self.parse_stream(file) if ret is None: file.seek(offset) chunk = file.read(size - 4) return model.RiffUnparsedList(identifier + size_field + \ list_identifier + chunk) else: obj.childs.append(ret) return obj
def parse_object(self, file, identifier): if not identifier[:3].isalnum(): return None size_field = file.read(4) size = get_chunk_size(size_field) chunk = file.read(size) return model.RiffObject(identifier + size_field + chunk)
def parse_object(self, file, identifier): if not identifier[:3].isalnum(): return None size_field = file.read(4) size = get_chunk_size(size_field) chunk = file.read(size) class_ = self.get_class(identifier) return class_(identifier + size_field + chunk)
def parse_file(self, file): identifier = file.read(4) size_field = file.read(4) list_identifier = file.read(4) obj = model.RiffRootList(identifier + size_field + list_identifier) size = get_chunk_size(size_field) while file.tell() < size + 8: ret = self.parse_stream(file) obj.childs.append(ret) return obj
def parse_pack(self, file, identifier): size_field = file.read(4) size = get_chunk_size(size_field) chunk = file.read(size) obj = model.RiffPackObject(identifier + size_field + chunk) import StringIO, zlib decomp = zlib.decompressobj() uncompresseddata = decomp.decompress(chunk[12:]) stream = StringIO.StringIO(uncompresseddata) while stream.tell() < len(uncompresseddata): ret = self.parse_stream(stream) obj.childs.append(ret) return obj