def _open_ggpk(self): """ Returns ------- GGPKThread or None Returns GGPKThread if successful, none otherwise """ # TODO replace with config / last path paths = PoEPath(version=self._get_version(), distributor=DISTRIBUTOR.GGG).get_installation_paths() # Use the first found path if paths: dir = os.path.join(paths[0].path, 'content.ggpk') else: dir = '.' p = self.parent() file = QFileDialog.getOpenFileName(p, self.tr("Open GGPK"), dir, self.tr("GGPK Files (*.ggpk)")) # User Aborted if not file[0]: return file_path = file[0] return GGPKThread(file_path, parent=p)
def poe_path(poe_version): paths = PoEPath( version=poe_version, distributor=DISTRIBUTOR.INTERNATIONAL).get_installation_paths( only_existing=True) if paths: return paths[0] else: pytest.skip('Path of Exile installation not found.')
def run(): out = [] path = PoEPath(version=VERSION.STABLE, distributor=DISTRIBUTOR.GGG).get_installation_paths()[0] dat.set_default_spec(VERSION.STABLE) existing_set = set(dat._default_spec.keys()) ggpk = GGPKFile() ggpk.read(os.path.join(path, 'content.ggpk')) ggpk.directory_build() index = Index() index.read(ggpk[Index.PATH].record.extract()) file_set = set() for name in index.get_dir_record('Data').files: if not name.endswith('.dat'): continue # Not a regular dat file, ignore if name in ['Languages.dat']: continue file_set.add(name) new = sorted(file_set.difference(set(existing_set))) for fn in new: fr = index.get_file_record('Data/' + fn) fr.bundle.read(ggpk[fr.bundle.ggpk_path].record.extract()) binary = fr.get_file() data_offset = binary.find(dat.DAT_FILE_MAGIC_NUMBER) n_rows = struct.unpack('<I', binary[0:4])[0] length = data_offset - 4 if n_rows > 0: record_length = length // n_rows out.append(""" '%s': File( fields=( %s ), ),""" % (fn, spec_unknown(record_length))) print('\n'.join(out))
def get_content_path(): """ Returns the path to the current content.ggpk based on the specified config variables for the version & distributor. :return: Path of the content ggpk :rtype: str :raises SetupError: if no valid path was found. """ path = config.get_option('ggpk_path') if path == '': args = config.get_option('version'), config.get_option('distributor') paths = PoEPath(*args).get_installation_paths() if not paths: raise SetupError('No PoE Installation found.') return paths[0] else: return path