Skip to content

Commit

Permalink
Update the about provenance dialog to handle the new provenance infor…
Browse files Browse the repository at this point in the history
…mation layout.
  • Loading branch information
hsorby committed Nov 8, 2023
1 parent c0c5a68 commit df72b3e
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 33 deletions.
15 changes: 10 additions & 5 deletions src/mapclient/core/provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 "<plugin-location-not-set>",
}
Expand All @@ -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():
Expand Down
40 changes: 29 additions & 11 deletions src/mapclient/view/dialogs/about/provenancedialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
47 changes: 40 additions & 7 deletions src/mapclient/view/dialogs/about/qt/provenancedialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>475</width>
<height>356</height>
<width>575</width>
<height>556</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -36,13 +36,46 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTableWidget" name="tableWidget">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
<widget class="QGroupBox" name="groupBoxMAPClient">
<property name="title">
<string>MAP Client provenance</string>
</property>
<property name="sortingEnabled">
<bool>true</bool>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QTableWidget" name="tableWidgetMAPClient">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxPlugin">
<property name="title">
<string>Plugin provenance</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QTableWidget" name="tableWidgetPlugin"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxPackage">
<property name="title">
<string>Package provenance</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QTableWidget" name="tableWidgetPackage"/>
</item>
</layout>
</widget>
</item>
</layout>
Expand Down
55 changes: 45 additions & 10 deletions src/mapclient/view/dialogs/about/ui/ui_provenancedialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
################################################################################
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit df72b3e

Please sign in to comment.