Sat, 23 Dec 2023 15:48:12 +0100
Updated copyright for 2024.
9214 | 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> |
9214 | 4 | # |
5 | ||
6 | """ | |
7 | Module implementing a dialog to enter the parameters for a Black formatting run. | |
8 | """ | |
9 | ||
10 | import contextlib | |
11 | import copy | |
12 | import pathlib | |
13 | ||
14 | import black | |
15 | import tomlkit | |
16 | ||
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
17 | from PyQt6.QtCore import Qt, pyqtSlot |
9214 | 18 | from PyQt6.QtGui import QFontMetricsF, QGuiApplication |
19 | from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QListWidgetItem | |
20 | ||
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:
9343
diff
changeset
|
21 | from eric7.EricWidgets import EricMessageBox |
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:
9343
diff
changeset
|
22 | from eric7.EricWidgets.EricApplication import ericApp |
9214 | 23 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
24 | from . import BlackUtilities |
9214 | 25 | from .Ui_BlackConfigurationDialog import Ui_BlackConfigurationDialog |
26 | ||
27 | ||
28 | class BlackConfigurationDialog(QDialog, Ui_BlackConfigurationDialog): | |
29 | """ | |
30 | Class implementing a dialog to enter the parameters for a Black formatting run. | |
31 | """ | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
32 | |
9337
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
33 | def __init__(self, withProject=True, onlyProject=False, parent=None): |
9214 | 34 | """ |
35 | Constructor | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
36 | |
9214 | 37 | @param withProject flag indicating to look for project configurations |
38 | (defaults to True) | |
9337
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
39 | @type bool (optional) |
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
40 | @param onlyProject flag indicating to only look for project configurations |
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
41 | (defaults to False) |
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
42 | @type bool (optional) |
9214 | 43 | @param parent reference to the parent widget (defaults to None) |
44 | @type QWidget (optional) | |
45 | """ | |
46 | super().__init__(parent) | |
47 | self.setupUi(self) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
48 | |
9337
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
49 | self.__project = ( |
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
50 | ericApp().getObject("Project") if (withProject or onlyProject) else None |
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
51 | ) |
9342
07a037ce923a
Optimized the 'Black' configuration dialog a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9341
diff
changeset
|
52 | self.__onlyProject = onlyProject |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
53 | |
9214 | 54 | indentTabWidth = ( |
55 | QFontMetricsF(self.excludeEdit.font()).horizontalAdvance(" ") * 2 | |
56 | ) | |
57 | self.excludeEdit.document().setIndentWidth(indentTabWidth) | |
58 | self.excludeEdit.setTabStopDistance(indentTabWidth) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
59 | |
9214 | 60 | self.__pyprojectData = {} |
61 | self.__projectData = {} | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
62 | |
9214 | 63 | self.__tomlButton = self.buttonBox.addButton( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
64 | self.tr("Generate TOML"), QDialogButtonBox.ButtonRole.ActionRole |
9214 | 65 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
66 | self.__tomlButton.setToolTip( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
67 | self.tr("Place a code snippet for 'pyproject.toml' into the clipboard.") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
68 | ) |
9214 | 69 | self.__tomlButton.clicked.connect(self.__createTomlSnippet) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
70 | |
9214 | 71 | # setup the source combobox |
72 | self.sourceComboBox.addItem("", "") | |
73 | if self.__project: | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
74 | pyprojectPath = ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
75 | pathlib.Path(self.__project.getProjectPath()) / "pyproject.toml" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
76 | ) |
9214 | 77 | if pyprojectPath.exists(): |
78 | with contextlib.suppress(tomlkit.exceptions.ParseError, OSError): | |
79 | with pyprojectPath.open("r", encoding="utf-8") as f: | |
80 | data = tomlkit.load(f) | |
81 | config = data.get("tool", {}).get("black", {}) | |
82 | if config: | |
83 | self.__pyprojectData = { | |
9222
e384c0e986be
Fixed a bug in the Black configuration dialog causing 'pyproject.toml' values being handled incorrectly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
84 | k.replace("--", ""): v for k, v in config.items() |
9214 | 85 | } |
86 | self.sourceComboBox.addItem("pyproject.toml", "pyproject") | |
87 | if self.__project.getData("OTHERTOOLSPARMS", "Black") is not None: | |
88 | self.__projectData = copy.deepcopy( | |
89 | self.__project.getData("OTHERTOOLSPARMS", "Black") | |
90 | ) | |
91 | self.sourceComboBox.addItem(self.tr("Project File"), "project") | |
9342
07a037ce923a
Optimized the 'Black' configuration dialog a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9341
diff
changeset
|
92 | elif onlyProject: |
07a037ce923a
Optimized the 'Black' configuration dialog a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9341
diff
changeset
|
93 | self.sourceComboBox.addItem(self.tr("Project File"), "project") |
9337
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
94 | if not onlyProject: |
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
95 | self.sourceComboBox.addItem(self.tr("Defaults"), "default") |
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
96 | self.sourceComboBox.addItem(self.tr("Configuration Below"), "dialog") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
97 | |
9214 | 98 | self.__populateTargetVersionsList() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
99 | |
9214 | 100 | if self.__projectData: |
101 | source = self.__projectData.get("source", "") | |
102 | self.sourceComboBox.setCurrentIndex(self.sourceComboBox.findData(source)) | |
9342
07a037ce923a
Optimized the 'Black' configuration dialog a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9341
diff
changeset
|
103 | elif onlyProject: |
07a037ce923a
Optimized the 'Black' configuration dialog a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9341
diff
changeset
|
104 | self.sourceComboBox.setCurrentIndex(self.sourceComboBox.findData("project")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
105 | |
9214 | 106 | def __populateTargetVersionsList(self): |
107 | """ | |
108 | Private method to populate the target versions list widget with checkable | |
109 | Python version entries. | |
110 | """ | |
111 | targets = [ | |
112 | (int(t[2]), int(t[3:]), t) | |
113 | for t in dir(black.TargetVersion) | |
114 | if t.startswith("PY") | |
115 | ] | |
9341
3dc887a49403
Improved the display of the 'Target Versions' list of the 'Black' configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9337
diff
changeset
|
116 | for target in sorted(targets, reverse=True): |
9214 | 117 | itm = QListWidgetItem( |
118 | "Python {0}.{1}".format(target[0], target[1]), self.targetVersionsList | |
119 | ) | |
120 | itm.setData(Qt.ItemDataRole.UserRole, target[2]) | |
121 | itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable) | |
122 | itm.setCheckState(Qt.CheckState.Unchecked) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
123 | |
9214 | 124 | def __loadConfiguration(self, configurationDict): |
125 | """ | |
126 | Private method to load the configuration section with data of the given | |
127 | dictionary. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
128 | |
9214 | 129 | @param configurationDict reference to the data to be loaded |
130 | @type dict | |
131 | """ | |
132 | confDict = copy.deepcopy(BlackUtilities.getDefaultConfiguration()) | |
133 | confDict.update(configurationDict) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
134 | |
9214 | 135 | self.lineLengthSpinBox.setValue(int(confDict["line-length"])) |
136 | self.skipStringNormalCheckBox.setChecked(confDict["skip-string-normalization"]) | |
137 | self.skipMagicCommaCheckBox.setChecked(confDict["skip-magic-trailing-comma"]) | |
138 | self.excludeEdit.setPlainText(confDict["extend-exclude"]) | |
139 | for row in range(self.targetVersionsList.count()): | |
140 | itm = self.targetVersionsList.item(row) | |
141 | itm.setCheckState( | |
142 | Qt.CheckState.Checked | |
143 | if itm.data(Qt.ItemDataRole.UserRole).lower() | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
144 | in confDict["target-version"] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
145 | else Qt.CheckState.Unchecked |
9214 | 146 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
147 | |
9214 | 148 | @pyqtSlot(str) |
149 | def on_sourceComboBox_currentTextChanged(self, selection): | |
150 | """ | |
151 | Private slot to handle the selection of a configuration source. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
152 | |
9214 | 153 | @param selection text of the currently selected item |
154 | @type str | |
155 | """ | |
156 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( | |
9342
07a037ce923a
Optimized the 'Black' configuration dialog a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9341
diff
changeset
|
157 | bool(selection) or self.__onlyProject |
9214 | 158 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
159 | |
9214 | 160 | source = self.sourceComboBox.currentData() |
161 | if source == "pyproject": | |
162 | self.__loadConfiguration(self.__pyprojectData) | |
163 | elif source == "project": | |
164 | self.__loadConfiguration(self.__projectData) | |
165 | elif source == "default": | |
166 | self.__loadConfiguration(BlackUtilities.getDefaultConfiguration()) | |
167 | elif source == "dialog": | |
168 | # just leave the current entries | |
169 | pass | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
170 | |
9214 | 171 | @pyqtSlot() |
172 | def on_excludeEdit_textChanged(self): | |
173 | """ | |
174 | Private slot to enable the validate button depending on the exclude text. | |
175 | """ | |
176 | self.validateButton.setEnabled(bool(self.excludeEdit.toPlainText())) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
177 | |
9214 | 178 | @pyqtSlot() |
179 | def on_validateButton_clicked(self): | |
180 | """ | |
181 | Private slot to validate the entered exclusion regular expression. | |
182 | """ | |
183 | regexp = self.excludeEdit.toPlainText() | |
184 | valid, error = BlackUtilities.validateRegExp(regexp) | |
185 | if valid: | |
186 | EricMessageBox.information( | |
187 | self, | |
188 | self.tr("Validation"), | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
189 | self.tr("""The exclusion expression is valid."""), |
9214 | 190 | ) |
191 | else: | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
192 | EricMessageBox.critical(self, self.tr("Validation Error"), error) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
193 | |
9214 | 194 | def __getTargetList(self): |
195 | """ | |
196 | Private method to get the list of checked target versions. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
197 | |
9214 | 198 | @return list of target versions |
199 | @rtype list of str | |
200 | """ | |
201 | targets = [] | |
202 | for row in range(self.targetVersionsList.count()): | |
203 | itm = self.targetVersionsList.item(row) | |
204 | if itm.checkState() == Qt.CheckState.Checked: | |
205 | targets.append(itm.data(Qt.ItemDataRole.UserRole).lower()) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
206 | |
9214 | 207 | return targets |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
208 | |
9214 | 209 | @pyqtSlot() |
210 | def __createTomlSnippet(self): | |
211 | """ | |
212 | Private slot to generate a TOML snippet of the current configuration. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
213 | |
9214 | 214 | Note: Only non-default values are included in this snippet. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
215 | |
9214 | 216 | The code snippet is copied to the clipboard and may be placed inside the |
217 | 'pyproject.toml' file. | |
218 | """ | |
219 | doc = tomlkit.document() | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
220 | |
9214 | 221 | black = tomlkit.table() |
222 | targetList = self.__getTargetList() | |
223 | if targetList: | |
224 | black["target-version"] = targetList | |
225 | black["line-length"] = self.lineLengthSpinBox.value() | |
226 | if self.skipStringNormalCheckBox.isChecked(): | |
227 | black["skip-string-normalization"] = True | |
228 | if self.skipMagicCommaCheckBox.isChecked(): | |
229 | black["skip-magic-trailing-comma"] = True | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
230 | |
9214 | 231 | excludeRegexp = self.excludeEdit.toPlainText() |
232 | if excludeRegexp and BlackUtilities.validateRegExp(excludeRegexp)[0]: | |
233 | black["extend-exclude"] = tomlkit.string( | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
234 | "\n{0}\n".format(excludeRegexp.strip()), literal=True, multiline=True |
9214 | 235 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
236 | |
9214 | 237 | doc["tool"] = tomlkit.table(is_super_table=True) |
238 | doc["tool"]["black"] = black | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
239 | |
9214 | 240 | QGuiApplication.clipboard().setText(tomlkit.dumps(doc)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
241 | |
9214 | 242 | EricMessageBox.information( |
243 | self, | |
9216
e89083501ce3
Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
244 | self.tr("Create TOML snippet"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
245 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
246 | """The 'pyproject.toml' snippet was copied to the clipboard""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
247 | """ successfully.""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
248 | ), |
9214 | 249 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
250 | |
9343
7180fb8677e5
Corrected another oversight in the 'Black' configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9342
diff
changeset
|
251 | def getConfiguration(self, saveToProject=False): |
9214 | 252 | """ |
253 | Public method to get the current configuration parameters. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
254 | |
9343
7180fb8677e5
Corrected another oversight in the 'Black' configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9342
diff
changeset
|
255 | @param saveToProject flag indicating to save the configuration data in the |
7180fb8677e5
Corrected another oversight in the 'Black' configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9342
diff
changeset
|
256 | project file (defaults to False) |
7180fb8677e5
Corrected another oversight in the 'Black' configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9342
diff
changeset
|
257 | @type bool (optional) |
9214 | 258 | @return dictionary containing the configuration parameters |
259 | @rtype dict | |
260 | """ | |
261 | configuration = BlackUtilities.getDefaultConfiguration() | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
262 | |
9214 | 263 | configuration["source"] = self.sourceComboBox.currentData() |
264 | configuration["target-version"] = self.__getTargetList() | |
265 | configuration["line-length"] = self.lineLengthSpinBox.value() | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
266 | configuration[ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
267 | "skip-string-normalization" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
268 | ] = self.skipStringNormalCheckBox.isChecked() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
269 | configuration[ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
270 | "skip-magic-trailing-comma" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
271 | ] = self.skipMagicCommaCheckBox.isChecked() |
9214 | 272 | configuration["extend-exclude"] = self.excludeEdit.toPlainText().strip() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
273 | |
9343
7180fb8677e5
Corrected another oversight in the 'Black' configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9342
diff
changeset
|
274 | if saveToProject and self.__project: |
9214 | 275 | self.__project.setData("OTHERTOOLSPARMS", "Black", configuration) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
276 | |
9214 | 277 | return configuration |