diff --git a/src/mapclient/core/provenance.py b/src/mapclient/core/provenance.py index c3270817..125d223b 100644 --- a/src/mapclient/core/provenance.py +++ b/src/mapclient/core/provenance.py @@ -30,7 +30,7 @@ def _strip_pip_list_output(output_stream): else: output[parts[0]]['location'] = parts[2] else: - output[parts[0]]['location'] = 'pypi' + output[parts[0]]['location'] = 'PyPI' return output @@ -80,14 +80,16 @@ def _determine_capabilities(): package_info = _strip_pip_list_output(result.stdout) - mapclientplugins_info = {} + plugin_names = [] + mapclient_plugins_info = {} if mapclientplugins_present: for loader, module_name, is_pkg in pkgutil.walk_packages(mapclientplugins.__path__): if is_pkg: package_name = PLUGINS_PACKAGE_NAME + '.' + module_name try: + plugin_names.append(package_name) module = import_module(package_name) - mapclientplugins_info[package_name] = { + mapclient_plugins_info[package_name] = { "version": module.__version__ if hasattr(module, '__version__') else "X.Y.Z", "location": module.__location__ if hasattr(module, '__location__') else "", } @@ -99,9 +101,12 @@ def _determine_capabilities(): mapclient_info = {'version': 'unknown', 'location': 'unknown'} if 'mapclient' in package_info: mapclient_info = package_info['mapclient'] - del package_info['mapclient'] - return {'version': '0.1.0', 'id': 'map-client-provenance-record', 'mapclient': mapclient_info, 'plugins': mapclientplugins_info, 'packages': package_info} + for key in ['mapclient'] + plugin_names: + if key in package_info: + del package_info[key] + + return {'version': '0.1.0', 'id': 'map-client-provenance-record', 'mapclient': mapclient_info, 'plugins': mapclient_plugins_info, 'packages': package_info} def reproducibility_info(): diff --git a/src/mapclient/view/dialogs/about/provenancedialog.py b/src/mapclient/view/dialogs/about/provenancedialog.py index d4f1bf63..2028820d 100644 --- a/src/mapclient/view/dialogs/about/provenancedialog.py +++ b/src/mapclient/view/dialogs/about/provenancedialog.py @@ -34,18 +34,36 @@ def __init__(self, parent=None): self._ui.setupUi(self) info = reproducibility_info() - headers = ["Package", "Version", "Location"] - self._ui.tableWidget.setColumnCount(len(headers)) - self._ui.tableWidget.setRowCount(len(info)) + self._headers = ["Package", "Version", "Location"] + print(list(info.keys())) + for key in info.keys(): + if key == 'mapclient': + table = self._ui.tableWidgetMAPClient + content = {'mapclient': info[key]} + elif key == 'plugins': + table = self._ui.tableWidgetPlugin + content = info[key] + elif key == 'packages': + table = self._ui.tableWidgetPackage + content = info[key] + else: + continue - self._ui.tableWidget.setHorizontalHeaderLabels(headers) + self._add_table_content(table, content) - for row, i in enumerate(info): + def _add_table_content(self, table, content): + table.setColumnCount(len(self._headers)) + table.setRowCount(len(content)) + table.verticalHeader().setVisible(False) + + table.setHorizontalHeaderLabels(self._headers) + + for row, i in enumerate(content): item_1 = QTableWidgetItem(i) - item_2 = QTableWidgetItem(info[i]["version"]) - item_3 = QTableWidgetItem(info[i]["location"]) - self._ui.tableWidget.setItem(row, 0, item_1) - self._ui.tableWidget.setItem(row, 1, item_2) - self._ui.tableWidget.setItem(row, 2, item_3) + item_2 = QTableWidgetItem(content[i]["version"]) + item_3 = QTableWidgetItem(content[i]["location"]) + table.setItem(row, 0, item_1) + table.setItem(row, 1, item_2) + table.setItem(row, 2, item_3) - self._ui.tableWidget.resizeColumnsToContents() + table.resizeColumnsToContents() diff --git a/src/mapclient/view/dialogs/about/qt/provenancedialog.ui b/src/mapclient/view/dialogs/about/qt/provenancedialog.ui index 59053a39..45a8321a 100644 --- a/src/mapclient/view/dialogs/about/qt/provenancedialog.ui +++ b/src/mapclient/view/dialogs/about/qt/provenancedialog.ui @@ -6,8 +6,8 @@ 0 0 - 475 - 356 + 575 + 556 @@ -36,13 +36,46 @@ - - - QAbstractItemView::NoEditTriggers + + + MAP Client provenance - - true + + + + + QAbstractItemView::NoEditTriggers + + + true + + + + + + + + + + Plugin provenance + + + + + + + + + + + + Package provenance + + + + + diff --git a/src/mapclient/view/dialogs/about/ui/ui_provenancedialog.py b/src/mapclient/view/dialogs/about/ui/ui_provenancedialog.py index ab75afb8..a852507e 100644 --- a/src/mapclient/view/dialogs/about/ui/ui_provenancedialog.py +++ b/src/mapclient/view/dialogs/about/ui/ui_provenancedialog.py @@ -3,7 +3,7 @@ ################################################################################ ## Form generated from reading UI file 'provenancedialog.ui' ## -## Created by: Qt User Interface Compiler version 6.4.1 +## Created by: Qt User Interface Compiler version 6.5.2 ## ## WARNING! All changes made in this file will be lost when recompiling UI file! ################################################################################ @@ -15,15 +15,16 @@ QFont, QFontDatabase, QGradient, QIcon, QImage, QKeySequence, QLinearGradient, QPainter, QPalette, QPixmap, QRadialGradient, QTransform) -from PySide6.QtWidgets import (QAbstractItemView, QApplication, QFrame, QHBoxLayout, - QHeaderView, QPushButton, QSizePolicy, QSpacerItem, - QTableWidget, QTableWidgetItem, QVBoxLayout, QWidget) +from PySide6.QtWidgets import (QAbstractItemView, QApplication, QFrame, QGroupBox, + QHBoxLayout, QHeaderView, QPushButton, QSizePolicy, + QSpacerItem, QTableWidget, QTableWidgetItem, QVBoxLayout, + QWidget) class Ui_ProvenanceDialog(object): def setupUi(self, ProvenanceDialog): if not ProvenanceDialog.objectName(): ProvenanceDialog.setObjectName(u"ProvenanceDialog") - ProvenanceDialog.resize(475, 356) + ProvenanceDialog.resize(575, 556) self.verticalLayout = QVBoxLayout(ProvenanceDialog) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(0, 0, 0, 0) @@ -33,12 +34,43 @@ def setupUi(self, ProvenanceDialog): self.frame_2.setFrameShadow(QFrame.Raised) self.verticalLayout_2 = QVBoxLayout(self.frame_2) self.verticalLayout_2.setObjectName(u"verticalLayout_2") - self.tableWidget = QTableWidget(self.frame_2) - self.tableWidget.setObjectName(u"tableWidget") - self.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers) - self.tableWidget.setSortingEnabled(True) + self.groupBoxMAPClient = QGroupBox(self.frame_2) + self.groupBoxMAPClient.setObjectName(u"groupBoxMAPClient") + self.verticalLayout_3 = QVBoxLayout(self.groupBoxMAPClient) + self.verticalLayout_3.setObjectName(u"verticalLayout_3") + self.tableWidgetMAPClient = QTableWidget(self.groupBoxMAPClient) + self.tableWidgetMAPClient.setObjectName(u"tableWidgetMAPClient") + self.tableWidgetMAPClient.setEditTriggers(QAbstractItemView.NoEditTriggers) + self.tableWidgetMAPClient.setSortingEnabled(True) - self.verticalLayout_2.addWidget(self.tableWidget) + self.verticalLayout_3.addWidget(self.tableWidgetMAPClient) + + + self.verticalLayout_2.addWidget(self.groupBoxMAPClient) + + self.groupBoxPlugin = QGroupBox(self.frame_2) + self.groupBoxPlugin.setObjectName(u"groupBoxPlugin") + self.verticalLayout_4 = QVBoxLayout(self.groupBoxPlugin) + self.verticalLayout_4.setObjectName(u"verticalLayout_4") + self.tableWidgetPlugin = QTableWidget(self.groupBoxPlugin) + self.tableWidgetPlugin.setObjectName(u"tableWidgetPlugin") + + self.verticalLayout_4.addWidget(self.tableWidgetPlugin) + + + self.verticalLayout_2.addWidget(self.groupBoxPlugin) + + self.groupBoxPackage = QGroupBox(self.frame_2) + self.groupBoxPackage.setObjectName(u"groupBoxPackage") + self.verticalLayout_5 = QVBoxLayout(self.groupBoxPackage) + self.verticalLayout_5.setObjectName(u"verticalLayout_5") + self.tableWidgetPackage = QTableWidget(self.groupBoxPackage) + self.tableWidgetPackage.setObjectName(u"tableWidgetPackage") + + self.verticalLayout_5.addWidget(self.tableWidgetPackage) + + + self.verticalLayout_2.addWidget(self.groupBoxPackage) self.verticalLayout.addWidget(self.frame_2) @@ -70,6 +102,9 @@ def setupUi(self, ProvenanceDialog): def retranslateUi(self, ProvenanceDialog): ProvenanceDialog.setWindowTitle(QCoreApplication.translate("ProvenanceDialog", u"MAP Client Provenance", None)) + self.groupBoxMAPClient.setTitle(QCoreApplication.translate("ProvenanceDialog", u"MAP Client provenance", None)) + self.groupBoxPlugin.setTitle(QCoreApplication.translate("ProvenanceDialog", u"Plugin provenance", None)) + self.groupBoxPackage.setTitle(QCoreApplication.translate("ProvenanceDialog", u"Package provenance", None)) self.btn_Close.setText(QCoreApplication.translate("ProvenanceDialog", u"&Close", None)) # retranslateUi