Wed, 21 Sep 2022 17:08:29 +0200
Changed the multiprocessing start method to 'spawn' because 'fork' (on *nix) seems to be unreliable with respect to queues.
9214 | 1 | # -*- coding: utf-8 -*- |
2 | ||
3 | # Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de> | |
4 | # | |
5 | ||
6 | """ | |
7 | Module implementing a dialog showing the code formatting progress and the result. | |
8 | """ | |
9 | ||
10 | import copy | |
11 | import datetime | |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
12 | import multiprocessing |
9214 | 13 | import pathlib |
14 | ||
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
15 | from dataclasses import dataclass |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
16 | |
9214 | 17 | import black |
18 | ||
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
19 | from PyQt6.QtCore import pyqtSignal, pyqtSlot, Qt, QCoreApplication, QObject |
9214 | 20 | from PyQt6.QtWidgets import ( |
21 | QAbstractButton, | |
22 | QDialog, | |
23 | QDialogButtonBox, | |
24 | QHeaderView, | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
25 | QTreeWidgetItem, |
9214 | 26 | ) |
27 | ||
28 | from EricWidgets import EricMessageBox | |
29 | ||
30 | from .Ui_BlackFormattingDialog import Ui_BlackFormattingDialog | |
31 | ||
32 | from . import BlackUtilities | |
33 | from .BlackDiffWidget import BlackDiffWidget | |
34 | from .BlackFormattingAction import BlackFormattingAction | |
35 | ||
36 | import Utilities | |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
37 | import Preferences |
9214 | 38 | |
39 | ||
40 | class BlackFormattingDialog(QDialog, Ui_BlackFormattingDialog): | |
41 | """ | |
42 | Class implementing a dialog showing the code formatting progress and the result. | |
43 | """ | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
44 | |
9214 | 45 | DataTypeRole = Qt.ItemDataRole.UserRole |
46 | DataRole = Qt.ItemDataRole.UserRole + 1 | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
47 | |
9220
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
48 | StatusColumn = 0 |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
49 | FileNameColumn = 1 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
50 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
51 | def __init__( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
52 | self, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
53 | configuration, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
54 | filesList, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
55 | project=None, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
56 | action=BlackFormattingAction.Format, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
57 | parent=None, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
58 | ): |
9214 | 59 | """ |
60 | Constructor | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
61 | |
9214 | 62 | @param configuration dictionary containing the configuration parameters |
63 | @type dict | |
64 | @param filesList list of absolute file paths to be processed | |
65 | @type list of str | |
66 | @param project reference to the project object (defaults to None) | |
67 | @type Project (optional) | |
68 | @param action action to be performed (defaults to BlackFormattingAction.Format) | |
69 | @type BlackFormattingAction (optional) | |
70 | @param parent reference to the parent widget (defaults to None) | |
71 | @type QWidget (optional) | |
72 | """ | |
73 | super().__init__(parent) | |
74 | self.setupUi(self) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
75 | |
9214 | 76 | self.progressBar.setMaximum(len(filesList)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
77 | |
9214 | 78 | self.resultsList.header().setSortIndicator(1, Qt.SortOrder.AscendingOrder) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
79 | |
9214 | 80 | self.__config = copy.deepcopy(configuration) |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
81 | self.__config["__action__"] = action # needed by the workers |
9214 | 82 | self.__project = project |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
83 | |
9344
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
84 | self.__filesList = filesList[:] |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
85 | |
9214 | 86 | self.__diffDialog = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
87 | |
9220
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
88 | self.__allFilter = self.tr("<all>") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
89 | |
9344
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
90 | self.__formatButton = self.buttonBox.addButton( |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
91 | self.tr("Format Code"), QDialogButtonBox.ButtonRole.ActionRole |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
92 | ) |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
93 | self.__formatButton.setVisible(False) |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
94 | |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
95 | self.show() |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
96 | QCoreApplication.processEvents() |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
97 | |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
98 | self.__performAction() |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
99 | |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
100 | def __performAction(self): |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
101 | """ |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
102 | Private method to exceute the requested formatting action. |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
103 | """ |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
104 | self.progressBar.setValue(0) |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
105 | |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
106 | self.statisticsGroup.setVisible(False) |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
107 | self.__statistics = BlackStatistics() |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
108 | |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
109 | self.__cancelled = False |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
110 | |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
111 | self.statusFilterComboBox.clear() |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
112 | self.resultsList.clear() |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
113 | |
9214 | 114 | self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(True) |
115 | self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False) | |
116 | self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
117 | |
9344
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
118 | files = self.__filterFiles(self.__filesList) |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
119 | if len(files) > 1: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
120 | self.__formatManyFiles(files) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
121 | elif len(files) == 1: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
122 | self.__formatOneFile(files[0]) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
123 | |
9214 | 124 | def __filterFiles(self, filesList): |
125 | """ | |
126 | Private method to filter the given list of files according the | |
127 | configuration parameters. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
128 | |
9214 | 129 | @param filesList list of files |
130 | @type list of str | |
131 | @return list of filtered files | |
132 | @rtype list of str | |
133 | """ | |
134 | filterRegExps = [ | |
135 | BlackUtilities.compileRegExp(self.__config[k]) | |
136 | for k in ["force-exclude", "extend-exclude", "exclude"] | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
137 | if k in self.__config |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
138 | and bool(self.__config[k]) |
9214 | 139 | and BlackUtilities.validateRegExp(self.__config[k])[0] |
140 | ] | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
141 | |
9214 | 142 | files = [] |
143 | for file in filesList: | |
144 | file = Utilities.fromNativeSeparators(file) | |
145 | for filterRegExp in filterRegExps: | |
146 | filterMatch = filterRegExp.search(file) | |
147 | if filterMatch and filterMatch.group(0): | |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
148 | self.__handleBlackFormattingResult("ignored", file, "") |
9214 | 149 | break |
150 | else: | |
151 | files.append(file) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
152 | |
9214 | 153 | return files |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
154 | |
9214 | 155 | def __resort(self): |
156 | """ | |
157 | Private method to resort the result list. | |
158 | """ | |
159 | self.resultsList.sortItems( | |
160 | self.resultsList.sortColumn(), | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
161 | self.resultsList.header().sortIndicatorOrder(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
162 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
163 | |
9214 | 164 | def __resizeColumns(self): |
165 | """ | |
166 | Private method to resize the columns of the result list. | |
167 | """ | |
168 | self.resultsList.header().resizeSections( | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
169 | QHeaderView.ResizeMode.ResizeToContents |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
170 | ) |
9214 | 171 | self.resultsList.header().setStretchLastSection(True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
172 | |
9220
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
173 | def __populateStatusFilterCombo(self): |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
174 | """ |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
175 | Private method to populate the status filter combo box with allowed selections. |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
176 | """ |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
177 | allowedSelections = set() |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
178 | for row in range(self.resultsList.topLevelItemCount()): |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
179 | allowedSelections.add( |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
180 | self.resultsList.topLevelItem(row).text( |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
181 | BlackFormattingDialog.StatusColumn |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
182 | ) |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
183 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
184 | |
9220
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
185 | self.statusFilterComboBox.addItem(self.__allFilter) |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
186 | self.statusFilterComboBox.addItems(sorted(allowedSelections)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
187 | |
9214 | 188 | def __finish(self): |
189 | """ | |
190 | Private method to perform some actions after the run was performed or canceled. | |
191 | """ | |
192 | self.__resort() | |
193 | self.__resizeColumns() | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
194 | |
9214 | 195 | self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
196 | self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True) | |
197 | self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
198 | |
9214 | 199 | self.progressBar.setVisible(False) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
200 | |
9344
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
201 | self.__formatButton.setVisible( |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
202 | self.__config["__action__"] is not BlackFormattingAction.Format |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
203 | and self.__statistics.changeCount > 0 |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
204 | ) |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
205 | |
9214 | 206 | self.__updateStatistics() |
9220
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
207 | self.__populateStatusFilterCombo() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
208 | |
9214 | 209 | def __updateStatistics(self): |
210 | """ | |
9220
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
211 | Private method to update the statistics about the recent formatting run and |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
212 | make them visible. |
9214 | 213 | """ |
214 | self.reformattedLabel.setText( | |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
215 | self.tr("Reformatted:") |
9344
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
216 | if self.__config["__action__"] is BlackFormattingAction.Format |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
217 | else self.tr("Would Reformat:") |
9214 | 218 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
219 | |
9214 | 220 | total = self.progressBar.maximum() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
221 | |
9214 | 222 | self.totalCountLabel.setText("{0:n}".format(total)) |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
223 | self.excludedCountLabel.setText("{0:n}".format(self.__statistics.ignoreCount)) |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
224 | self.failuresCountLabel.setText("{0:n}".format(self.__statistics.failureCount)) |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
225 | self.processedCountLabel.setText( |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
226 | "{0:n}".format(self.__statistics.processedCount) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
227 | ) |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
228 | self.reformattedCountLabel.setText( |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
229 | "{0:n}".format(self.__statistics.changeCount) |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
230 | ) |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
231 | self.unchangedCountLabel.setText("{0:n}".format(self.__statistics.sameCount)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
232 | |
9220
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
233 | self.statisticsGroup.setVisible(True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
234 | |
9214 | 235 | @pyqtSlot(QAbstractButton) |
236 | def on_buttonBox_clicked(self, button): | |
237 | """ | |
238 | Private slot to handle button presses of the dialog buttons. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
239 | |
9214 | 240 | @param button reference to the pressed button |
241 | @type QAbstractButton | |
242 | """ | |
243 | if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel): | |
244 | self.__cancelled = True | |
245 | elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close): | |
246 | self.accept() | |
9344
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
247 | elif button is self.__formatButton: |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
248 | self.__formatButtonClicked() |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
249 | |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
250 | @pyqtSlot() |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
251 | def __formatButtonClicked(self): |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
252 | """ |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
253 | Private slot handling the selection of the 'Format Code' button. |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
254 | """ |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
255 | self.__config["__action__"] = BlackFormattingAction.Format |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
256 | |
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
257 | self.__performAction() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
258 | |
9214 | 259 | @pyqtSlot(QTreeWidgetItem, int) |
260 | def on_resultsList_itemDoubleClicked(self, item, column): | |
261 | """ | |
262 | Private slot handling a double click of a result item. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
263 | |
9214 | 264 | @param item reference to the double clicked item |
265 | @type QTreeWidgetItem | |
266 | @param column column number that was double clicked | |
267 | @type int | |
268 | """ | |
269 | dataType = item.data(0, BlackFormattingDialog.DataTypeRole) | |
270 | if dataType == "error": | |
271 | EricMessageBox.critical( | |
272 | self, | |
273 | self.tr("Formatting Failure"), | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
274 | self.tr("<p>Formatting failed due to this error.</p><p>{0}</p>").format( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
275 | item.data(0, BlackFormattingDialog.DataRole) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
276 | ), |
9214 | 277 | ) |
278 | elif dataType == "diff": | |
279 | if self.__diffDialog is None: | |
280 | self.__diffDialog = BlackDiffWidget() | |
281 | self.__diffDialog.showDiff(item.data(0, BlackFormattingDialog.DataRole)) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
282 | |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
283 | def __formatManyFiles(self, files): |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
284 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
285 | Private method to format the list of files according the configuration using |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
286 | multiple processes in parallel. |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
287 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
288 | @param files list of files to be processed |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
289 | @type list of str |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
290 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
291 | maxProcesses = Preferences.getUI("BackgroundServiceProcesses") |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
292 | if maxProcesses == 0: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
293 | # determine based on CPU count |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
294 | try: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
295 | NumberOfProcesses = multiprocessing.cpu_count() |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
296 | if NumberOfProcesses >= 1: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
297 | NumberOfProcesses -= 1 |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
298 | except NotImplementedError: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
299 | NumberOfProcesses = 1 |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
300 | else: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
301 | NumberOfProcesses = maxProcesses |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
302 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
303 | # Create queues |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
304 | taskQueue = multiprocessing.Queue() |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
305 | doneQueue = multiprocessing.Queue() |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
306 | |
9289
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
307 | # Submit tasks (initially two times the number of processes) |
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
308 | tasks = len(files) |
9292
a5c8a0213fe3
Fixed an issue in the multiprocessing usage causing a traceback when then number of tasks is smaller than the number of worker processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9289
diff
changeset
|
309 | initialTasks = min(2 * NumberOfProcesses, tasks) |
9289
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
310 | for _ in range(initialTasks): |
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
311 | file = files.pop(0) |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
312 | relSrc = self.__project.getRelativePath(str(file)) if self.__project else "" |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
313 | taskQueue.put((file, relSrc)) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
314 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
315 | # Start worker processes |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
316 | workers = [ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
317 | multiprocessing.Process( |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
318 | target=self.formattingWorkerTask, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
319 | args=(taskQueue, doneQueue, self.__config), |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
320 | ) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
321 | for _ in range(NumberOfProcesses) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
322 | ] |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
323 | for worker in workers: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
324 | worker.start() |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
325 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
326 | # Get the results from the worker tasks |
9289
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
327 | for _ in range(tasks): |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
328 | result = doneQueue.get() |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
329 | self.__handleBlackFormattingResult( |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
330 | result.status, result.filename, result.data |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
331 | ) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
332 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
333 | if self.__cancelled: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
334 | break |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
335 | |
9289
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
336 | if files: |
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
337 | file = files.pop(0) |
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
338 | relSrc = ( |
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
339 | self.__project.getRelativePath(str(file)) if self.__project else "" |
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
340 | ) |
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
341 | taskQueue.put((file, relSrc)) |
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
342 | |
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
343 | # Tell child processes to stop |
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
344 | for _ in range(NumberOfProcesses): |
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
345 | taskQueue.put("STOP") |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
346 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
347 | for worker in workers: |
9348
f61d71d95cb1
Changed the multiprocessing start method to 'spawn' because 'fork' (on *nix) seems to be unreliable with respect to queues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9344
diff
changeset
|
348 | worker.join() |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
349 | worker.close() |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
350 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
351 | taskQueue.close() |
9348
f61d71d95cb1
Changed the multiprocessing start method to 'spawn' because 'fork' (on *nix) seems to be unreliable with respect to queues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9344
diff
changeset
|
352 | doneQueue.close() |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
353 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
354 | self.__finish() |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
355 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
356 | @staticmethod |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
357 | def formattingWorkerTask(inputQueue, outputQueue, config): |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
358 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
359 | Static method acting as the parallel worker for the formatting task. |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
360 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
361 | @param inputQueue input queue |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
362 | @type multiprocessing.Queue |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
363 | @param outputQueue output queue |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
364 | @type multiprocessing.Queue |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
365 | @param config dictionary containing the configuration parameters |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
366 | @type dict |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
367 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
368 | report = BlackMultiprocessingReport(outputQueue) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
369 | report.check = config["__action__"] is BlackFormattingAction.Check |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
370 | report.diff = config["__action__"] is BlackFormattingAction.Diff |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
371 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
372 | versions = ( |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
373 | {black.TargetVersion[target.upper()] for target in config["target-version"]} |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
374 | if config["target-version"] |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
375 | else set() |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
376 | ) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
377 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
378 | mode = black.Mode( |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
379 | target_versions=versions, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
380 | line_length=int(config["line-length"]), |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
381 | string_normalization=not config["skip-string-normalization"], |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
382 | magic_trailing_comma=not config["skip-magic-trailing-comma"], |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
383 | ) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
384 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
385 | if config["__action__"] is BlackFormattingAction.Diff: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
386 | for file, relSrc in iter(inputQueue.get, "STOP"): |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
387 | BlackFormattingDialog.__diffFormatFile( |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
388 | pathlib.Path(file), |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
389 | fast=False, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
390 | mode=mode, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
391 | report=report, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
392 | relSrc=relSrc, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
393 | ) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
394 | else: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
395 | writeBack = black.WriteBack.from_configuration( |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
396 | check=config["__action__"] is BlackFormattingAction.Check, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
397 | diff=config["__action__"] is BlackFormattingAction.Diff, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
398 | ) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
399 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
400 | for file, _relSrc in iter(inputQueue.get, "STOP"): |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
401 | black.reformat_one( |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
402 | pathlib.Path(file), |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
403 | fast=False, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
404 | write_back=writeBack, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
405 | mode=mode, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
406 | report=report, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
407 | ) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
408 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
409 | def __formatOneFile(self, file): |
9214 | 410 | """ |
411 | Private method to format the list of files according the configuration. | |
9284
3b3a4f659782
"Blacked" the sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9283
diff
changeset
|
412 | |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
413 | @param file name of the file to be processed |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
414 | @type str |
9214 | 415 | """ |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
416 | report = BlackReport(self) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
417 | report.check = self.__config["__action__"] is BlackFormattingAction.Check |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
418 | report.diff = self.__config["__action__"] is BlackFormattingAction.Diff |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
419 | report.result.connect(self.__handleBlackFormattingResult) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
420 | |
9214 | 421 | writeBack = black.WriteBack.from_configuration( |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
422 | check=self.__config["__action__"] is BlackFormattingAction.Check, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
423 | diff=self.__config["__action__"] is BlackFormattingAction.Diff, |
9214 | 424 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
425 | |
9214 | 426 | versions = ( |
427 | { | |
428 | black.TargetVersion[target.upper()] | |
429 | for target in self.__config["target-version"] | |
430 | } | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
431 | if self.__config["target-version"] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
432 | else set() |
9214 | 433 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
434 | |
9214 | 435 | mode = black.Mode( |
436 | target_versions=versions, | |
437 | line_length=int(self.__config["line-length"]), | |
438 | string_normalization=not self.__config["skip-string-normalization"], | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
439 | magic_trailing_comma=not self.__config["skip-magic-trailing-comma"], |
9214 | 440 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
441 | |
9344
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
442 | if self.__config["__action__"] is BlackFormattingAction.Diff: |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
443 | relSrc = self.__project.getRelativePath(str(file)) if self.__project else "" |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
444 | self.__diffFormatFile( |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
445 | pathlib.Path(file), fast=False, mode=mode, report=report, relSrc=relSrc |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
446 | ) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
447 | else: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
448 | black.reformat_one( |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
449 | pathlib.Path(file), |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
450 | fast=False, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
451 | write_back=writeBack, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
452 | mode=mode, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
453 | report=report, |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
454 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
455 | |
9214 | 456 | self.__finish() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
457 | |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
458 | @staticmethod |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
459 | def __diffFormatFile(src, fast, mode, report, relSrc=""): |
9214 | 460 | """ |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
461 | Static method to check, if the given files need to be reformatted, and generate |
9214 | 462 | a unified diff. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
463 | |
9214 | 464 | @param src path of file to be checked |
465 | @type pathlib.Path | |
466 | @param fast flag indicating fast operation | |
467 | @type bool | |
468 | @param mode code formatting options | |
469 | @type black.Mode | |
470 | @param report reference to the report object | |
471 | @type BlackReport | |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
472 | @param relSrc name of the file relative to the project (defaults to "") |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
473 | @type str (optional) |
9214 | 474 | """ |
475 | then = datetime.datetime.utcfromtimestamp(src.stat().st_mtime) | |
476 | with open(src, "rb") as buf: | |
477 | srcContents, _, _ = black.decode_bytes(buf.read()) | |
478 | try: | |
479 | dstContents = black.format_file_contents(srcContents, fast=fast, mode=mode) | |
480 | except black.NothingChanged: | |
481 | report.done(src, black.Changed.NO) | |
482 | return | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
483 | |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
484 | fileName = relSrc if bool(relSrc) else str(src) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
485 | |
9214 | 486 | now = datetime.datetime.utcnow() |
487 | srcName = f"{fileName}\t{then} +0000" | |
488 | dstName = f"{fileName}\t{now} +0000" | |
489 | diffContents = black.diff(srcContents, dstContents, srcName, dstName) | |
490 | report.done(src, black.Changed.YES, diff=diffContents) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
491 | |
9214 | 492 | def closeEvent(self, evt): |
493 | """ | |
494 | Protected slot implementing a close event handler. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
495 | |
9214 | 496 | @param evt reference to the close event |
497 | @type QCloseEvent | |
498 | """ | |
499 | if self.__diffDialog is not None: | |
500 | self.__diffDialog.close() | |
501 | evt.accept() | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
502 | |
9220
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
503 | @pyqtSlot(str) |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
504 | def on_statusFilterComboBox_currentTextChanged(self, status): |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
505 | """ |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
506 | Private slot handling the selection of a status for items to be shown. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
507 | |
9220
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
508 | @param status selected status |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
509 | @type str |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
510 | """ |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
511 | for row in range(self.resultsList.topLevelItemCount()): |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
512 | itm = self.resultsList.topLevelItem(row) |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
513 | itm.setHidden( |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
514 | status != self.__allFilter |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
515 | and itm.text(BlackFormattingDialog.StatusColumn) != status |
e9e7eca7efee
Black Formatting Dialog
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
516 | ) |
9214 | 517 | |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
518 | @pyqtSlot(str, str, str) |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
519 | def __handleBlackFormattingResult(self, status, filename, data): |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
520 | """ |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
521 | Private slot to handle the result of a black reformatting action. |
9214 | 522 | |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
523 | @param status status of the performed action (one of 'changed', 'unchanged', |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
524 | 'unmodified', 'failed' or 'ignored') |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
525 | @type str |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
526 | @param filename name of the processed file |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
527 | @type str |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
528 | @param data action data (error message or unified diff) |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
529 | @type str |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
530 | """ |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
531 | isError = False |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
532 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
533 | if status == "changed": |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
534 | statusMsg = ( |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
535 | self.tr("would reformat") |
9344
52990830b13f
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
536 | if self.__config["__action__"] |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
537 | in (BlackFormattingAction.Check, BlackFormattingAction.Diff) |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
538 | else self.tr("reformatted") |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
539 | ) |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
540 | self.__statistics.changeCount += 1 |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
541 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
542 | elif status == "unchanged": |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
543 | statusMsg = self.tr("unchanged") |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
544 | self.__statistics.sameCount += 1 |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
545 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
546 | elif status == "unmodified": |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
547 | statusMsg = self.tr("unmodified") |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
548 | self.__statistics.sameCount += 1 |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
549 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
550 | elif status == "ignored": |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
551 | statusMsg = self.tr("ignored") |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
552 | self.__statistics.ignoreCount += 1 |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
553 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
554 | elif status == "failed": |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
555 | statusMsg = self.tr("failed") |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
556 | self.__statistics.failureCount += 1 |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
557 | isError = True |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
558 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
559 | else: |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
560 | statusMsg = self.tr("invalid status ({0})").format(status) |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
561 | self.__statistics.failureCount += 1 |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
562 | isError = True |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
563 | |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
564 | if status != "ignored": |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
565 | self.__statistics.processedCount += 1 |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
566 | |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
567 | if self.__project: |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
568 | filename = self.__project.getRelativePath(filename) |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
569 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
570 | itm = QTreeWidgetItem(self.resultsList, [statusMsg, filename]) |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
571 | if data: |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
572 | itm.setData( |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
573 | 0, BlackFormattingDialog.DataTypeRole, "error" if isError else "diff" |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
574 | ) |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
575 | itm.setData(0, BlackFormattingDialog.DataRole, data) |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
576 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
577 | self.progressBar.setValue(self.progressBar.value() + 1) |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
578 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
579 | QCoreApplication.processEvents() |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
580 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
581 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
582 | @dataclass |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
583 | class BlackStatistics: |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
584 | """ |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
585 | Class containing the reformatting statistic data. |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
586 | """ |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
587 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
588 | ignoreCount: int = 0 |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
589 | changeCount: int = 0 |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
590 | sameCount: int = 0 |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
591 | failureCount: int = 0 |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
592 | processedCount: int = 0 |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
593 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
594 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
595 | class BlackReport(QObject, black.Report): |
9214 | 596 | """ |
597 | Class extending the black Report to work with our dialog. | |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
598 | |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
599 | @signal result(status, file name, data) emitted to signal the reformatting result |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
600 | as three strings giving the status (one of 'changed', 'unchanged', 'unmodified', |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
601 | 'failed' or 'ignored'), the file name and data related to the result |
9214 | 602 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
603 | |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
604 | result = pyqtSignal(str, str, str) |
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
605 | |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
606 | def __init__(self, parent=None): |
9214 | 607 | """ |
608 | Constructor | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
609 | |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
610 | @param parent reference to the parent object (defaults to None |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
611 | @type QObject (optional) |
9214 | 612 | """ |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
613 | QObject.__init__(self, parent) |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
614 | black.Report.__init__(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
615 | |
9214 | 616 | def done(self, src, changed, diff=""): |
617 | """ | |
618 | Public method to handle the end of a reformat. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
619 | |
9214 | 620 | @param src name of the processed file |
621 | @type pathlib.Path | |
622 | @param changed change status | |
623 | @type black.Changed | |
624 | @param diff unified diff of potential changes (defaults to "") | |
625 | @type str | |
626 | """ | |
627 | if changed is black.Changed.YES: | |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
628 | status = "changed" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
629 | |
9214 | 630 | elif changed is black.Changed.NO: |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
631 | status = "unchanged" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
632 | |
9214 | 633 | elif changed is black.Changed.CACHED: |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
634 | status = "unmodified" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
635 | |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
636 | self.result.emit(status, str(src), diff) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
637 | |
9214 | 638 | def failed(self, src, message): |
639 | """ | |
640 | Public method to handle a reformat failure. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
641 | |
9214 | 642 | @param src name of the processed file |
643 | @type pathlib.Path | |
644 | @param message error message | |
645 | @type str | |
646 | """ | |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
647 | self.result.emit("failed", str(src), message) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
648 | |
9214 | 649 | def path_ignored(self, src, message=""): |
650 | """ | |
651 | Public method handling an ignored path. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9220
diff
changeset
|
652 | |
9214 | 653 | @param src name of the processed file |
654 | @type pathlib.Path or str | |
655 | @param message ignore message (default to "") | |
656 | @type str (optional) | |
657 | """ | |
9281
76caf27cb8a8
Changed the code reformatting dialog to work with signals and slots and do the statistics calculation in the dialog class (prepare for multi processing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
658 | self.result.emit("ignored", str(src), "") |
9283
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
659 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
660 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
661 | @dataclass |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
662 | class BlackMultiprocessingResult: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
663 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
664 | Class containing the reformatting result data. |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
665 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
666 | This class is used when reformatting multiple files in parallel using processes. |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
667 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
668 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
669 | status: str = "" |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
670 | filename: str = "" |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
671 | data: str = "" |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
672 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
673 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
674 | class BlackMultiprocessingReport(black.Report): |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
675 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
676 | Class extending the black Report to work with multiprocessing. |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
677 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
678 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
679 | def __init__(self, resultQueue): |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
680 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
681 | Constructor |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
682 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
683 | @param resultQueue reference to the queue to put the results into |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
684 | @type multiprocessing.Queue |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
685 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
686 | super().__init__() |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
687 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
688 | self.__queue = resultQueue |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
689 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
690 | def done(self, src, changed, diff=""): |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
691 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
692 | Public method to handle the end of a reformat. |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
693 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
694 | @param src name of the processed file |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
695 | @type pathlib.Path |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
696 | @param changed change status |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
697 | @type black.Changed |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
698 | @param diff unified diff of potential changes (defaults to "") |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
699 | @type str |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
700 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
701 | if changed is black.Changed.YES: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
702 | status = "changed" |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
703 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
704 | elif changed is black.Changed.NO: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
705 | status = "unchanged" |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
706 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
707 | elif changed is black.Changed.CACHED: |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
708 | status = "unmodified" |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
709 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
710 | self.__queue.put( |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
711 | BlackMultiprocessingResult(status=status, filename=str(src), data=diff) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
712 | ) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
713 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
714 | def failed(self, src, message): |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
715 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
716 | Public method to handle a reformat failure. |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
717 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
718 | @param src name of the processed file |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
719 | @type pathlib.Path |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
720 | @param message error message |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
721 | @type str |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
722 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
723 | self.__queue.put( |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
724 | BlackMultiprocessingResult(status="failed", filename=str(src), data=message) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
725 | ) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
726 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
727 | def path_ignored(self, src, message=""): |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
728 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
729 | Public method handling an ignored path. |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
730 | |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
731 | @param src name of the processed file |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
732 | @type pathlib.Path or str |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
733 | @param message ignore message (default to "") |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
734 | @type str (optional) |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
735 | """ |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
736 | self.__queue.put( |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
737 | BlackMultiprocessingResult(status="ignored", filename=str(src), data="") |
0e9d2c4e379e
Changed the code reformatting dialog such, that it uses multiple processes to reformat files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9281
diff
changeset
|
738 | ) |