def save(self) -> bool: tmp_dir = CreateZip.create_tmp_dir() storage = self.FileNameStorage() result = True documents_list = list() documents_list.append( (self.ui.variantTree, Path('Variants_Tree.xml')) ) for widget, file in zip(self.ui.view_mgr.file_mgr.widgets, self.ui.view_mgr.file_mgr.files): if hasattr(widget, 'user_view'): documents_list.append( (widget.user_view, file) ) for view, file in documents_list: if not view.model().rowCount() or not file: continue tab_order_index = self.get_tab_order(file) file = storage.add_file(file, tab_order_index, view.undo_stack.isClean()) # Save document tmp_file = tmp_dir / file.name r, _ = self.load_save_mgr.save(tmp_file, view) if not r: result = False del storage.store[file.name] else: LOGGER.debug('Saved session document: %s', tmp_file.name) # Save original file paths stored in Files class Settings.save(storage, tmp_dir / self.files_list_name) if not CreateZip.save_dir_to_zip(tmp_dir, self.session_zip): result = False CreateZip.remove_dir(tmp_dir) return result
""" Creates python resource file for PyQt5 with pyrcc5 """ import sys import lxml.etree as Et from pathlib import Path from shlex import split as shell_syntax from subprocess import run from modules.settings import Settings, delayed_log_setup from modules.app_globals import Resource qrc_resource_file = "tieflader_res.qrc" scripts_dir = Path(sys.executable).parent # eg. C:/Python/Scripts pyside_rcc_path = scripts_dir.parent / 'Lib' / 'site-packages' / 'PySide2' / 'pyside2-rcc.exe' args = pyside_rcc_path.as_posix( ) + r" -compress 9 -o gui_resource.py " + qrc_resource_file print(shell_syntax(args)) run(shell_syntax(args), shell=True) # Update resource paths with open(qrc_resource_file, 'r') as f: xml = Et.parse(f) for e in xml.iterfind('qresource'): prefix = e.get('prefix') if not prefix: continue print('---- Prefix: {} ----'.format(prefix)) for file in e.iter('file'): file_path = file.text if not file_path: