eric6/CondaInterface/CondaPackageDetailsWidget.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2019 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a widget and a dialog to show package details.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt5.QtCore import Qt, QDateTime
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt5.QtWidgets import QWidget, QDialog, QVBoxLayout, QDialogButtonBox
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from .Ui_CondaPackageDetailsWidget import Ui_CondaPackageDetailsWidget
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from Globals import dataString
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class CondaPackageDetailsWidget(QWidget, Ui_CondaPackageDetailsWidget):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing a widget to show package details.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 def __init__(self, details, parent=None):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Constructor
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @param details dictionary containing the package details
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @type dict
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param parent reference to the parent widget
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @type QWidget
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 super(CondaPackageDetailsWidget, self).__init__(parent)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 self.setupUi(self)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.headerLabel.setText(self.tr("<b>{0} / {1} / {2}</b>").format(
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 details["name"], details["version"], details["build"]))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 if "fn" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.filenameLabel.setText(details["fn"])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 if "size" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.sizeLabel.setText(dataString(details["size"]))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 if "channel" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.channelLabel.setText(details["channel"])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 if "url" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.urlLabel.setText(details["url"])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 if "md5" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.md5Label.setText(details["md5"])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 if "license" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.licenseLabel.setText(details["license"])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 if "subdir" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.platformLabel.setText(details["subdir"])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 elif "platform" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.platformLabel.setText(details["platform"])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 else:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.platformLabel.setText(self.tr("unknown"))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 if "depends" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.dependenciesEdit.setPlainText("\n".join(details["depends"]))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 if "timestamp" in details:
6713
84024511120e CondaPackageDetailsWidget: fixed calculation of the timestamp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
58 dt = QDateTime.fromMSecsSinceEpoch(details["timestamp"], Qt.UTC)
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.timestampLabel.setText(dt.toString("yyyy-MM-dd hh:mm:ss t"))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6713
diff changeset
61 self.resize(600, 450)
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 class CondaPackageDetailsDialog(QDialog):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 Class implementing a dialog to show package details.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 def __init__(self, details, parent=None):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 Constructor
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 @param details dictionary containing the package details
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 @type dict
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 @param parent reference to the parent widget
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 @type QWidget
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 super(CondaPackageDetailsDialog, self).__init__(parent)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.setSizeGripEnabled(True)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.__layout = QVBoxLayout(self)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.setLayout(self.__layout)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.__cw = CondaPackageDetailsWidget(details, self)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 size = self.__cw.size()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.__layout.addWidget(self.__cw)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.__buttonBox = QDialogButtonBox(self)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.__buttonBox.setStandardButtons(QDialogButtonBox.Close)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.__layout.addWidget(self.__buttonBox)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.resize(size)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.setWindowTitle(self.tr("Package Details"))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.__buttonBox.accepted.connect(self.accept)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 self.__buttonBox.rejected.connect(self.reject)

eric ide

mercurial