def handle(self, args): ver = config.get_option('version') if ver != VERSION.DEFAULT: console('Loading specification for %s' % ver) dat.set_default_spec(version=ver) spec = dat._default_spec if args.files is None: args.files = list(spec) else: files = set() for file_name in args.files: if file_name in spec: files.add(file_name) elif not file_name.endswith('.dat'): file_name += '.dat' if file_name not in spec: console( '.dat file "%s" is not in specification. Removing.' % file_name, msg=Msg.error) else: files.add(file_name) files = list(files) files.sort() args.files = files args.spec = spec
def _reload_specifications(self): p = self.parent() v = p.s_general.version p._write_log(self.tr('Reloading default specification... (%s)' % v)) dat.set_default_spec(version=v, reload=True) p._write_log('Done.')
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 pytest_generate_tests(metafunc): global run if run: dat.set_default_spec(version=get_version(metafunc.config)) run = False if 'dat_file_name' in metafunc.fixturenames: file_names = [fn for fn in load(version=get_version(metafunc.config))] metafunc.parametrize('dat_file_name', file_names) elif 'unique_dat_file_name' in metafunc.fixturenames and \ 'unique_dat_field_name' in metafunc.fixturenames: tests = [] for file_name, file_section in load( version=get_version(metafunc.config)).items(): for field_name, field_section in file_section['fields'].items(): if not field_section['unique']: continue tests.append((file_name, field_name)) metafunc.parametrize( ('unique_dat_file_name', 'unique_dat_field_name'), tests, )
def poe_version(request): v = get_version(request.config) dat.set_default_spec(v) return v
def test_reload_default_spec(): old = dat._default_spec dat.set_default_spec(reload=True) assert id(old) != id(dat._default_spec), 'Specification wasn\'t reloaded'
def __init__(self, *args, **kwargs): super().__init__( *args, app_name=self.NAME, **kwargs ) self.s_general = GeneralSettingsFrame(parent=self) dat.set_default_spec(version=self.s_general.version) # Misc Variables set in other places self._last_node = None self._file_data_manager = FileDataManager(self) # Menu Bar self.menu_file = FileMenu(parent=self) self.menu_view = ViewMenu(parent=self) self.menu_misc = MiscMenu(parent=self) self.menu_misc.addAction(self.settings_window.action_open) # Tool Bars self.context_toolbar = ContextToolbar(parent=self) # Central Widget self.master = QSplitter(parent=self) self.master.setOrientation(Qt.Vertical) self.work_area_splitter = QSplitter() self.master.addWidget(self.work_area_splitter) self.master.addWidget(self.notification) self.ggpk_view = QTreeView() self.ggpk_view.setModel(GGPKModel()) self.ggpk_view.setColumnWidth(0, 200) self.ggpk_view.setColumnWidth(1, 75) self.ggpk_view.setColumnWidth(2, 80) #self.ggpk_view.setColumnWidth(3, 80) self.ggpk_view.setMinimumSize(370, 370) self.ggpk_view.clicked.connect(self._view_record) self.ggpk_view.setContextMenuPolicy(Qt.ActionsContextMenu) self.ggpk_view.addAction(self.context_toolbar.action_extract) self.ggpk_view.addAction(self.context_toolbar.action_search) self.ggpk_view.addAction(self.context_toolbar.action_copy_path) self.work_area_splitter.addWidget(self.ggpk_view) self.work_area_frame = QFrame() self.work_area_frame.setContentsMargins(0, 0, 0, 0) self.file_layout = QVBoxLayout() self.file_layout.setContentsMargins(0, 0, 0, 0) self.work_area_frame.setLayout(self.file_layout) self.work_area_splitter.addWidget(self.work_area_frame) # Create Info bar self.file_infobar_layout = QHBoxLayout() self.file_infobar_layout.setAlignment(Qt.AlignLeft) self.file_infobar = QFrame() self.file_infobar.setSizePolicy( QSizePolicy.Minimum, QSizePolicy.Maximum ) self.file_infobar.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) self.file_infobar.setLayout(self.file_infobar_layout) self.file_infobar_layout.addWidget(QLabel(self.tr('Name Hash:'))) self.file_infobar_name_hash = QLineEdit(readOnly=True) #self.file_infobar_name_hash.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Maximum) self.file_infobar_name_hash.setFixedWidth(70) self.file_infobar_layout.addWidget(self.file_infobar_name_hash) self.file_infobar_layout.addWidget(QLabel(self.tr('File Hash:'))) self.file_infobar_file_hash = QLineEdit(readOnly=True) self.file_infobar_file_hash.setSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.Maximum ) self.file_infobar_file_hash.setMinimumWidth(405) self.file_infobar_layout.addWidget(self.file_infobar_file_hash) # Add to the info bar to general file layout self.file_layout.addWidget(self.file_infobar) # Create Frame #self.file_frame_scroll = QScrollArea() #self.file_frame_scroll.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) #self.file_layout.addWidget(self.file_frame_scroll) self.file_frame = QFrame() self.file_frame.setSizePolicy( QSizePolicy.Expanding, QSizePolicy.Expanding ) self.file_frame.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) self.file_layout.addWidget(self.file_frame) self.file_frame_layout = QVBoxLayout() self.file_frame_layout.setAlignment(Qt.AlignTop) self.file_frame.setLayout(self.file_frame_layout) #self.file_frame_scroll.setWidget(self.file_frame) #self.file_frame_scroll.setLayout(self.file_frame_layout) #self.file_frame_scroll.show() # self.file_textbox = QTextEdit(self) self.file_textbox.setText(self.tr("No file selected.")) self.file_textbox.setSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding ) self.file_frame_layout.addWidget(self.file_textbox) # Setup the main window self.setCentralWidget(self.master) self.statusBar() self.setWindowTitle(self.tr(self.NAME))