11 import os |
11 import os |
12 |
12 |
13 from PyQt6.QtCore import QDir, pyqtSlot |
13 from PyQt6.QtCore import QDir, pyqtSlot |
14 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
14 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
15 |
15 |
|
16 from EricWidgets import EricMessageBox |
16 from EricWidgets.EricApplication import ericApp |
17 from EricWidgets.EricApplication import ericApp |
17 from EricWidgets.EricPathPicker import EricPathPickerModes |
18 from EricWidgets.EricPathPicker import EricPathPickerModes |
18 |
19 |
19 from .Ui_PropertiesDialog import Ui_PropertiesDialog |
20 from .Ui_PropertiesDialog import Ui_PropertiesDialog |
20 |
21 |
86 ) |
87 ) |
87 self.__initPaths = [ |
88 self.__initPaths = [ |
88 Utilities.fromNativeSeparators(ipath), |
89 Utilities.fromNativeSeparators(ipath), |
89 Utilities.fromNativeSeparators(ipath) + "/", |
90 Utilities.fromNativeSeparators(ipath) + "/", |
90 ] |
91 ] |
|
92 |
|
93 self.__populateLicenseComboBox() |
91 |
94 |
92 if not new: |
95 if not new: |
93 name = os.path.splitext(self.project.pfile)[0] |
96 name = os.path.splitext(self.project.pfile)[0] |
94 self.nameEdit.setText(os.path.basename(name)) |
97 self.nameEdit.setText(os.path.basename(name)) |
95 self.languageComboBox.setCurrentIndex( |
98 self.languageComboBox.setCurrentIndex( |
138 self.docstringStyleComboBox.setCurrentIndex(cindex) |
141 self.docstringStyleComboBox.setCurrentIndex(cindex) |
139 with contextlib.suppress(KeyError): |
142 with contextlib.suppress(KeyError): |
140 cindex = self.testingFrameworkComboBox.findData( |
143 cindex = self.testingFrameworkComboBox.findData( |
141 self.project.pdata["TESTING_FRAMEWORK"]) |
144 self.project.pdata["TESTING_FRAMEWORK"]) |
142 self.testingFrameworkComboBox.setCurrentIndex(cindex) |
145 self.testingFrameworkComboBox.setCurrentIndex(cindex) |
|
146 with contextlib.suppress(KeyError): |
|
147 self.licenseComboBox.setCurrentText( |
|
148 self.project.pdata["LICENSE"]) |
143 else: |
149 else: |
144 self.languageComboBox.setCurrentIndex( |
150 self.languageComboBox.setCurrentText("Python3") |
145 self.languageComboBox.findText("Python3")) |
|
146 self.projectTypeComboBox.setCurrentIndex( |
151 self.projectTypeComboBox.setCurrentIndex( |
147 self.projectTypeComboBox.findData("PyQt6")) |
152 self.projectTypeComboBox.findData("PyQt6")) |
148 self.dirPicker.setText(self.__initPaths[0]) |
153 self.dirPicker.setText(self.__initPaths[0]) |
149 self.versionEdit.setText('0.1') |
154 self.versionEdit.setText('0.1') |
150 self.vcsLabel.hide() |
155 self.vcsLabel.hide() |
153 self.vcsCheckBox.hide() |
158 self.vcsCheckBox.hide() |
154 |
159 |
155 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
160 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
156 bool(self.dirPicker.text()) and |
161 bool(self.dirPicker.text()) and |
157 self.dirPicker.text() not in self.__initPaths) |
162 self.dirPicker.text() not in self.__initPaths) |
|
163 |
|
164 def __populateLicenseComboBox(self): |
|
165 """ |
|
166 Private method to populate the license selector with the list of trove |
|
167 license types. |
|
168 |
|
169 Note: The trove licanese list file was created from querying |
|
170 "https://pypi.org/pypi?%3Aaction=list_classifiers". |
|
171 """ |
|
172 filename = os.path.join( |
|
173 os.path.dirname(__file__), "..", "data", |
|
174 "trove_license_classifiers.txt") |
|
175 try: |
|
176 with open(filename, "r") as f: |
|
177 lines = f.readlines() |
|
178 except OSError as err: |
|
179 EricMessageBox.warning( |
|
180 self, |
|
181 self.tr("Reading Trove License Classifiers"), |
|
182 self.tr("""<p>The Trove Classifiers file <b>{0}</b>""" |
|
183 """ could not be read.</p><p>Reason: {1}</p>""") |
|
184 .format(filename, str(err))) |
|
185 return |
|
186 |
|
187 self.licenseComboBox.addItem("") |
|
188 self.licenseComboBox.addItems( |
|
189 line.split("::")[-1].strip() |
|
190 for line in lines |
|
191 if line.startswith("License ") # play it safe |
|
192 ) |
158 |
193 |
159 @pyqtSlot(str) |
194 @pyqtSlot(str) |
160 def on_languageComboBox_currentTextChanged(self, language): |
195 def on_languageComboBox_currentTextChanged(self, language): |
161 """ |
196 """ |
162 Private slot handling the selection of a programming language. |
197 Private slot handling the selection of a programming language. |