|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.CodeFormatting.IsortFormattingDialog</title> |
|
4 <meta charset="UTF-8"> |
|
5 <link rel="stylesheet" href="styles.css"> |
|
6 </head> |
|
7 <body> |
|
8 <a NAME="top" ID="top"></a> |
|
9 <h1>eric7.CodeFormatting.IsortFormattingDialog</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing a dialog showing the isort code formatting progress and the results. |
|
13 </p> |
|
14 <h3>Global Attributes</h3> |
|
15 |
|
16 <table> |
|
17 <tr><td>None</td></tr> |
|
18 </table> |
|
19 <h3>Classes</h3> |
|
20 |
|
21 <table> |
|
22 |
|
23 <tr> |
|
24 <td><a href="#IsortFormattingDialog">IsortFormattingDialog</a></td> |
|
25 <td>Class implementing a dialog showing the isort code formatting progress and the results.</td> |
|
26 </tr> |
|
27 <tr> |
|
28 <td><a href="#IsortResult">IsortResult</a></td> |
|
29 <td>Class containing the isort reformatting result data.</td> |
|
30 </tr> |
|
31 <tr> |
|
32 <td><a href="#IsortStatistics">IsortStatistics</a></td> |
|
33 <td>Class containing the isort reformatting statistic data.</td> |
|
34 </tr> |
|
35 </table> |
|
36 <h3>Functions</h3> |
|
37 |
|
38 <table> |
|
39 <tr><td>None</td></tr> |
|
40 </table> |
|
41 <hr /> |
|
42 <hr /> |
|
43 <a NAME="IsortFormattingDialog" ID="IsortFormattingDialog"></a> |
|
44 <h2>IsortFormattingDialog</h2> |
|
45 |
|
46 <p> |
|
47 Class implementing a dialog showing the isort code formatting progress and the |
|
48 results. |
|
49 </p> |
|
50 <h3>Derived from</h3> |
|
51 QDialog, Ui_IsortFormattingDialog |
|
52 <h3>Class Attributes</h3> |
|
53 |
|
54 <table> |
|
55 <tr><td>DataRole</td></tr><tr><td>DataTypeRole</td></tr><tr><td>FileNameColumn</td></tr><tr><td>StatusColumn</td></tr> |
|
56 </table> |
|
57 <h3>Class Methods</h3> |
|
58 |
|
59 <table> |
|
60 <tr><td>None</td></tr> |
|
61 </table> |
|
62 <h3>Methods</h3> |
|
63 |
|
64 <table> |
|
65 |
|
66 <tr> |
|
67 <td><a href="#IsortFormattingDialog.__init__">IsortFormattingDialog</a></td> |
|
68 <td>Constructor</td> |
|
69 </tr> |
|
70 <tr> |
|
71 <td><a href="#IsortFormattingDialog.__filterFiles">__filterFiles</a></td> |
|
72 <td>Private method to filter the given list of files according the configuration parameters.</td> |
|
73 </tr> |
|
74 <tr> |
|
75 <td><a href="#IsortFormattingDialog.__finish">__finish</a></td> |
|
76 <td>Private method to perform some actions after the run was performed or canceled.</td> |
|
77 </tr> |
|
78 <tr> |
|
79 <td><a href="#IsortFormattingDialog.__formatManyFiles">__formatManyFiles</a></td> |
|
80 <td>Private method to format the list of files according the configuration using multiple processes in parallel.</td> |
|
81 </tr> |
|
82 <tr> |
|
83 <td><a href="#IsortFormattingDialog.__formatOneFile">__formatOneFile</a></td> |
|
84 <td>Private method to format the list of files according the configuration.</td> |
|
85 </tr> |
|
86 <tr> |
|
87 <td><a href="#IsortFormattingDialog.__handleIsortResult">__handleIsortResult</a></td> |
|
88 <td>Private method to handle an isort formatting result.</td> |
|
89 </tr> |
|
90 <tr> |
|
91 <td><a href="#IsortFormattingDialog.__performAction">__performAction</a></td> |
|
92 <td>Private method to execute the requested formatting action.</td> |
|
93 </tr> |
|
94 <tr> |
|
95 <td><a href="#IsortFormattingDialog.__populateStatusFilterCombo">__populateStatusFilterCombo</a></td> |
|
96 <td>Private method to populate the status filter combo box with allowed selections.</td> |
|
97 </tr> |
|
98 <tr> |
|
99 <td><a href="#IsortFormattingDialog.__resizeColumns">__resizeColumns</a></td> |
|
100 <td>Private method to resize the columns of the result list.</td> |
|
101 </tr> |
|
102 <tr> |
|
103 <td><a href="#IsortFormattingDialog.__resort">__resort</a></td> |
|
104 <td>Private method to resort the result list.</td> |
|
105 </tr> |
|
106 <tr> |
|
107 <td><a href="#IsortFormattingDialog.__sortImportsButtonClicked">__sortImportsButtonClicked</a></td> |
|
108 <td>Private slot handling the selection of the 'Sort Imports' button.</td> |
|
109 </tr> |
|
110 <tr> |
|
111 <td><a href="#IsortFormattingDialog.__updateStatistics">__updateStatistics</a></td> |
|
112 <td>Private method to update the statistics about the recent formatting run and make them visible.</td> |
|
113 </tr> |
|
114 <tr> |
|
115 <td><a href="#IsortFormattingDialog.closeEvent">closeEvent</a></td> |
|
116 <td>Protected slot implementing a close event handler.</td> |
|
117 </tr> |
|
118 <tr> |
|
119 <td><a href="#IsortFormattingDialog.on_buttonBox_clicked">on_buttonBox_clicked</a></td> |
|
120 <td>Private slot to handle button presses of the dialog buttons.</td> |
|
121 </tr> |
|
122 <tr> |
|
123 <td><a href="#IsortFormattingDialog.on_resultsList_itemDoubleClicked">on_resultsList_itemDoubleClicked</a></td> |
|
124 <td>Private slot handling a double click of a result item.</td> |
|
125 </tr> |
|
126 <tr> |
|
127 <td><a href="#IsortFormattingDialog.on_statusFilterComboBox_currentTextChanged">on_statusFilterComboBox_currentTextChanged</a></td> |
|
128 <td>Private slot handling the selection of a status for items to be shown.</td> |
|
129 </tr> |
|
130 </table> |
|
131 <h3>Static Methods</h3> |
|
132 |
|
133 <table> |
|
134 |
|
135 <tr> |
|
136 <td><a href="#IsortFormattingDialog.__isortCheckFile">__isortCheckFile</a></td> |
|
137 <td>Static method to check, if a file's import statements need to be changed.</td> |
|
138 </tr> |
|
139 <tr> |
|
140 <td><a href="#IsortFormattingDialog.__isortSortFile">__isortSortFile</a></td> |
|
141 <td>Static method to sort the import statements of a file.</td> |
|
142 </tr> |
|
143 <tr> |
|
144 <td><a href="#IsortFormattingDialog.formattingWorkerTask">formattingWorkerTask</a></td> |
|
145 <td>Static method acting as the parallel worker for the formatting task.</td> |
|
146 </tr> |
|
147 </table> |
|
148 |
|
149 <a NAME="IsortFormattingDialog.__init__" ID="IsortFormattingDialog.__init__"></a> |
|
150 <h4>IsortFormattingDialog (Constructor)</h4> |
|
151 <b>IsortFormattingDialog</b>(<i>configuration, filesList, project=None, action=IsortFormattingAction.Sort, parent=None, </i>) |
|
152 |
|
153 <p> |
|
154 Constructor |
|
155 </p> |
|
156 <dl> |
|
157 |
|
158 <dt><i>configuration</i> (dict)</dt> |
|
159 <dd> |
|
160 dictionary containing the configuration parameters |
|
161 </dd> |
|
162 <dt><i>filesList</i> (list of str)</dt> |
|
163 <dd> |
|
164 list of absolute file paths to be processed |
|
165 </dd> |
|
166 <dt><i>project</i> (Project (optional))</dt> |
|
167 <dd> |
|
168 reference to the project object (defaults to None) |
|
169 </dd> |
|
170 <dt><i>action</i> (IsortFormattingAction (optional))</dt> |
|
171 <dd> |
|
172 action to be performed (defaults to IsortFormattingAction.Sort) |
|
173 </dd> |
|
174 <dt><i>parent</i> (QWidget (optional))</dt> |
|
175 <dd> |
|
176 reference to the parent widget (defaults to None) |
|
177 </dd> |
|
178 </dl> |
|
179 <a NAME="IsortFormattingDialog.__filterFiles" ID="IsortFormattingDialog.__filterFiles"></a> |
|
180 <h4>IsortFormattingDialog.__filterFiles</h4> |
|
181 <b>__filterFiles</b>(<i>filesList</i>) |
|
182 |
|
183 <p> |
|
184 Private method to filter the given list of files according the |
|
185 configuration parameters. |
|
186 </p> |
|
187 <dl> |
|
188 |
|
189 <dt><i>filesList</i> (list of str)</dt> |
|
190 <dd> |
|
191 list of files |
|
192 </dd> |
|
193 </dl> |
|
194 <dl> |
|
195 <dt>Return:</dt> |
|
196 <dd> |
|
197 list of filtered files |
|
198 </dd> |
|
199 </dl> |
|
200 <dl> |
|
201 <dt>Return Type:</dt> |
|
202 <dd> |
|
203 list of str |
|
204 </dd> |
|
205 </dl> |
|
206 <a NAME="IsortFormattingDialog.__finish" ID="IsortFormattingDialog.__finish"></a> |
|
207 <h4>IsortFormattingDialog.__finish</h4> |
|
208 <b>__finish</b>(<i></i>) |
|
209 |
|
210 <p> |
|
211 Private method to perform some actions after the run was performed or canceled. |
|
212 </p> |
|
213 <a NAME="IsortFormattingDialog.__formatManyFiles" ID="IsortFormattingDialog.__formatManyFiles"></a> |
|
214 <h4>IsortFormattingDialog.__formatManyFiles</h4> |
|
215 <b>__formatManyFiles</b>(<i>files</i>) |
|
216 |
|
217 <p> |
|
218 Private method to format the list of files according the configuration using |
|
219 multiple processes in parallel. |
|
220 </p> |
|
221 <dl> |
|
222 |
|
223 <dt><i>files</i> (list of str)</dt> |
|
224 <dd> |
|
225 list of files to be processed |
|
226 </dd> |
|
227 </dl> |
|
228 <a NAME="IsortFormattingDialog.__formatOneFile" ID="IsortFormattingDialog.__formatOneFile"></a> |
|
229 <h4>IsortFormattingDialog.__formatOneFile</h4> |
|
230 <b>__formatOneFile</b>(<i>file</i>) |
|
231 |
|
232 <p> |
|
233 Private method to format the list of files according the configuration. |
|
234 </p> |
|
235 <dl> |
|
236 |
|
237 <dt><i>file</i> (str)</dt> |
|
238 <dd> |
|
239 name of the file to be processed |
|
240 </dd> |
|
241 </dl> |
|
242 <a NAME="IsortFormattingDialog.__handleIsortResult" ID="IsortFormattingDialog.__handleIsortResult"></a> |
|
243 <h4>IsortFormattingDialog.__handleIsortResult</h4> |
|
244 <b>__handleIsortResult</b>(<i>filename, status, data=""</i>) |
|
245 |
|
246 <p> |
|
247 Private method to handle an isort formatting result. |
|
248 </p> |
|
249 <dl> |
|
250 |
|
251 <dt><i>filename</i> (str)</dt> |
|
252 <dd> |
|
253 name of the processed file |
|
254 </dd> |
|
255 <dt><i>status</i> (str)</dt> |
|
256 <dd> |
|
257 status of the performed action (one of 'changed', 'failed', |
|
258 'skipped' or 'unchanged') |
|
259 </dd> |
|
260 <dt><i>data</i> (str (optional))</dt> |
|
261 <dd> |
|
262 action data (error message or unified diff) (defaults to "") |
|
263 </dd> |
|
264 </dl> |
|
265 <a NAME="IsortFormattingDialog.__performAction" ID="IsortFormattingDialog.__performAction"></a> |
|
266 <h4>IsortFormattingDialog.__performAction</h4> |
|
267 <b>__performAction</b>(<i></i>) |
|
268 |
|
269 <p> |
|
270 Private method to execute the requested formatting action. |
|
271 </p> |
|
272 <a NAME="IsortFormattingDialog.__populateStatusFilterCombo" ID="IsortFormattingDialog.__populateStatusFilterCombo"></a> |
|
273 <h4>IsortFormattingDialog.__populateStatusFilterCombo</h4> |
|
274 <b>__populateStatusFilterCombo</b>(<i></i>) |
|
275 |
|
276 <p> |
|
277 Private method to populate the status filter combo box with allowed selections. |
|
278 </p> |
|
279 <a NAME="IsortFormattingDialog.__resizeColumns" ID="IsortFormattingDialog.__resizeColumns"></a> |
|
280 <h4>IsortFormattingDialog.__resizeColumns</h4> |
|
281 <b>__resizeColumns</b>(<i></i>) |
|
282 |
|
283 <p> |
|
284 Private method to resize the columns of the result list. |
|
285 </p> |
|
286 <a NAME="IsortFormattingDialog.__resort" ID="IsortFormattingDialog.__resort"></a> |
|
287 <h4>IsortFormattingDialog.__resort</h4> |
|
288 <b>__resort</b>(<i></i>) |
|
289 |
|
290 <p> |
|
291 Private method to resort the result list. |
|
292 </p> |
|
293 <a NAME="IsortFormattingDialog.__sortImportsButtonClicked" ID="IsortFormattingDialog.__sortImportsButtonClicked"></a> |
|
294 <h4>IsortFormattingDialog.__sortImportsButtonClicked</h4> |
|
295 <b>__sortImportsButtonClicked</b>(<i></i>) |
|
296 |
|
297 <p> |
|
298 Private slot handling the selection of the 'Sort Imports' button. |
|
299 </p> |
|
300 <a NAME="IsortFormattingDialog.__updateStatistics" ID="IsortFormattingDialog.__updateStatistics"></a> |
|
301 <h4>IsortFormattingDialog.__updateStatistics</h4> |
|
302 <b>__updateStatistics</b>(<i></i>) |
|
303 |
|
304 <p> |
|
305 Private method to update the statistics about the recent formatting run and |
|
306 make them visible. |
|
307 </p> |
|
308 <a NAME="IsortFormattingDialog.closeEvent" ID="IsortFormattingDialog.closeEvent"></a> |
|
309 <h4>IsortFormattingDialog.closeEvent</h4> |
|
310 <b>closeEvent</b>(<i>evt</i>) |
|
311 |
|
312 <p> |
|
313 Protected slot implementing a close event handler. |
|
314 </p> |
|
315 <dl> |
|
316 |
|
317 <dt><i>evt</i> (QCloseEvent)</dt> |
|
318 <dd> |
|
319 reference to the close event |
|
320 </dd> |
|
321 </dl> |
|
322 <a NAME="IsortFormattingDialog.on_buttonBox_clicked" ID="IsortFormattingDialog.on_buttonBox_clicked"></a> |
|
323 <h4>IsortFormattingDialog.on_buttonBox_clicked</h4> |
|
324 <b>on_buttonBox_clicked</b>(<i>button</i>) |
|
325 |
|
326 <p> |
|
327 Private slot to handle button presses of the dialog buttons. |
|
328 </p> |
|
329 <dl> |
|
330 |
|
331 <dt><i>button</i> (QAbstractButton)</dt> |
|
332 <dd> |
|
333 reference to the pressed button |
|
334 </dd> |
|
335 </dl> |
|
336 <a NAME="IsortFormattingDialog.on_resultsList_itemDoubleClicked" ID="IsortFormattingDialog.on_resultsList_itemDoubleClicked"></a> |
|
337 <h4>IsortFormattingDialog.on_resultsList_itemDoubleClicked</h4> |
|
338 <b>on_resultsList_itemDoubleClicked</b>(<i>item, column</i>) |
|
339 |
|
340 <p> |
|
341 Private slot handling a double click of a result item. |
|
342 </p> |
|
343 <dl> |
|
344 |
|
345 <dt><i>item</i> (QTreeWidgetItem)</dt> |
|
346 <dd> |
|
347 reference to the double clicked item |
|
348 </dd> |
|
349 <dt><i>column</i> (int)</dt> |
|
350 <dd> |
|
351 column number that was double clicked |
|
352 </dd> |
|
353 </dl> |
|
354 <a NAME="IsortFormattingDialog.on_statusFilterComboBox_currentTextChanged" ID="IsortFormattingDialog.on_statusFilterComboBox_currentTextChanged"></a> |
|
355 <h4>IsortFormattingDialog.on_statusFilterComboBox_currentTextChanged</h4> |
|
356 <b>on_statusFilterComboBox_currentTextChanged</b>(<i>status</i>) |
|
357 |
|
358 <p> |
|
359 Private slot handling the selection of a status for items to be shown. |
|
360 </p> |
|
361 <dl> |
|
362 |
|
363 <dt><i>status</i> (str)</dt> |
|
364 <dd> |
|
365 selected status |
|
366 </dd> |
|
367 </dl> |
|
368 <a NAME="IsortFormattingDialog.__isortCheckFile" ID="IsortFormattingDialog.__isortCheckFile"></a> |
|
369 <h4>IsortFormattingDialog.__isortCheckFile (static)</h4> |
|
370 <b>__isortCheckFile</b>(<i>isortConfig, withDiff=True</i>) |
|
371 |
|
372 <p> |
|
373 Static method to check, if a file's import statements need to be changed. |
|
374 </p> |
|
375 <dl> |
|
376 |
|
377 <dt><i>filename</i> (str)</dt> |
|
378 <dd> |
|
379 name of the file to be processed |
|
380 </dd> |
|
381 <dt><i>isortConfig</i> (isort.Config)</dt> |
|
382 <dd> |
|
383 config object for isort |
|
384 </dd> |
|
385 <dt><i>withDiff</i> (bool (optional))</dt> |
|
386 <dd> |
|
387 flag indicating to return a unified diff, if the file needs to |
|
388 be changed (defaults to True) |
|
389 </dd> |
|
390 </dl> |
|
391 <dl> |
|
392 <dt>Return:</dt> |
|
393 <dd> |
|
394 result object |
|
395 </dd> |
|
396 </dl> |
|
397 <dl> |
|
398 <dt>Return Type:</dt> |
|
399 <dd> |
|
400 IsortResult |
|
401 </dd> |
|
402 </dl> |
|
403 <a NAME="IsortFormattingDialog.__isortSortFile" ID="IsortFormattingDialog.__isortSortFile"></a> |
|
404 <h4>IsortFormattingDialog.__isortSortFile (static)</h4> |
|
405 <b>__isortSortFile</b>(<i>isortConfig</i>) |
|
406 |
|
407 <p> |
|
408 Static method to sort the import statements of a file. |
|
409 </p> |
|
410 <dl> |
|
411 |
|
412 <dt><i>filename</i> (str)</dt> |
|
413 <dd> |
|
414 name of the file to be processed |
|
415 </dd> |
|
416 <dt><i>isortConfig</i> (isort.Config)</dt> |
|
417 <dd> |
|
418 config object for isort |
|
419 </dd> |
|
420 </dl> |
|
421 <dl> |
|
422 <dt>Return:</dt> |
|
423 <dd> |
|
424 result object |
|
425 </dd> |
|
426 </dl> |
|
427 <dl> |
|
428 <dt>Return Type:</dt> |
|
429 <dd> |
|
430 IsortResult |
|
431 </dd> |
|
432 </dl> |
|
433 <a NAME="IsortFormattingDialog.formattingWorkerTask" ID="IsortFormattingDialog.formattingWorkerTask"></a> |
|
434 <h4>IsortFormattingDialog.formattingWorkerTask (static)</h4> |
|
435 <b>formattingWorkerTask</b>(<i>outputQueue, isortConfig</i>) |
|
436 |
|
437 <p> |
|
438 Static method acting as the parallel worker for the formatting task. |
|
439 </p> |
|
440 <dl> |
|
441 |
|
442 <dt><i>inputQueue</i> (multiprocessing.Queue)</dt> |
|
443 <dd> |
|
444 input queue |
|
445 </dd> |
|
446 <dt><i>outputQueue</i> (multiprocessing.Queue)</dt> |
|
447 <dd> |
|
448 output queue |
|
449 </dd> |
|
450 <dt><i>isortConfig</i> (isort.Config)</dt> |
|
451 <dd> |
|
452 config object for isort |
|
453 </dd> |
|
454 </dl> |
|
455 <div align="right"><a href="#top">Up</a></div> |
|
456 <hr /> |
|
457 <hr /> |
|
458 <a NAME="IsortResult" ID="IsortResult"></a> |
|
459 <h2>IsortResult</h2> |
|
460 |
|
461 <p> |
|
462 Class containing the isort reformatting result data. |
|
463 </p> |
|
464 <h3>Derived from</h3> |
|
465 None |
|
466 <h3>Class Attributes</h3> |
|
467 |
|
468 <table> |
|
469 <tr><td>None</td></tr> |
|
470 </table> |
|
471 <h3>Class Methods</h3> |
|
472 |
|
473 <table> |
|
474 <tr><td>None</td></tr> |
|
475 </table> |
|
476 <h3>Methods</h3> |
|
477 |
|
478 <table> |
|
479 <tr><td>None</td></tr> |
|
480 </table> |
|
481 <h3>Static Methods</h3> |
|
482 |
|
483 <table> |
|
484 <tr><td>None</td></tr> |
|
485 </table> |
|
486 |
|
487 <div align="right"><a href="#top">Up</a></div> |
|
488 <hr /> |
|
489 <hr /> |
|
490 <a NAME="IsortStatistics" ID="IsortStatistics"></a> |
|
491 <h2>IsortStatistics</h2> |
|
492 |
|
493 <p> |
|
494 Class containing the isort reformatting statistic data. |
|
495 </p> |
|
496 <h3>Derived from</h3> |
|
497 None |
|
498 <h3>Class Attributes</h3> |
|
499 |
|
500 <table> |
|
501 <tr><td>None</td></tr> |
|
502 </table> |
|
503 <h3>Class Methods</h3> |
|
504 |
|
505 <table> |
|
506 <tr><td>None</td></tr> |
|
507 </table> |
|
508 <h3>Methods</h3> |
|
509 |
|
510 <table> |
|
511 <tr><td>None</td></tr> |
|
512 </table> |
|
513 <h3>Static Methods</h3> |
|
514 |
|
515 <table> |
|
516 <tr><td>None</td></tr> |
|
517 </table> |
|
518 |
|
519 <div align="right"><a href="#top">Up</a></div> |
|
520 <hr /> |
|
521 </body></html> |