Sun, 24 Dec 2023 19:49:52 +0100
Corrected some source code documentation issues.
9078 | 1 | # -*- coding: utf-8 -*- |
2 | ||
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
3 | # Copyright (c) 2022 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
9078 | 4 | # |
5 | ||
6 | """ | |
7 | Module implementing a dialog to enter the parameters for a coverage JSON | |
8 | report. | |
9 | """ | |
10 | ||
11 | import os | |
12 | ||
13 | from PyQt6.QtCore import pyqtSlot | |
14 | from PyQt6.QtWidgets import QDialog, QDialogButtonBox | |
15 | ||
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
16 | from eric7.EricWidgets.EricPathPicker import EricPathPickerModes |
9078 | 17 | |
18 | from .Ui_PyCoverageJsonReportDialog import Ui_PyCoverageJsonReportDialog | |
19 | ||
20 | ||
21 | class PyCoverageJsonReportDialog(QDialog, Ui_PyCoverageJsonReportDialog): | |
22 | """ | |
23 | Class implementing a dialog to enter the parameters for a coverage JSON | |
24 | report. | |
25 | """ | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
26 | |
9078 | 27 | def __init__(self, defaultDirectory, parent=None): |
28 | """ | |
29 | Constructor | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
30 | |
9078 | 31 | @param defaultDirectory default directory for selecting the output |
32 | directory | |
33 | @type str | |
34 | @param parent reference to the parent widget (defaults to None) | |
35 | @type QWidget (optional) | |
36 | """ | |
37 | super().__init__(parent) | |
38 | self.setupUi(self) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
39 | |
9078 | 40 | self.outputFilePicker.setMode( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
41 | EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | ) |
9078 | 43 | self.outputFilePicker.setDefaultDirectory(defaultDirectory) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
44 | self.outputFilePicker.setFilters(self.tr("JSON Files (*.json);;All Files (*)")) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
45 | self.outputFilePicker.setText(os.path.join(defaultDirectory, "coverage.json")) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
46 | |
9078 | 47 | msh = self.minimumSizeHint() |
48 | self.resize(max(self.width(), msh.width()), msh.height()) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
49 | |
9078 | 50 | @pyqtSlot(str) |
51 | def on_outputFilePicker_textChanged(self, filename): | |
52 | """ | |
53 | Private slot handling a change of the output file. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
54 | |
9078 | 55 | @param filename current text of the file picker |
56 | @type str | |
57 | """ | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
58 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
59 | bool(filename) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
60 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
61 | |
9078 | 62 | def getData(self): |
63 | """ | |
64 | Public method to get the entered data. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
65 | |
9078 | 66 | @return tuple containing the output file and a flag indicating the |
67 | creation of a compact JSON file | |
68 | @rtype tuple of (str, bool) | |
69 | """ | |
70 | return ( | |
71 | self.outputFilePicker.currentText(), | |
72 | self.compactCheckBox.isChecked(), | |
73 | ) |