import struct import typing class Ppix: def __init__(self, stream): self.__stream = stream stream.seek(0) if(stream.read(5) != b"PPIX\x00"): raise Exception("Stream does not begin with PPIX magic number") self.__publication_index_location, self.__collection_index_location, self.__tag_index_location, self.__word_tree_root_location = struct.unpack(" 0): self.__collection_alternatives_location = struct.unpack(" int: self.__stream.seek(self.__publication_index_location) return struct.unpack(" str: position = self.__publication_index_location + 4 + (id * 6) self.__stream.seek(position) string_location, string_length = struct.unpack(" typing.List[int]: position = self.__collection_index_location + (id * 6) self.__stream.seek(position) collection_location, collection_item_count = struct.unpack(" int: self.__stream.seek(self.__tag_index_location) return struct.unpack(" int: if(self.__collection_alternatives_location == 0): return 0 self.__stream.seek(self.__collection_alternatives_location) return struct.unpack("