Пример #1
0
 def open_file(self, directory, abs_path):
     abs_path = os.path.normpath(abs_path)
     rel_path = directory.get_child_rel_path(abs_path)
     if abs_path in self.files:
         self.fileActivated.emit(abs_path, rel_path)
     else:
         try:
             ws_file = WorkspaceFile(directory, rel_path, parent=self)
             FilePluginRegistry.load_model(ws_file)
             FilePluginRegistry.load_relations(ws_file, self.directories)
             self.files[abs_path] = ws_file
             self.fileOpened.emit(abs_path, rel_path)
         except Exception as e:
             log.exception("error loading path: %s", abs_path)
             self.fileLoadError.emit(abs_path, rel_path, str(e))
Пример #2
0
 def handle_export_file_action(self):
     ws_file = self.get_current_workspace_file()
     plugin = FilePluginRegistry.get_plugin(ws_file.abs_path)
     fields = plugin.data_factory.EntryFactory.fields()
     data = [it.as_dict() for it in ws_file.data.entries]
     dialog = ExportDialog.init(self, data, fields,
                                plugin.import_export.get("safe_attrs"))
     dialog.open()
Пример #3
0
 def handle_import_file_action(self):
     ws_file = self.get_current_workspace_file()
     plugin = FilePluginRegistry.get_plugin(ws_file.abs_path)
     fields = plugin.data_factory.EntryFactory.fields()
     dialog = ImportDialog.init(self,
                                fields,
                                plugin.import_export.get("safe_attrs"),
                                as_list=True)
     if dialog:
         dialog.import_accepted.connect(self.handle_import_accepted)
         dialog.open()
Пример #4
0
 def factory(cls, parent, workspace_file):
     plugin = FilePluginRegistry.get_plugin(workspace_file.abs_path)
     widget_inst = plugin.widget_factory()
     inst = cls(workspace_file, widget_inst, parent)
     return inst