MCPcopy
hub / github.com/ciromattia/kcc / selectFileMetaEditor

Method selectFileMetaEditor

kindlecomicconverter/KCC_gui.py:663–708  ·  view source on GitHub ↗
(self, sname)

Source from the content-addressed store, hash-verified

661
662
663 def selectFileMetaEditor(self, sname):
664 files = []
665 if not sname:
666 if QApplication.keyboardModifiers() == Qt.ShiftModifier:
667 # Multi-directory selection for bulk editing ComicInfo.xml
668 dialog = QFileDialog(MW, 'Select volume directories', self.lastPath)
669 dialog.setFileMode(QFileDialog.FileMode.Directory)
670 dialog.setOption(QFileDialog.Option.ShowDirsOnly, True)
671 dialog.setOption(QFileDialog.Option.DontUseNativeDialog, True)
672
673 # Enable multi-selection in the dialog (may not work with native dialog on all platforms)
674 file_view = dialog.findChild(QListView, 'listView')
675 if file_view:
676 file_view.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
677 file_tree = dialog.findChild(QTreeView)
678 if file_tree:
679 file_tree.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
680
681 if dialog.exec():
682 selected_dirs = dialog.selectedFiles()
683 if selected_dirs:
684 files = [os.path.join(d, 'ComicInfo.xml') for d in selected_dirs]
685 self.lastPath = os.path.dirname(selected_dirs[0])
686 else:
687 if self.sevenzip:
688 fnames = QFileDialog.getOpenFileNames(MW, 'Select file(s)', self.lastPath,
689 'Comic (*.cbz *.cbr *.cb7)')
690 files = fnames[0]
691 if files:
692 self.lastPath = os.path.abspath(os.path.join(files[0], os.pardir))
693 else:
694 self.showDialog("Editor is disabled due to a lack of 7z.", 'error')
695 self.addMessage('<a href="https://github.com/ciromattia/kcc#7-zip">Install 7z (link)</a>'
696 ' to enable metadata editing.', 'warning')
697 else:
698 files = [sname]
699
700 if files:
701 try:
702 self.editor.loadData(files)
703 except Exception as err:
704 _, _, traceback = sys.exc_info()
705 self.showDialog("Failed to parse metadata!\n\n%s\n\nTraceback:\n%s"
706 % (str(err), sanitizeTrace(traceback)), 'error')
707 else:
708 self.editor.ui.exec_()
709
710 def clearJobs(self):
711 GUI.jobList.clear()

Callers 1

editSourceMetadataMethod · 0.95

Calls 4

showDialogMethod · 0.95
addMessageMethod · 0.95
sanitizeTraceFunction · 0.85
loadDataMethod · 0.80

Tested by

no test coverage detected