def on_execute(self, item, action): if item and item.category() == self.ITEMCAT_RESULT: kpu.set_clipboard(item.data_bag()) elif item and item.category() == self.ITEMCAT_RELOAD_DEFS: self.reconfigure() self.on_catalog() elif item and item.category() == self.ITEMCAT_CREATE_CUSTOM_DEFS: try: builtin_cvtdefs = os.path.join("data/", self.CVTDEF_FILE) builtin_cvtdefs_text = self.load_text_resource( builtin_cvtdefs).replace("\r\n", "\n") custom_cvtdefs = os.path.join(kp.user_config_dir(), self.CVTDEF_FILE) if os.path.exists(custom_cvtdefs): self.warn( f"Customized conversion file '{custom_cvtdefs}' already exists. It hasn't been overwritten" ) else: with open(custom_cvtdefs, "w", encoding="utf-8") as f: f.write(builtin_cvtdefs_text) f.close() kpu.explore_file(custom_cvtdefs) self.reconfigure() self.on_catalog() except Exception as exc: self.warn( f"Failed to create custom conversion definition file '{custom_cvtdefs}', {exc}" )
def on_execute(self, item, action): if action is None or action.name() == self.ACTION_FORK['name']: self.fork.openrepository(item.target()) return if action.name() == self.ACTION_SHELL['name']: self.fork.openshelltool(item.target()) return if action.name() == self.ACTION_EXPLORER['name']: kpu.explore_file(item.target()) return
def on_execute(self, item, action): path = item.target() kpu.explore_file(path)