def _read_dat_files(self, args, prefix=''): path = get_content_path() console(prefix + 'Loading file system...') file_system = FileSystem(root_path=path) console(prefix + 'Reading .dat files') dat_files = {} lang = args.language or config.get_option('language') dir_path = "Data/" if lang != 'English': #ggpk_data = index.get_dir_record("Data/%s" % lang) dir_path = "Data/%s/" % lang remove = [] for name in tqdm(args.files): file_path = dir_path + name try: data = file_system.get_file(file_path) except FileNotFoundError: console('Skipping "%s" (missing)' % file_path, msg=Msg.warning) remove.append(name) continue df = dat.DatFile(name) try: df.read(file_path_or_raw=data, use_dat_value=False) except Exception: print(name, traceback.format_exc()) remove.append(name) dat_files[name] = df for file_name in remove: args.files.remove(file_name) return dat_files
def __init__(self, path_or_file_system: Union[str, FileSystem] = None, files: List[str] = None, files_shortcut: bool = True, instance_options: Dict[str, Any] = None, read_options: Dict[str, Any] = None): """ Parameters ---------- path_or_file_system The root path (i.e. relative to content.ggpk) where the files are stored or a :class:`PyPoE.poe.file.ggpk.GGPKFile` instance files Iterable of files that will be loaded right away files_shortcut Whether to use the shortcut function, i.e. self.__getitem__ instance_options options to pass to the file's __init__ method read_options options to pass to the file instance's read method Raises ------ TypeError if path_or_ggpk not specified or invalid type ValueError if a :class:`PyPoE.poe.file.ggpk.GGPKFile` was passed, but it was not parsed """ if isinstance(path_or_file_system, FileSystem): self.file_system: FileSystem = path_or_file_system else: self.file_system: FileSystem = FileSystem( root_path=path_or_file_system) self.instance_options: Dict[str, Any] = {} if \ instance_options is None else instance_options self.read_options: Dict[str, Any] = {} if \ read_options is None else read_options self.files: Dict[str, AbstractFileReadOnly] = {} read_func = self.__getitem__ if files_shortcut else self.get_file if files is not None: for file in files: read_func(file)
def load_file_system(ggpk_path): return FileSystem(ggpk_path)
import sys import os.path from PyPoE.poe.file.file_system import FileSystem from PyPoE.poe.file import bundle if bundle.ooz is None: bundle.ooz = bundle.ffi.dlopen('ooz/build/liblibooz.so') if __name__ == '__main__': file_system = FileSystem(root_path='Content.ggpk.d/latest') for filePath in sys.argv[1:]: data = file_system.get_file(filePath) desPath = os.path.join('out/extracted', os.path.basename(filePath)) file = open(desPath, 'wb') file.write(data) file.close()
# Functions # ============================================================================= if __name__ == '__main__': '''profiler = LineProfiler( DatStyle.sizeHint, DatStyle._get_text, DatStyle._show_value, )''' translator = QTranslator() translator.load('i18n/en_US') app = QApplication(sys.argv) app.installTranslator(translator) frame = QMainWindow() frame.setMinimumSize(2000, 1000) fs = FileSystem(r'M:\Steam\steamapps\common\Path of Exile') f = 'HeistEquipment.dat' data = fs.get_file('Data/' + f) #for item in dir(o): # print(item, getattr(o, item)) fm = FileDataManager(None) h = fm.get_handler(f) #profiler.run('w = h.get_widget(data, f, parent=frame)') #profiler.print_stats() w = h.get_widget(data, f, parent=frame) frame.setCentralWidget(w) frame.show() app.exec_()
def kf_file(self): kf = KeyValuesFile(parent_or_file_system=FileSystem( root_path=data_dir)) kf.read(os.path.join(data_dir, _read_file_name)) return kf
def file_system(poe_path) -> FileSystem: return FileSystem(poe_path)