From 9a894da6d4bab50c4c0ce76cb83c0596576acbc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20V=C3=ADrseda?= Date: Mon, 27 May 2024 08:07:38 +0200 Subject: [PATCH 1/9] refactor: enable commented code and improve message logs --- MiAZ/backend/pluginsystem.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/MiAZ/backend/pluginsystem.py b/MiAZ/backend/pluginsystem.py index 6eb1f3d7..95f07374 100644 --- a/MiAZ/backend/pluginsystem.py +++ b/MiAZ/backend/pluginsystem.py @@ -34,11 +34,11 @@ class MiAZPluginType(IntEnum): SYSTEM = 1 USER = 2 - # ~ def __str__(self): - # ~ if self.value == MiAZPluginType.USER: - # ~ return _("User Plugin") - # ~ elif self.value == MiAZPluginType.SYSTEM: - # ~ return _("System Plugin") + def __str__(self): + if self.value == MiAZPluginType.USER: + return _("User Plugin") + elif self.value == MiAZPluginType.SYSTEM: + return _("System Plugin") class MiAZPluginManager(GObject.GObject): @@ -119,7 +119,7 @@ def load_plugin(self, plugin: Peas.PluginInfo) -> bool: try: self.engine.load_plugin(plugin) if plugin.is_loaded(): - # ~ self.log.debug("Plugin %s (%s) loaded", plugin.get_name(), ptype) + self.log.debug("Plugin %s (%s) loaded", plugin.get_name(), ptype) return True else: self.log.error("Plugin %s (%s) couldn't be loaded", plugin.get_name(), ptype) @@ -131,8 +131,9 @@ def load_plugin(self, plugin: Peas.PluginInfo) -> bool: def unload_plugin(self, plugin: Peas.PluginInfo): try: + ptype = self.get_plugin_type(plugin) self.engine.unload_plugin(plugin) - self.log.debug("Plugin unloaded") + self.log.debug("Plugin %s (%s) unloaded", plugin.get_name(), ptype) except Exception as error: self.log.error(error) From 99eb03e0a941d84b3b2d27c304d510c3a9f106cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20V=C3=ADrseda?= Date: Mon, 27 May 2024 08:08:30 +0200 Subject: [PATCH 2/9] fix(ConfigView): Plugins Available ConfigView display user plugins --- MiAZ/frontend/desktop/widgets/configview.py | 24 ++++++++++----------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/MiAZ/frontend/desktop/widgets/configview.py b/MiAZ/frontend/desktop/widgets/configview.py index c5e70a9a..9d61d295 100644 --- a/MiAZ/frontend/desktop/widgets/configview.py +++ b/MiAZ/frontend/desktop/widgets/configview.py @@ -316,17 +316,17 @@ def _setup_view_finish(self): self.viewSl = MiAZColumnViewPlugin(self.app) self.add_columnview_used(self.viewSl) - # ~ def _update_view_available(self): - # ~ plugin_manager = self.app.get_service('plugin-manager') - # ~ items = [] - # ~ item_type = self.config.model - # ~ for plugin in plugin_manager.plugins: - # ~ ptype = plugin_manager.get_plugin_type(plugin) - # ~ if ptype == MiAZPluginType.USER: - # ~ pid = plugin.get_module_name() - # ~ title = plugin.get_description() #+ ' (v%s)' % plugin.get_version() - # ~ items.append(item_type(id=pid, title=title)) - # ~ self.viewAv.update(items) + def _update_view_available(self): + plugin_manager = self.app.get_service('plugin-manager') + items = [] + item_type = self.config.model + for plugin in plugin_manager.plugins: + ptype = plugin_manager.get_plugin_type(plugin) + if ptype == MiAZPluginType.USER: + pid = plugin.get_module_name() + title = plugin.get_description() #+ ' (v%s)' % plugin.get_version() + items.append(item_type(id=pid, title=title)) + self.viewAv.update(items) def _on_item_used_remove(self, *args): plugin_manager = self.app.get_service('plugin-manager') @@ -335,7 +335,6 @@ def _on_item_used_remove(self, *args): plugin = plugin_manager.get_plugin_info(plugin_used.id) if plugin.is_loaded(): plugin_manager.unload_plugin(plugin) - self.log.debug("Plugin %s unloaded", plugin.get_name()) del(plugins_used[plugin_used.id]) self.config.save_used(items=plugins_used) self._update_view_used() @@ -351,7 +350,6 @@ def _on_item_used_add(self, *args): plugin = plugin_manager.get_plugin_info(plugin_available.id) if not plugin.is_loaded(): plugin_manager.load_plugin(plugin) - self.log.debug("Plugin %s loaded", plugin.get_name()) changed = True if changed: self.config.save_used(items=plugins_used) From a42670e5fd7803e5e70cb849cda32724cc7fccb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20V=C3=ADrseda?= Date: Mon, 27 May 2024 09:50:52 +0200 Subject: [PATCH 3/9] feat(App): Add button in Welcome dialog to open the application settings window --- MiAZ/frontend/desktop/widgets/welcome.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/MiAZ/frontend/desktop/widgets/welcome.py b/MiAZ/frontend/desktop/widgets/welcome.py index 7736f8c2..219421ea 100644 --- a/MiAZ/frontend/desktop/widgets/welcome.py +++ b/MiAZ/frontend/desktop/widgets/welcome.py @@ -22,6 +22,7 @@ def __init__(self, app): super(Gtk.Box, self).__init__(spacing=12, orientation=Gtk.Orientation.VERTICAL) self.app = app self.factory = self.app.get_service('factory') + ENV = self.app.get_env() centerbox = Gtk.CenterBox(orientation=Gtk.Orientation.VERTICAL) centerbox.set_vexpand(True) centerbox.set_hexpand(True) @@ -30,18 +31,20 @@ def __init__(self, app): vbox = self.factory.create_box_vertical(spacing=24, hexpand=True, vexpand=False) centerbox.set_center_widget(vbox) - label = Gtk.Label.new(_('Welcome!')) + label = Gtk.Label.new(_('Welcome to %s!' % ENV['APP']['shortname'])) label.get_style_context().add_class(class_name='title-1') vbox.append(label) label = Gtk.Label() label.get_style_context().add_class(class_name='title-3') - label.set_markup(_('No active repositories has been found.\n')) - vbox.append(label) - label = Gtk.Label() - label.get_style_context().add_class(class_name='title-4') - label.set_markup(_('Please, open the Application Settings to manage your repositories.')) + label.set_markup(_('No active repositories have been found\n')) vbox.append(label) + button = self.factory.create_button(title='Manage repositories') + button.set_valign(Gtk.Align.CENTER) + button.set_halign(Gtk.Align.CENTER) + button.connect('clicked', self.app.show_app_settings) + vbox.append(button) + From 32ac01375874b82a5c6e3d23dd5264136f21724e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20V=C3=ADrseda?= Date: Mon, 27 May 2024 12:07:25 +0200 Subject: [PATCH 4/9] refactor(Workspace): UI changes --- MiAZ/frontend/desktop/widgets/workspace.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/MiAZ/frontend/desktop/widgets/workspace.py b/MiAZ/frontend/desktop/widgets/workspace.py index 078e674c..f107bf4d 100644 --- a/MiAZ/frontend/desktop/widgets/workspace.py +++ b/MiAZ/frontend/desktop/widgets/workspace.py @@ -65,7 +65,6 @@ def __init__(self, app): super(MiAZWorkspace, self).__init__(orientation=Gtk.Orientation.HORIZONTAL) self.log = get_logger('MiAZ.Workspace') self.app = app - self.backend = self.app.get_service('backend') self.factory = self.app.get_service('factory') self.actions = self.app.get_service('actions') self.repository = self.app.get_service('repo') @@ -75,11 +74,6 @@ def __init__(self, app): self.util.connect('filename-deleted', self._on_filename_deleted) for node in self.config: self.config[node].connect('used-updated', self._on_config_used_updated) - self.set_vexpand(False) - self.set_margin_top(margin=3) - self.set_margin_end(margin=3) - self.set_margin_bottom(margin=3) - self.set_margin_start(margin=3) self.app.add_widget('ws-dropdowns', {}) frmView = self._setup_workspace() self.append(frmView) @@ -98,8 +92,6 @@ def __init__(self, app): except: self.initialize_caches() - # ~ self._check_first_time() - # Allow plug-ins to make their job self.app.connect('start-application-completed', self._finish_configuration) self._on_filter_selected() @@ -376,11 +368,9 @@ def _setup_columnview(self): self.view = MiAZColumnViewWorkspace(self.app) self.app.add_widget('workspace-view', self.view) self.view.get_style_context().add_class(class_name='caption') - # ~ self.view.get_style_context().add_class(class_name='monospace') + self.view.get_style_context().add_class(class_name='monospace') self.view.set_filter(self._do_filter_view) - frmView = self.factory.create_frame(hexpand=True, vexpand=True) - frmView.set_child(self.view) - return frmView + return self.view def _on_factory_bind_icon_type(self, factory, list_item): box = list_item.get_child() @@ -678,7 +668,7 @@ def _do_eval_cond_matches_project(self, doc): if len(lprojects) == 0: matches = True else: - matches = self.backend.projects.exists(project, doc) + matches = projects.exists(project, doc) return matches def _do_filter_view(self, item, filter_list_model): From bd201f9421c749cd48aa552ce79d82d7a926f707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20V=C3=ADrseda?= Date: Mon, 27 May 2024 12:12:50 +0200 Subject: [PATCH 5/9] fix(Workspace): use only one signal to allow plugins know that the workspace is ready --- MiAZ/frontend/desktop/widgets/workspace.py | 8 +++----- data/resources/plugins/delete.py | 2 +- data/resources/plugins/export2csv.py | 2 +- data/resources/plugins/export2dir.py | 4 ++-- data/resources/plugins/export2text.py | 2 +- data/resources/plugins/export2zip.py | 2 +- data/resources/plugins/massrename.py | 2 +- data/resources/plugins/menurepo.py | 2 +- data/resources/plugins/projmgt.py | 2 +- data/resources/plugins/renameitem.py | 2 +- data/resources/plugins/viewitem.py | 2 +- 11 files changed, 14 insertions(+), 16 deletions(-) diff --git a/MiAZ/frontend/desktop/widgets/workspace.py b/MiAZ/frontend/desktop/widgets/workspace.py index f107bf4d..3540b237 100644 --- a/MiAZ/frontend/desktop/widgets/workspace.py +++ b/MiAZ/frontend/desktop/widgets/workspace.py @@ -50,8 +50,7 @@ class MiAZWorkspace(Gtk.Box): __gtype_name__ = 'MiAZWorkspace' """Workspace""" __gsignals__ = { - "extend-menu": (GObject.SignalFlags.RUN_LAST, None, ()), - "extend-toolbar-top": (GObject.SignalFlags.RUN_LAST, None, ()), + "workspace-loaded": (GObject.SignalFlags.RUN_LAST, None, ()), } workspace_loaded = False selected_items = [] @@ -65,6 +64,7 @@ def __init__(self, app): super(MiAZWorkspace, self).__init__(orientation=Gtk.Orientation.HORIZONTAL) self.log = get_logger('MiAZ.Workspace') self.app = app + self.backend = self.app.backend self.factory = self.app.get_service('factory') self.actions = self.app.get_service('actions') self.repository = self.app.get_service('repo') @@ -141,9 +141,7 @@ def _on_filename_deleted(self, util, target): def _finish_configuration(self, *args): # ~ self.log.debug("Finish loading workspace") self.workspace_loaded = True - # ~ self.app.load_plugins() - self.emit('extend-menu') - self.emit('extend-toolbar-top') + self.emit('workspace-loaded') def _setup_toolbar_filters(self): dropdowns = self.app.get_widget('ws-dropdowns') diff --git a/data/resources/plugins/delete.py b/data/resources/plugins/delete.py index 12512efe..66f7e989 100644 --- a/data/resources/plugins/delete.py +++ b/data/resources/plugins/delete.py @@ -37,7 +37,7 @@ def do_activate(self): self.config = self.backend.get_config() self.util = self.app.get_service('util') self.workspace = API.app.get_widget('workspace') - self.workspace.connect("extend-menu", self.add_menuitem) + self.workspace.connect('workspace-loaded', self.add_menuitem) def do_deactivate(self): diff --git a/data/resources/plugins/export2csv.py b/data/resources/plugins/export2csv.py index bbcc40c2..fa2f6dc7 100644 --- a/data/resources/plugins/export2csv.py +++ b/data/resources/plugins/export2csv.py @@ -31,7 +31,7 @@ def do_activate(self): self.factory = self.app.get_service('factory') self.util = self.app.get_service('util') self.workspace = API.app.get_widget('workspace') - self.workspace.connect("extend-menu", self.add_menuitem) + self.workspace.connect('workspace-loaded', self.add_menuitem) def do_deactivate(self): self.log.debug("Plugin deactivation not implemented") diff --git a/data/resources/plugins/export2dir.py b/data/resources/plugins/export2dir.py index 9d215835..c8526838 100644 --- a/data/resources/plugins/export2dir.py +++ b/data/resources/plugins/export2dir.py @@ -45,7 +45,7 @@ def do_activate(self): self.factory = self.app.get_service('factory') self.util = self.app.get_service('util') self.workspace = API.app.get_widget('workspace') - self.workspace.connect("extend-menu", self.add_menuitem) + self.workspace.connect('workspace-loaded', self.add_menuitem) def do_deactivate(self): print("do_deactivate") @@ -141,4 +141,4 @@ def filechooser_response(dialog, response, patterns): hbox.append(etyPattern) hbox.append(btpPattern) box.append(hbox) - filechooser.show() \ No newline at end of file + filechooser.show() diff --git a/data/resources/plugins/export2text.py b/data/resources/plugins/export2text.py index 81ec6283..54543007 100644 --- a/data/resources/plugins/export2text.py +++ b/data/resources/plugins/export2text.py @@ -31,7 +31,7 @@ def do_activate(self): self.factory = self.app.get_service('factory') self.util = self.app.get_service('util') self.workspace = API.app.get_widget('workspace') - self.workspace.connect("extend-menu", self.add_menuitem) + self.workspace.connect('workspace-loaded', self.add_menuitem) def do_deactivate(self): print("do_deactivate") diff --git a/data/resources/plugins/export2zip.py b/data/resources/plugins/export2zip.py index 291437de..620935a4 100644 --- a/data/resources/plugins/export2zip.py +++ b/data/resources/plugins/export2zip.py @@ -45,7 +45,7 @@ def do_activate(self): self.factory = self.app.get_service('factory') self.util = self.app.get_service('util') self.workspace = API.app.get_widget('workspace') - self.workspace.connect("extend-menu", self.add_menuitem) + self.workspace.connect('workspace-loaded', self.add_menuitem) def do_deactivate(self): print("do_deactivate") diff --git a/data/resources/plugins/massrename.py b/data/resources/plugins/massrename.py index 72867689..2ca63b3b 100644 --- a/data/resources/plugins/massrename.py +++ b/data/resources/plugins/massrename.py @@ -67,7 +67,7 @@ def do_activate(self): self.config = self.backend.get_config() self.util = self.app.get_service('util') self.workspace = API.app.get_widget('workspace') - self.workspace.connect("extend-menu", self.add_menuitem) + self.workspace.connect('workspace-loaded', self.add_menuitem) def do_deactivate(self): diff --git a/data/resources/plugins/menurepo.py b/data/resources/plugins/menurepo.py index 55c97217..2cd6cf1f 100644 --- a/data/resources/plugins/menurepo.py +++ b/data/resources/plugins/menurepo.py @@ -31,7 +31,7 @@ def do_activate(self): self.factory = self.app.get_service('factory') self.util = self.app.get_service('util') self.workspace = API.app.get_widget('workspace') - self.workspace.connect("extend-menu", self.repo_settings_menu) + self.workspace.connect('workspace-loaded', self.repo_settings_menu) def do_deactivate(self): self.log.debug("Plugin deactivation not implemented") diff --git a/data/resources/plugins/projmgt.py b/data/resources/plugins/projmgt.py index 7fc3ca9e..4b14dbaa 100644 --- a/data/resources/plugins/projmgt.py +++ b/data/resources/plugins/projmgt.py @@ -58,7 +58,7 @@ def do_activate(self): self.util = self.app.get_service('util') self.projects = self.app.get_service('Projects') self.workspace = API.app.get_widget('workspace') - self.workspace.connect("extend-menu", self.add_menuitem) + self.workspace.connect('workspace-loaded', self.add_menuitem) def do_deactivate(self): self.log.debug("Plugin deactivation not implemented") diff --git a/data/resources/plugins/renameitem.py b/data/resources/plugins/renameitem.py index f4a26ff2..240f5cac 100644 --- a/data/resources/plugins/renameitem.py +++ b/data/resources/plugins/renameitem.py @@ -41,7 +41,7 @@ def do_activate(self): self.factory = self.app.get_service('factory') self.util = self.app.get_service('util') self.workspace = API.app.get_widget('workspace') - self.workspace.connect("extend-toolbar-top", self.add_toolbar_button) + self.workspace.connect('workspace-loaded', self.add_toolbar_button) view = self.app.get_widget('workspace-view') selection = view.get_selection() selection.connect('selection-changed', self._on_selection_changed) diff --git a/data/resources/plugins/viewitem.py b/data/resources/plugins/viewitem.py index 33e008d8..4b76189c 100644 --- a/data/resources/plugins/viewitem.py +++ b/data/resources/plugins/viewitem.py @@ -32,7 +32,7 @@ def do_activate(self): self.factory = self.app.get_service('factory') self.util = self.app.get_service('util') self.workspace = API.app.get_widget('workspace') - self.workspace.connect("extend-toolbar-top", self.add_toolbar_button) + self.workspace.connect('workspace-loaded', self.add_toolbar_button) view = self.app.get_widget('workspace-view') view.cv.connect("activate", self.callback) selection = view.get_selection() From 7bcf0bbc9cb3bd4117f98852ad3f287fd163b071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20V=C3=ADrseda?= Date: Mon, 27 May 2024 19:07:06 +0200 Subject: [PATCH 6/9] fix(Util): remove dependency from module repository --- MiAZ/backend/projects.py | 7 +- MiAZ/backend/stats.py | 4 +- MiAZ/backend/util.py | 180 +++++++++----------- MiAZ/frontend/desktop/services/actions.py | 21 ++- MiAZ/frontend/desktop/widgets/configview.py | 8 +- MiAZ/frontend/desktop/widgets/rename.py | 12 +- MiAZ/frontend/desktop/widgets/selector.py | 5 +- MiAZ/frontend/desktop/widgets/workspace.py | 18 +- data/resources/plugins/delete.py | 4 +- data/resources/plugins/export2dir.py | 10 +- data/resources/plugins/export2zip.py | 18 +- data/resources/plugins/massrename.py | 18 +- data/resources/plugins/projmgt.py | 16 +- 13 files changed, 170 insertions(+), 151 deletions(-) diff --git a/MiAZ/backend/projects.py b/MiAZ/backend/projects.py index 9762e5da..7de4ac5d 100644 --- a/MiAZ/backend/projects.py +++ b/MiAZ/backend/projects.py @@ -25,8 +25,8 @@ def __init__(self, backend): conf = self.backend.get_config() self.config = conf['Project'] self.util = self.backend.get_service('util') - repository = self.backend.get_service('repo') - repo_dir_conf = repository.get('dir_conf') + self.repository = self.backend.get_service('repo') + repo_dir_conf = self.repository.get('dir_conf') self.cnfprj = os.path.join(repo_dir_conf, 'projects.json') self.projects = {} if not os.path.exists(self.cnfprj): @@ -36,10 +36,11 @@ def __init__(self, backend): self.check() def check(self): + repo_dir = self.repository.get('dir_docs') to_delete = [] for project in self.projects: for doc in self.docs_in_project(project): - docpath = self.util.filename_path(doc) + docpath = os.path.join(repo_dir, doc) if not os.path.exists(docpath): to_delete.append((doc, project)) for doc, project in to_delete: diff --git a/MiAZ/backend/stats.py b/MiAZ/backend/stats.py index 0ced6c04..5ead8238 100644 --- a/MiAZ/backend/stats.py +++ b/MiAZ/backend/stats.py @@ -39,6 +39,7 @@ def __init__(self, backend): self.backend = backend self.log = get_logger('MiAZStats') self.util = self.backend.get_service('util') + self.repository = self.backend.get_service('repo') def _build(self, *args): self.stats = {} @@ -52,7 +53,8 @@ def _build(self, *args): self.stats[_(Purpose.__title__)] = {} self.stats[_(SentTo.__title__)] = {} - for document in self.util.get_files(): + repo_dir = self.repository.get('dir_docs') + for document in self.util.get_files(repo_dir): fields = self.util.get_fields(document) # Date diff --git a/MiAZ/backend/util.py b/MiAZ/backend/util.py index ffb8ee53..a6917c84 100644 --- a/MiAZ/backend/util.py +++ b/MiAZ/backend/util.py @@ -58,7 +58,7 @@ def __init__(self, backend): self.app = backend.app self.backend = backend self.conf = self.backend.get_config() - self.repository = self.backend.get_service('repo') + # ~ self.repository = self.backend.get_service('repo') def directory_open(self, dirpath: str): os.system("xdg-open '%s'" % dirpath) @@ -95,9 +95,9 @@ def json_save(self, filepath: str, adict: {}) -> {}: with open(filepath, 'w') as fout: json.dump(adict, fout, sort_keys=True, indent=4) - def field_used(self, item_type, value): + def field_used(self, repo_dir, item_type, value): used = False - for doc in self.get_files(): + for doc in self.get_files(repo_dir): fields = self.get_fields(doc) fn = Field[item_type] if fields[fn] == value: @@ -108,10 +108,8 @@ def field_used(self, item_type, value): def get_temp_dir(self): ENV = self.app.get_env() - repo_dir = self.repository.get('dir_docs') ts = datetime.now().strftime('%Y%m%d_%H%M%S') - name = self.valid_key(repo_dir) - return os.path.join(ENV['LPATH']['TMP'], "%s_%s" % (ts, name)) + return os.path.join(ENV['LPATH']['TMP'], "%s_%s" % (ts, 'miaz-export')) def get_temp_file(self, dir_tmp, suffix='.txt'): return tempfile.mkstemp(dir=dir_tmp, suffix=suffix) @@ -124,15 +122,10 @@ def get_fields(self, filename: str) -> []: filename = filename[:dot] return filename.split('-') - def get_files(self, root_dir: str = '') -> []: - """Get all files from a given directory. - If no directory is given, it will return files from repository - documents directory. - """ + def get_files(self, dirpath: str) -> []: + """Get all files from a given directory.""" # ~ FIXME: validate root_dir - if len(root_dir) == 0: - repo_dir = self.repository.get('dir_docs') - return glob.glob(os.path.join(repo_dir, '*')) + return glob.glob(os.path.join(dirpath, '*')) def get_files_recursively(self, root_dir: str) -> []: """Get documents from a given directory recursively @@ -162,9 +155,7 @@ def get_files_recursively(self, root_dir: str) -> []: documents.add(thisfile) return documents - def filename_get_creation_date(self, doc: str) -> datetime: - repo_dir = self.repository.get('dir_docs') - filepath = os.path.join(repo_dir, doc) + def filename_get_creation_date(self, filepath: str) -> datetime: lastmod = os.stat(filepath).st_mtime return datetime.fromtimestamp(lastmod) @@ -208,11 +199,8 @@ def valid_key(self, key: str) -> str: key = str(key).strip().replace(' ', '_') return re.sub(r'(?u)[^-\w.]', '', key) - def filename_rename(self, doc_source, doc_target) -> bool: + def filename_rename(self, source, target) -> bool: rename = False - repo_dir = self.repository.get('dir_docs') - source = os.path.join(repo_dir, doc_source) - target = os.path.join(repo_dir, doc_target) if source != target: if not os.path.exists(target): try: @@ -226,7 +214,7 @@ def filename_rename(self, doc_source, doc_target) -> bool: self.log.error(error) else: self.log.debug("Document NOT renamed:") - self.log.error("\tTarget '%s' already exist", doc_target) + self.log.error("\tTarget '%s' already exist", target) # ~ else: # ~ self.log.error("Source and Target are the same. Skip rename") return rename @@ -245,13 +233,11 @@ def filename_import(self, source: str, target: str): Normally, only the source filename would be necessary, but as it is renamed according MiAZ rules, target is also needed. """ - target = self.repository.get('dir_docs') + # ~ target = self.repository.get('dir_docs') self.filename_copy(source, target) self.emit('filename-added', target) - def filename_export(self, doc: str, target: str): - repo_dir = self.repository.get('dir_docs') - source = os.path.join(repo_dir, doc) + def filename_export(self, source: str, target: str): self.filename_copy(source, target) def filename_copy(self, source, target, overwrite=True): @@ -284,88 +270,88 @@ def filename_date_human_simple(self, value: str = '') -> str: date_dsc = None return date_dsc - def filename_display(self, doc): - filepath = self.filename_path(doc) + def filename_display(self, filepath): + # ~ filepath = self.filename_path(doc) if sys.platform in ['linux', 'linux2']: os.system("xdg-open \"%s\"" % filepath) elif sys.platform in ['win32', 'cygwin', 'msys']: os.startfile(filepath) - def filename_path(self, doc): - repo_dir = self.repository.get('dir_docs') - return os.path.join(repo_dir, doc) + # ~ def filename_path(self, doc): + # ~ repo_dir = self.repository.get('dir_docs') + # ~ return os.path.join(repo_dir, doc) def filename_validate(self, doc:str) -> bool: if len(doc.split('-')) == 7: return True return False - def filename_validate_complex(self, filepath: str) -> tuple: - filename = os.path.basename(filepath) - reasons = "OK" - valid = True - reasons = [] - - # Check fields partitioning - partitioning = False - fields = filename.split('-') - if len(fields) != 7: - source = filename - target = self.filename_normalize(filename) - if source != target: - self.filename_rename(source, target) - else: - self.log.debug("Target normalized filename is the same than source") - name, ext = self.filename_details(filename) - fields = name.split('-') - - # Check extension - item_type = Extension - gtype = Date.__gtype_name__ - dot = filename.rfind('.') - if dot > 0: - name = filename[:dot] - ext = filename[dot+1:] - message = "File extension '%s' is valid" % ext - rc = True - else: - name = filename - ext = '' - rc = False - valid &= False - message = "File extension missing. Please, check this document!" - reasons.append((rc, gtype, ext, message)) - - # Validate fields - for item_type in [Date, Country, Group, SentBy, Purpose, SentTo]: - gtype = item_type.__gtype_name__ - fn = Field[item_type] # Field number - fname = item_type.__gtype_name__ - title = _(item_type.__title__) - key = fields[fn] - value = None - if len(key) == 0: - valid &= False - rc = False - message = _('%s field is empty') % title - else: - if item_type != Date: - available = self.conf[fname].exists_available(key) - used = self.conf[fname].exists_used(key) - if available and used: - rc = True - items = self.conf[fname].load_used() - value = self.conf[fname].get(key) - if len(value) > 0: - message = _('%s %s (%s) is available and ready to use') % (fname, key, value) - else: - message = _('%s %s is available and ready to use') % (fname, key) - else: - valid &= False - rc = False - message = _('%s %s available? %s. Used? %s') % (title, key, available, used) - reasons.append((rc, gtype, value, message)) - return valid, reasons + # ~ def filename_validate_complex(self, filepath: str) -> tuple: + # ~ filename = os.path.basename(filepath) + # ~ reasons = "OK" + # ~ valid = True + # ~ reasons = [] + + # ~ # Check fields partitioning + # ~ partitioning = False + # ~ fields = filename.split('-') + # ~ if len(fields) != 7: + # ~ source = filename + # ~ target = self.filename_normalize(filename) + # ~ if source != target: + # ~ self.filename_rename(source, target) + # ~ else: + # ~ self.log.debug("Target normalized filename is the same than source") + # ~ name, ext = self.filename_details(filename) + # ~ fields = name.split('-') + + # ~ # Check extension + # ~ item_type = Extension + # ~ gtype = Date.__gtype_name__ + # ~ dot = filename.rfind('.') + # ~ if dot > 0: + # ~ name = filename[:dot] + # ~ ext = filename[dot+1:] + # ~ message = "File extension '%s' is valid" % ext + # ~ rc = True + # ~ else: + # ~ name = filename + # ~ ext = '' + # ~ rc = False + # ~ valid &= False + # ~ message = "File extension missing. Please, check this document!" + # ~ reasons.append((rc, gtype, ext, message)) + + # ~ # Validate fields + # ~ for item_type in [Date, Country, Group, SentBy, Purpose, SentTo]: + # ~ gtype = item_type.__gtype_name__ + # ~ fn = Field[item_type] # Field number + # ~ fname = item_type.__gtype_name__ + # ~ title = _(item_type.__title__) + # ~ key = fields[fn] + # ~ value = None + # ~ if len(key) == 0: + # ~ valid &= False + # ~ rc = False + # ~ message = _('%s field is empty') % title + # ~ else: + # ~ if item_type != Date: + # ~ available = self.conf[fname].exists_available(key) + # ~ used = self.conf[fname].exists_used(key) + # ~ if available and used: + # ~ rc = True + # ~ items = self.conf[fname].load_used() + # ~ value = self.conf[fname].get(key) + # ~ if len(value) > 0: + # ~ message = _('%s %s (%s) is available and ready to use') % (fname, key, value) + # ~ else: + # ~ message = _('%s %s is available and ready to use') % (fname, key) + # ~ else: + # ~ valid &= False + # ~ rc = False + # ~ message = _('%s %s available? %s. Used? %s') % (title, key, available, used) + # ~ reasons.append((rc, gtype, value, message)) + # ~ return valid, reasons def since_date_this_year(self, adate: datetime) -> datetime: year = adate.year diff --git a/MiAZ/frontend/desktop/services/actions.py b/MiAZ/frontend/desktop/services/actions.py index 8176394d..37540e3f 100644 --- a/MiAZ/frontend/desktop/services/actions.py +++ b/MiAZ/frontend/desktop/services/actions.py @@ -52,10 +52,13 @@ def __init__(self, app): self.backend = self.app.get_service('backend') self.util = self.app.get_service('util') self.factory = self.app.get_service('factory') + self.repository = self.app.get_service('repo') def document_display(self, doc): self.log.debug("Displaying %s", doc) - self.util.filename_display(doc) + repo_dir = self.repository.get('dir_docs') + filepath = os.path.join(repo_dir, doc) + self.util.filename_display(filepath) # ~ def document_open_location(self, item): # ~ self.log.debug("Open file location for %s", item.id) @@ -133,8 +136,7 @@ def dropdown_populate(self, config, dropdown, item_type, any_value=True, none_va def import_directory(self, *args): def filechooser_response(dialog, response, data): - config = self.backend.repo_config() - target_dir = config['dir_docs'] + target_dir = self.repository.get('dir_docs') if response == Gtk.ResponseType.ACCEPT: content_area = dialog.get_content_area() box = content_area.get_first_child() @@ -142,6 +144,7 @@ def filechooser_response(dialog, response, data): toggle = box.get_last_child() recursive = toggle.get_active() gfile = filechooser.get_file() + repo_dir = self.repository.get('dir_docs') if gfile is not None: dirpath = gfile.get_path() self.log.debug("Walk directory %s recursively? %s", dirpath, recursive) @@ -150,7 +153,8 @@ def filechooser_response(dialog, response, data): else: files = glob.glob(os.path.join(dirpath, '*.*')) for source in files: - target = self.util.filename_normalize(source) + btarget = self.util.filename_normalize(source) + target = os.path.join(repo_dir, btarget) self.util.filename_import(source, target) dialog.destroy() @@ -169,8 +173,7 @@ def filechooser_response(dialog, response, data): def import_config(self, *args): def filechooser_response(dialog, response, data): - config = self.backend.repo_config() - target_dir = config['dir_docs'] + target_dir = self.repository.get('dir_docs') if response == Gtk.ResponseType.ACCEPT: content_area = dialog.get_content_area() box = content_area.get_first_child() @@ -192,8 +195,7 @@ def filechooser_response(dialog, response, data): def import_file(self, *args): def filechooser_response(dialog, response, data): - config = self.backend.repo_config() - target_dir = config['dir_docs'] + repo_dir = self.repository.get('dir_docs') if response == Gtk.ResponseType.ACCEPT: content_area = dialog.get_content_area() box = content_area.get_first_child() @@ -201,7 +203,8 @@ def filechooser_response(dialog, response, data): gfile = filechooser.get_file() if gfile is not None: source = gfile.get_path() - target = self.util.filename_normalize(source) + btarget = self.util.filename_normalize(source) + target = os.path.join(repo_dir, btarget) self.util.filename_import(source, target) dialog.destroy() diff --git a/MiAZ/frontend/desktop/widgets/configview.py b/MiAZ/frontend/desktop/widgets/configview.py index 9d61d295..241b95ee 100644 --- a/MiAZ/frontend/desktop/widgets/configview.py +++ b/MiAZ/frontend/desktop/widgets/configview.py @@ -37,6 +37,7 @@ def __init__(self, app, config=None): self.app = app self.log = get_logger('MiAZConfigView') self.backend = self.app.get_service('backend') + self.repository = self.app.get_service('repo') self.conf = self.backend.get_config() self.config = self.conf[config] self.config.connect('used-updated', self.update) @@ -280,17 +281,20 @@ def calendar_day_selected(calendar, label, columnview, items): def _on_mass_action_rename_date_response(self, dialog, response, calendar): if response == Gtk.ResponseType.ACCEPT: + repo_dir = self.repository.get('dir_docs') adate = calendar.get_date() y = "%04d" % adate.get_year() m = "%02d" % adate.get_month() d = "%02d" % adate.get_day_of_month() sdate = "%s%s%s" % (y, m, d) for item in self.selected_items: - source = os.path.basename(item.id) + bsource = os.path.basename(item.id) + source = os.path.join(repo_dir, bsource) name, ext = self.util.filename_details(source) lname = name.split('-') lname[0] = sdate - target = "%s.%s" % ('-'.join(lname), ext) + btarget = "%s.%s" % ('-'.join(lname), ext) + target = os.path.join(repo_dir, btarget) self.util.filename_rename(source, target) dialog.destroy() diff --git a/MiAZ/frontend/desktop/widgets/rename.py b/MiAZ/frontend/desktop/widgets/rename.py index 69324fb2..b99e4693 100644 --- a/MiAZ/frontend/desktop/widgets/rename.py +++ b/MiAZ/frontend/desktop/widgets/rename.py @@ -39,6 +39,7 @@ def __init__(self, app) -> Gtk.Widget: self.factory = self.app.get_service('factory') self.actions = self.app.get_service('actions') self.icons = self.app.get_service('icons') + self.repository = self.app.get_service('repository') self.config = self.backend.get_config() self.util = self.app.get_service('util') self.log = get_logger('Miaz.Rename') @@ -111,11 +112,13 @@ def set_data(self, doc): self.doc = doc self.filepath = doc name, self.extension = self.util.filename_details(doc) + repo_dir = self.repository.get('dir_docs') + filepath = os.path.join(repo_dir, doc) # ~ self.extension = filepath[filepath.rfind('.')+1:] # ~ self.doc = os.path.basename(filepath) self.suggested = self.util.get_fields(self.doc) if len(self.suggested[0]) == 0: - adate = self.util.filename_get_creation_date(doc) + adate = self.util.filename_get_creation_date(filepath) self.entry_date.set_text(adate.strftime("%Y%m%d")) else: self.entry_date.set_text(self.suggested[0]) @@ -397,8 +400,11 @@ def on_rename_accept(self, *args): def on_answer_question_rename(self, dialog, response): if response == Gtk.ResponseType.ACCEPT: - source = self.get_filepath_source() - target = self.get_filepath_target() + repo_dir = self.repository.get('dir_docs') + bsource = self.get_filepath_source() + source = os.path.join(repo_dir, bsource) + btarget = self.get_filepath_target() + target = os.path.join(repo_dir, btarget) self.util.filename_rename(source, target) dialog.destroy() self.app.show_stack_page_by_name('workspace') diff --git a/MiAZ/frontend/desktop/widgets/selector.py b/MiAZ/frontend/desktop/widgets/selector.py index 5e8506ec..07b998a6 100644 --- a/MiAZ/frontend/desktop/widgets/selector.py +++ b/MiAZ/frontend/desktop/widgets/selector.py @@ -33,6 +33,7 @@ def __init__(self, app, edit=True): self.backend = self.app.get_service('backend') self.util = self.app.get_service('util') self.factory = self.app.get_service('factory') + self.repository = self.app.get_service('repository') self.log = get_logger('MiAZ.Selector') super(MiAZSelector, self).__init__(orientation=Gtk.Orientation.VERTICAL, hexpand=True, vexpand=True, spacing=0) @@ -167,11 +168,11 @@ def _on_item_used_remove(self, *args): value_used = False elif self.config.model == Project: projects = self.app.get_service('Projects') - # ~ self.projects = self.backend.projects docs = projects.docs_in_project(item_used.id) value_used = len(docs) > 0 else: - value_used = self.util.field_used(self.config.model, item_used.id) + repo_dir = self.repository.get('dir_docs') + value_used = self.util.field_used(repo_dir, self.config.model, item_used.id) if not value_used: del(items_used[item_used.id]) diff --git a/MiAZ/frontend/desktop/widgets/workspace.py b/MiAZ/frontend/desktop/widgets/workspace.py index 3540b237..5ca1ebfd 100644 --- a/MiAZ/frontend/desktop/widgets/workspace.py +++ b/MiAZ/frontend/desktop/widgets/workspace.py @@ -128,7 +128,7 @@ def _on_filename_renamed(self, util, source, target): source = os.path.basename(source) target = os.path.basename(target) lprojects = projects.assigned_to(source) - self.log.debug("%s found in these projects: %s", source, ', '.join(projects)) + self.log.debug("%s found in these projects: %s", source, ', '.join(lprojects)) for project in lprojects: srvprj.remove(project, source) srvprj.add(project, target) @@ -216,7 +216,8 @@ def _on_selection_changed(self, selection, position, n_items): item = model.get_item(pos) self.selected_items.append(item) label = self.btnDocsSel.get_child() - docs = self.util.get_files() + repo_dir = self.repository.get('dir_docs') + docs = self.util.get_files(repo_dir) # ~ self.log.debug(', '.join([item.id for item in self.selected_items])) label.set_markup("%d / %d / %d" % (len(self.selected_items), len(model), len(docs))) # ~ self.app.statusbar_message("Selected %d of %d documents in current view (total documents: %d)" % (len(self.selected_items), len(model), len(docs))) @@ -470,7 +471,8 @@ def update(self, *args): dd_prj = dropdowns[Project.__gtype_name__] filters = {} self.selected_items = [] - docs = self.util.get_files() + repo_dir = self.repository.get('dir_docs') + docs = self.util.get_files(repo_dir) sentby = self.app.get_config('SentBy') sentto = self.app.get_config('SentTo') countries = self.app.get_config('Country') @@ -586,8 +588,11 @@ def update(self, *args): self.view.select_first_item() renamed = 0 for filename in invalid: - target = self.util.filename_normalize(filename) - rename = self.util.filename_rename(filename, target) + repo_dir = self.repository.get('dir_docs') + source = os.path.join(repo_dir, filename) + btarget = self.util.filename_normalize(filename) + target = os.path.join(repo_dir, btarget) + rename = self.util.filename_rename(source, target) if rename: renamed += 1 if renamed > 0: @@ -733,7 +738,8 @@ def _on_filter_selected(self, *args): self.view.refilter() model = self.view.cv.get_model() # nº items in current view label = self.btnDocsSel.get_child() - docs = self.util.get_files() # nº total items + repo_dir = self.repository.get('dir_docs') + docs = self.util.get_files(repo_dir) # nº total items label.set_markup("%d / %d / %d" % (len(self.selected_items), len(model), len(docs))) def _on_select_all(self, *args): diff --git a/data/resources/plugins/delete.py b/data/resources/plugins/delete.py index 66f7e989..6605d796 100644 --- a/data/resources/plugins/delete.py +++ b/data/resources/plugins/delete.py @@ -54,9 +54,9 @@ def add_menuitem(self, *args): def document_delete(self, *args): def dialog_response(dialog, response, items): if response == Gtk.ResponseType.ACCEPT: - repo = self.backend.repo_config() for item in items: - filepath = os.path.join(repo['dir_docs'], item.id) + dir_docs = self.repository.get('dir_docs') + filepath = os.path.join(dir_docs, item.id) self.util.filename_delete(filepath) dialog.destroy() diff --git a/data/resources/plugins/export2dir.py b/data/resources/plugins/export2dir.py index c8526838..6cbc6e50 100644 --- a/data/resources/plugins/export2dir.py +++ b/data/resources/plugins/export2dir.py @@ -74,8 +74,7 @@ def get_pattern_paths(item): return paths def filechooser_response(dialog, response, patterns): - config = self.backend.repo_config() - target_dir = config['dir_docs'] + target_dir = self.repository.get('dir_docs') if response == Gtk.ResponseType.ACCEPT: content_area = dialog.get_content_area() box = content_area.get_first_child() @@ -83,6 +82,7 @@ def filechooser_response(dialog, response, patterns): hbox = box.get_last_child() toggle_pattern = hbox.get_first_child() gfile = filechooser.get_file() + repo_dir = self.repository.get('dir_docs') if gfile is not None: dirpath = gfile.get_path() if toggle_pattern.get_active(): @@ -97,11 +97,13 @@ def filechooser_response(dialog, response, patterns): thispath.append(paths[key]) target = os.path.join(*thispath) os.makedirs(target, exist_ok = True) - self.util.filename_export(item.id, target) + source = os.path.join(repo_dir, item.id) + self.util.filename_export(source, target) else: for item in items: + source = os.path.join(repo_dir, item.id) target = os.path.join(dirpath, os.path.basename(item.id)) - self.util.filename_export(item.id, target) + self.util.filename_export(source, target) self.util.directory_open(dirpath) dialog.destroy() diff --git a/data/resources/plugins/export2zip.py b/data/resources/plugins/export2zip.py index 620935a4..3f38eba3 100644 --- a/data/resources/plugins/export2zip.py +++ b/data/resources/plugins/export2zip.py @@ -9,6 +9,7 @@ """ import os +import shutil import tempfile from datetime import datetime from gettext import gettext as _ @@ -44,6 +45,7 @@ def do_activate(self): self.backend = self.app.get_service('backend') self.factory = self.app.get_service('factory') self.util = self.app.get_service('util') + self.repository = self.app.get_service('repo') self.workspace = API.app.get_widget('workspace') self.workspace.connect('workspace-loaded', self.add_menuitem) @@ -62,8 +64,7 @@ def export(self, *args): items = self.workspace.get_selected_items() def filechooser_response(dialog, response, patterns): - config = self.backend.repo_config() - target_dir = config['dir_docs'] + target_dir = self.repository.get('dir_docs') if response == Gtk.ResponseType.ACCEPT: content_area = dialog.get_content_area() box = content_area.get_first_child() @@ -73,8 +74,7 @@ def filechooser_response(dialog, response, patterns): gfile = filechooser.get_file() dirpath = gfile.get_path() if gfile is not None: - repo = self.backend.repo_config() - dir_doc = repo['dir_docs'] + dir_doc = self.repository.get('dir_docs') dir_zip = self.util.get_temp_dir() self.util.directory_create(dir_zip) for item in items: @@ -82,13 +82,15 @@ def filechooser_response(dialog, response, patterns): target = dir_zip self.util.filename_copy(source, target) zip_file = "%s.zip" % os.path.basename(dir_zip) - target = os.path.join(ENV['LPATH']['TMP'], zip_file) + zip_target = os.path.join(ENV['LPATH']['TMP'], zip_file) + repo_dir = self.repository.get('dir_docs') + source = zip_target + target = os.path.join(dirpath, zip_file) self.util.zip(target, dir_zip) - self.util.filename_rename(target, os.path.join(dirpath, zip_file)) - self.util.directory_remove(dir_zip) + self.util.filename_rename(source, target) + shutil.rmtree(dir_zip) self.util.directory_open(dirpath) self.log.debug(target) - dialog.destroy() self.factory = self.app.get_service('factory') diff --git a/data/resources/plugins/massrename.py b/data/resources/plugins/massrename.py index 2ca63b3b..5d99fa87 100644 --- a/data/resources/plugins/massrename.py +++ b/data/resources/plugins/massrename.py @@ -137,12 +137,15 @@ def dialog_response(dialog, response, dropdown, item_type, items): if response == Gtk.ResponseType.ACCEPT: title = _(item_type.__title__) for item in items: - source = item.id - name, ext = self.util.filename_details(source) + bsource = item.id + name, ext = self.util.filename_details(bsource) n = Field[item_type] tmpfile = name.split('-') tmpfile[n] = dropdown.get_selected_item().id - target = "%s.%s" % ('-'.join(tmpfile), ext) + btarget = "%s.%s" % ('-'.join(tmpfile), ext) + repo_dir = self.repository.get('dir_docs') + source = os.path.join(repo_dir, bsource) + target = os.path.join(repo_dir, btarget) self.util.filename_rename(source, target) dialog.destroy() @@ -154,11 +157,14 @@ def dialog_response_date(dialog, response, calendar, items): d = "%02d" % adate.get_day_of_month() sdate = "%s%s%s" % (y, m, d) for item in items: - source = os.path.basename(item.id) - name, ext = self.util.filename_details(source) + bsource = os.path.basename(item.id) + name, ext = self.util.filename_details(bsource) lname = name.split('-') lname[0] = sdate - target = "%s.%s" % ('-'.join(lname), ext) + btarget = "%s.%s" % ('-'.join(lname), ext) + repo_dir = self.repository.get('dir_docs') + source = os.path.join(repo_dir, bsource) + target = os.path.join(repo_dir, btarget) self.util.filename_rename(source, target) dialog.destroy() diff --git a/data/resources/plugins/projmgt.py b/data/resources/plugins/projmgt.py index 4b14dbaa..a7527966 100644 --- a/data/resources/plugins/projmgt.py +++ b/data/resources/plugins/projmgt.py @@ -112,8 +112,8 @@ def dialog_response(dialog, response, dropdown, items): cv.set_vexpand(True) citems = [] for item in items: - projects = ', '.join([self.projects.description(pid) for pid in self.projects.assigned_to(item.id)]) - citems.append(File(id=item.id, title="%s" % projects)) + tprojects = ', '.join([self.projects.description(pid) for pid in self.projects.assigned_to(item.id)]) + citems.append(File(id=item.id, title="%s" % tprojects)) cv.update(citems) frame.set_child(cv) hbox = self.factory.create_box_horizontal(hexpand=False, vexpand=False) @@ -148,12 +148,12 @@ def dialog_response(dialog, response, dropdown, items): self.config[i_type].connect('used-updated', self.actions.dropdown_populate, dropdown, item_type, False, False) # Get projects - projects = set() + sprojects = set() for item in items: - for project in self.backend.projects.assigned_to(item.id): - projects.add(project) + for project in self.projects.assigned_to(item.id): + sprojects.add(project) - self.actions.dropdown_populate(self.config[i_type], dropdown, Project, any_value=False, only_include=list(projects)) + self.actions.dropdown_populate(self.config[i_type], dropdown, Project, any_value=False, only_include=list(sprojects)) btnManage = self.factory.create_button('miaz-res-manage', '') btnManage.connect('clicked', self.actions.manage_resource, Configview['Project'](self.app)) label = self.factory.create_label(_('Withdraw the following documents from this project: ')) @@ -164,8 +164,8 @@ def dialog_response(dialog, response, dropdown, items): cv.set_vexpand(True) citems = [] for item in items: - projects = ', '.join([self.projects.description(pid) for pid in self.projects.assigned_to(item.id)]) - citems.append(File(id=item.id, title="%s" % projects)) + tprojects = ', '.join([self.projects.description(pid) for pid in self.projects.assigned_to(item.id)]) + citems.append(File(id=item.id, title="%s" % tprojects)) cv.update(citems) frame.set_child(cv) hbox = self.factory.create_box_horizontal(hexpand=False, vexpand=False) From c3f20f154ad332a6fca18ff54b0f94d17d3f2aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20V=C3=ADrseda?= Date: Mon, 27 May 2024 19:07:22 +0200 Subject: [PATCH 7/9] Bump to version 0.0.28 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index ae9ddff0..f025f53f 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('MiAZ', - version: '0.0.26', + version: '0.0.28', meson_version: '>= 0.61.2', default_options: [ 'warning_level=2', ], From 9f52577862aa9826d8acfdbf8d04613906ca7313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20V=C3=ADrseda?= Date: Mon, 27 May 2024 20:57:32 +0200 Subject: [PATCH 8/9] fix(Repository): load watcher service --- MiAZ/backend/repository.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MiAZ/backend/repository.py b/MiAZ/backend/repository.py index 085110b6..f34d6300 100644 --- a/MiAZ/backend/repository.py +++ b/MiAZ/backend/repository.py @@ -94,8 +94,9 @@ def load(self, path): self.config['Project'] = MiAZConfigProjects(self.backend, repo_dir_conf) self.config['Plugin'] = MiAZConfigUserPlugins(self.backend, repo_dir_conf) self.backend.add_service('Projects', MiAZProject(self.backend)) - watcher = self.backend.add_service('watcher', MiAZWatcher('source', path)) + watcher = MiAZWatcher('source', path) watcher.set_active(active=True) + self.backend.add_service('watcher', watcher) self.log.debug("Config repo loaded from: %s", repo_dir_conf) self.emit('repository-switched') From c4ed4b8b845249b487ef910fc35977cbb44e5403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20V=C3=ADrseda?= Date: Mon, 27 May 2024 20:58:02 +0200 Subject: [PATCH 9/9] fix(Plugins): add reference to repository service --- data/resources/plugins/delete.py | 1 + data/resources/plugins/export2dir.py | 1 + data/resources/plugins/massrename.py | 1 + 3 files changed, 3 insertions(+) diff --git a/data/resources/plugins/delete.py b/data/resources/plugins/delete.py index 6605d796..ec4a5f6f 100644 --- a/data/resources/plugins/delete.py +++ b/data/resources/plugins/delete.py @@ -36,6 +36,7 @@ def do_activate(self): self.factory = self.app.get_service('factory') self.config = self.backend.get_config() self.util = self.app.get_service('util') + self.repository = self.app.get_service('repo') self.workspace = API.app.get_widget('workspace') self.workspace.connect('workspace-loaded', self.add_menuitem) diff --git a/data/resources/plugins/export2dir.py b/data/resources/plugins/export2dir.py index 6cbc6e50..23355338 100644 --- a/data/resources/plugins/export2dir.py +++ b/data/resources/plugins/export2dir.py @@ -44,6 +44,7 @@ def do_activate(self): self.backend = self.app.get_service('backend') self.factory = self.app.get_service('factory') self.util = self.app.get_service('util') + self.repository = self.app.get_service('repo') self.workspace = API.app.get_widget('workspace') self.workspace.connect('workspace-loaded', self.add_menuitem) diff --git a/data/resources/plugins/massrename.py b/data/resources/plugins/massrename.py index 5d99fa87..f8ec719e 100644 --- a/data/resources/plugins/massrename.py +++ b/data/resources/plugins/massrename.py @@ -66,6 +66,7 @@ def do_activate(self): self.factory = self.app.get_service('factory') self.config = self.backend.get_config() self.util = self.app.get_service('util') + self.repository = self.app.get_service('repo') self.workspace = API.app.get_widget('workspace') self.workspace.connect('workspace-loaded', self.add_menuitem)