|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2019 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the conda information dialog. |
|
8 """ |
|
9 |
|
10 from PyQt6.QtCore import Qt |
|
11 from PyQt6.QtWidgets import QDialog |
|
12 |
|
13 from .Ui_CondaInfoDialog import Ui_CondaInfoDialog |
|
14 |
|
15 import UI.PixmapCache |
|
16 |
|
17 |
|
18 class CondaInfoDialog(QDialog, Ui_CondaInfoDialog): |
|
19 """ |
|
20 Class implementing the conda information dialog. |
|
21 """ |
|
22 def __init__(self, infoDict, parent=None): |
|
23 """ |
|
24 Constructor |
|
25 |
|
26 @param infoDict dictionary containing the information to be shown |
|
27 @type dict |
|
28 @param parent reference to the parent widget |
|
29 @type QWidget |
|
30 """ |
|
31 super().__init__(parent) |
|
32 self.setupUi(self) |
|
33 self.setWindowFlags(Qt.WindowType.Window) |
|
34 |
|
35 self.iconLabel.setPixmap( |
|
36 UI.PixmapCache.getPixmap("miniconda48")) |
|
37 |
|
38 # version information |
|
39 if "conda_version" in infoDict: |
|
40 self.condaVersionLabel.setText( |
|
41 infoDict["conda_version"]) |
|
42 if "conda_build_version" in infoDict: |
|
43 self.condaBuildVersionLabel.setText( |
|
44 infoDict["conda_build_version"]) |
|
45 if "conda_env_version" in infoDict: |
|
46 self.condaEnvVersionLabel.setText( |
|
47 infoDict["conda_env_version"]) |
|
48 if "python_version" in infoDict: |
|
49 self.pythonVersionLabel.setText( |
|
50 infoDict["python_version"]) |
|
51 |
|
52 # prefixes |
|
53 if "active_prefix" in infoDict or "active_prefix_name" in infoDict: |
|
54 if infoDict["active_prefix_name"] and infoDict["active_prefix"]: |
|
55 self.activeEnvironmentEdit.setText( |
|
56 "{0} ({1})".format(infoDict["active_prefix_name"], |
|
57 infoDict["active_prefix"])) |
|
58 elif infoDict["active_prefix"]: |
|
59 self.activeEnvironmentEdit.setText( |
|
60 infoDict["active_prefix"]) |
|
61 elif infoDict["active_prefix_name"]: |
|
62 self.activeEnvironmentEdit.setText( |
|
63 infoDict["active_prefix_name"]) |
|
64 else: |
|
65 self.activeEnvironmentEdit.setText( |
|
66 self.tr("None")) |
|
67 else: |
|
68 self.activeEnvironmentLabel.hide() |
|
69 self.activeEnvironmentEdit.hide() |
|
70 if "root_prefix" in infoDict: |
|
71 if "root_writable" in infoDict and infoDict["root_writable"]: |
|
72 self.baseEnvironmentEdit.setText( |
|
73 self.tr("{0} (writable)").format(infoDict["root_prefix"])) |
|
74 else: |
|
75 self.baseEnvironmentEdit.setText( |
|
76 infoDict["root_prefix"]) |
|
77 if "envs_dirs" in infoDict: |
|
78 self.envDirsEdit.setPlainText( |
|
79 "\n".join(infoDict["envs_dirs"])) |
|
80 |
|
81 # configurations |
|
82 if "rc_path" in infoDict: |
|
83 self.userConfigEdit.setText( |
|
84 infoDict["rc_path"]) |
|
85 if "user_rc_path" in infoDict: |
|
86 # overwrite with more specific info |
|
87 self.userConfigEdit.setText( |
|
88 infoDict["user_rc_path"]) |
|
89 if "sys_rc_path" in infoDict: |
|
90 self.systemConfigEdit.setText( |
|
91 infoDict["sys_rc_path"]) |
|
92 if "config_files" in infoDict: |
|
93 self.configurationsEdit.setPlainText( |
|
94 "\n".join(infoDict["config_files"])) |
|
95 else: |
|
96 self.configurationsLabel.hide() |
|
97 self.configurationsEdit.hide() |
|
98 |
|
99 # channels |
|
100 if "channels" in infoDict: |
|
101 self.channelsEdit.setPlainText( |
|
102 "\n".join(infoDict["channels"])) |
|
103 |
|
104 # various |
|
105 if "pkgs_dirs" in infoDict: |
|
106 self.cachesEdit.setPlainText( |
|
107 "\n".join(infoDict["pkgs_dirs"])) |
|
108 if "platform" in infoDict: |
|
109 self.platformLabel.setText( |
|
110 infoDict["platform"]) |
|
111 if "user_agent" in infoDict: |
|
112 self.useragentEdit.setText( |
|
113 infoDict["user_agent"]) |
|
114 else: |
|
115 self.useragentLabel.hide() |
|
116 self.useragentEdit.hide() |
|
117 if "UID" in infoDict and "GID" in infoDict: |
|
118 self.uidGidDataLabel.setText( |
|
119 "{0}:{1}".format(infoDict["UID"], infoDict["GID"])) |
|
120 else: |
|
121 self.uidGidLabel.hide() |
|
122 self.uidGidDataLabel.hide() |
|
123 if "netrc_file" in infoDict: |
|
124 if infoDict["netrc_file"]: |
|
125 self.netrcEdit.setText( |
|
126 infoDict["netrc_file"]) |
|
127 else: |
|
128 self.netrcEdit.setText( |
|
129 self.tr("None")) |
|
130 else: |
|
131 self.netrcLabel.hide() |
|
132 self.netrcEdit.hide() |
|
133 if "offline" in infoDict: |
|
134 self.offlineCheckBox.setChecked( |
|
135 infoDict["offline"]) |