src/eric7/Documentation/Source/eric7.CodeFormatting.BlackFormattingDialog.html

branch
eric7
changeset 9215
30d7f7fd2b4a
child 9236
db53a9efe7ef
equal deleted inserted replaced
9214:bd28e56047d7 9215:30d7f7fd2b4a
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric7.CodeFormatting.BlackFormattingDialog</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.BlackFormattingDialog</h1>
10
11 <p>
12 Module implementing a dialog showing the code formatting progress and the result.
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="#BlackFormattingDialog">BlackFormattingDialog</a></td>
25 <td>Class implementing a dialog showing the code formatting progress and the result.</td>
26 </tr>
27 <tr>
28 <td><a href="#BlackReport">BlackReport</a></td>
29 <td>Class extending the black Report to work with our dialog.</td>
30 </tr>
31 </table>
32 <h3>Functions</h3>
33
34 <table>
35 <tr><td>None</td></tr>
36 </table>
37 <hr />
38 <hr />
39 <a NAME="BlackFormattingDialog" ID="BlackFormattingDialog"></a>
40 <h2>BlackFormattingDialog</h2>
41
42 <p>
43 Class implementing a dialog showing the code formatting progress and the result.
44 </p>
45 <h3>Derived from</h3>
46 QDialog, Ui_BlackFormattingDialog
47 <h3>Class Attributes</h3>
48
49 <table>
50 <tr><td>DataRole</td></tr><tr><td>DataTypeRole</td></tr>
51 </table>
52 <h3>Class Methods</h3>
53
54 <table>
55 <tr><td>None</td></tr>
56 </table>
57 <h3>Methods</h3>
58
59 <table>
60
61 <tr>
62 <td><a href="#BlackFormattingDialog.__init__">BlackFormattingDialog</a></td>
63 <td>Constructor</td>
64 </tr>
65 <tr>
66 <td><a href="#BlackFormattingDialog.__diffFormatFile">__diffFormatFile</a></td>
67 <td>Private method to check, if the given files need to be reformatted, and generate a unified diff.</td>
68 </tr>
69 <tr>
70 <td><a href="#BlackFormattingDialog.__filterFiles">__filterFiles</a></td>
71 <td>Private method to filter the given list of files according the configuration parameters.</td>
72 </tr>
73 <tr>
74 <td><a href="#BlackFormattingDialog.__finish">__finish</a></td>
75 <td>Private method to perform some actions after the run was performed or canceled.</td>
76 </tr>
77 <tr>
78 <td><a href="#BlackFormattingDialog.__formatFiles">__formatFiles</a></td>
79 <td>Private method to format the list of files according the configuration.</td>
80 </tr>
81 <tr>
82 <td><a href="#BlackFormattingDialog.__resizeColumns">__resizeColumns</a></td>
83 <td>Private method to resize the columns of the result list.</td>
84 </tr>
85 <tr>
86 <td><a href="#BlackFormattingDialog.__resort">__resort</a></td>
87 <td>Private method to resort the result list.</td>
88 </tr>
89 <tr>
90 <td><a href="#BlackFormattingDialog.__updateStatistics">__updateStatistics</a></td>
91 <td>Private method to update the statistics about the recent formatting run.</td>
92 </tr>
93 <tr>
94 <td><a href="#BlackFormattingDialog.addResultEntry">addResultEntry</a></td>
95 <td>Public method to add an entry to the result list.</td>
96 </tr>
97 <tr>
98 <td><a href="#BlackFormattingDialog.closeEvent">closeEvent</a></td>
99 <td>Protected slot implementing a close event handler.</td>
100 </tr>
101 <tr>
102 <td><a href="#BlackFormattingDialog.on_buttonBox_clicked">on_buttonBox_clicked</a></td>
103 <td>Private slot to handle button presses of the dialog buttons.</td>
104 </tr>
105 <tr>
106 <td><a href="#BlackFormattingDialog.on_resultsList_itemDoubleClicked">on_resultsList_itemDoubleClicked</a></td>
107 <td>Private slot handling a double click of a result item.</td>
108 </tr>
109 </table>
110 <h3>Static Methods</h3>
111
112 <table>
113 <tr><td>None</td></tr>
114 </table>
115
116 <a NAME="BlackFormattingDialog.__init__" ID="BlackFormattingDialog.__init__"></a>
117 <h4>BlackFormattingDialog (Constructor)</h4>
118 <b>BlackFormattingDialog</b>(<i>configuration, filesList, project=None, action=BlackFormattingAction.Format, parent=None</i>)
119
120 <p>
121 Constructor
122 </p>
123 <dl>
124
125 <dt><i>configuration</i> (dict)</dt>
126 <dd>
127 dictionary containing the configuration parameters
128 </dd>
129 <dt><i>filesList</i> (list of str)</dt>
130 <dd>
131 list of absolute file paths to be processed
132 </dd>
133 <dt><i>project</i> (Project (optional))</dt>
134 <dd>
135 reference to the project object (defaults to None)
136 </dd>
137 <dt><i>action</i> (BlackFormattingAction (optional))</dt>
138 <dd>
139 action to be performed (defaults to BlackFormattingAction.Format)
140 </dd>
141 <dt><i>parent</i> (QWidget (optional))</dt>
142 <dd>
143 reference to the parent widget (defaults to None)
144 </dd>
145 </dl>
146 <a NAME="BlackFormattingDialog.__diffFormatFile" ID="BlackFormattingDialog.__diffFormatFile"></a>
147 <h4>BlackFormattingDialog.__diffFormatFile</h4>
148 <b>__diffFormatFile</b>(<i>src, fast, mode, report</i>)
149
150 <p>
151 Private method to check, if the given files need to be reformatted, and generate
152 a unified diff.
153 </p>
154 <dl>
155
156 <dt><i>src</i> (pathlib.Path)</dt>
157 <dd>
158 path of file to be checked
159 </dd>
160 <dt><i>fast</i> (bool)</dt>
161 <dd>
162 flag indicating fast operation
163 </dd>
164 <dt><i>mode</i> (black.Mode)</dt>
165 <dd>
166 code formatting options
167 </dd>
168 <dt><i>report</i> (BlackReport)</dt>
169 <dd>
170 reference to the report object
171 </dd>
172 </dl>
173 <a NAME="BlackFormattingDialog.__filterFiles" ID="BlackFormattingDialog.__filterFiles"></a>
174 <h4>BlackFormattingDialog.__filterFiles</h4>
175 <b>__filterFiles</b>(<i>filesList</i>)
176
177 <p>
178 Private method to filter the given list of files according the
179 configuration parameters.
180 </p>
181 <dl>
182
183 <dt><i>filesList</i> (list of str)</dt>
184 <dd>
185 list of files
186 </dd>
187 </dl>
188 <dl>
189 <dt>Return:</dt>
190 <dd>
191 list of filtered files
192 </dd>
193 </dl>
194 <dl>
195 <dt>Return Type:</dt>
196 <dd>
197 list of str
198 </dd>
199 </dl>
200 <a NAME="BlackFormattingDialog.__finish" ID="BlackFormattingDialog.__finish"></a>
201 <h4>BlackFormattingDialog.__finish</h4>
202 <b>__finish</b>(<i></i>)
203
204 <p>
205 Private method to perform some actions after the run was performed or canceled.
206 </p>
207 <a NAME="BlackFormattingDialog.__formatFiles" ID="BlackFormattingDialog.__formatFiles"></a>
208 <h4>BlackFormattingDialog.__formatFiles</h4>
209 <b>__formatFiles</b>(<i></i>)
210
211 <p>
212 Private method to format the list of files according the configuration.
213 </p>
214 <a NAME="BlackFormattingDialog.__resizeColumns" ID="BlackFormattingDialog.__resizeColumns"></a>
215 <h4>BlackFormattingDialog.__resizeColumns</h4>
216 <b>__resizeColumns</b>(<i></i>)
217
218 <p>
219 Private method to resize the columns of the result list.
220 </p>
221 <a NAME="BlackFormattingDialog.__resort" ID="BlackFormattingDialog.__resort"></a>
222 <h4>BlackFormattingDialog.__resort</h4>
223 <b>__resort</b>(<i></i>)
224
225 <p>
226 Private method to resort the result list.
227 </p>
228 <a NAME="BlackFormattingDialog.__updateStatistics" ID="BlackFormattingDialog.__updateStatistics"></a>
229 <h4>BlackFormattingDialog.__updateStatistics</h4>
230 <b>__updateStatistics</b>(<i></i>)
231
232 <p>
233 Private method to update the statistics about the recent formatting run.
234 </p>
235 <a NAME="BlackFormattingDialog.addResultEntry" ID="BlackFormattingDialog.addResultEntry"></a>
236 <h4>BlackFormattingDialog.addResultEntry</h4>
237 <b>addResultEntry</b>(<i>status, fileName, isError=False, data=None</i>)
238
239 <p>
240 Public method to add an entry to the result list.
241 </p>
242 <dl>
243
244 <dt><i>status</i> (str)</dt>
245 <dd>
246 status of the operation
247 </dd>
248 <dt><i>fileName</i> (str)</dt>
249 <dd>
250 name of the processed file
251 </dd>
252 <dt><i>isError</i> (bool (optional))</dt>
253 <dd>
254 flag indicating that data contains an error message (defaults to
255 False)
256 </dd>
257 <dt><i>data</i> (str (optional))</dt>
258 <dd>
259 associated data (diff or error message) (defaults to None)
260 </dd>
261 </dl>
262 <a NAME="BlackFormattingDialog.closeEvent" ID="BlackFormattingDialog.closeEvent"></a>
263 <h4>BlackFormattingDialog.closeEvent</h4>
264 <b>closeEvent</b>(<i>evt</i>)
265
266 <p>
267 Protected slot implementing a close event handler.
268 </p>
269 <dl>
270
271 <dt><i>evt</i> (QCloseEvent)</dt>
272 <dd>
273 reference to the close event
274 </dd>
275 </dl>
276 <a NAME="BlackFormattingDialog.on_buttonBox_clicked" ID="BlackFormattingDialog.on_buttonBox_clicked"></a>
277 <h4>BlackFormattingDialog.on_buttonBox_clicked</h4>
278 <b>on_buttonBox_clicked</b>(<i>button</i>)
279
280 <p>
281 Private slot to handle button presses of the dialog buttons.
282 </p>
283 <dl>
284
285 <dt><i>button</i> (QAbstractButton)</dt>
286 <dd>
287 reference to the pressed button
288 </dd>
289 </dl>
290 <a NAME="BlackFormattingDialog.on_resultsList_itemDoubleClicked" ID="BlackFormattingDialog.on_resultsList_itemDoubleClicked"></a>
291 <h4>BlackFormattingDialog.on_resultsList_itemDoubleClicked</h4>
292 <b>on_resultsList_itemDoubleClicked</b>(<i>item, column</i>)
293
294 <p>
295 Private slot handling a double click of a result item.
296 </p>
297 <dl>
298
299 <dt><i>item</i> (QTreeWidgetItem)</dt>
300 <dd>
301 reference to the double clicked item
302 </dd>
303 <dt><i>column</i> (int)</dt>
304 <dd>
305 column number that was double clicked
306 </dd>
307 </dl>
308 <div align="right"><a href="#top">Up</a></div>
309 <hr />
310 <hr />
311 <a NAME="BlackReport" ID="BlackReport"></a>
312 <h2>BlackReport</h2>
313
314 <p>
315 Class extending the black Report to work with our dialog.
316 </p>
317 <h3>Derived from</h3>
318 black.Report
319 <h3>Class Attributes</h3>
320
321 <table>
322 <tr><td>None</td></tr>
323 </table>
324 <h3>Class Methods</h3>
325
326 <table>
327 <tr><td>None</td></tr>
328 </table>
329 <h3>Methods</h3>
330
331 <table>
332
333 <tr>
334 <td><a href="#BlackReport.__init__">BlackReport</a></td>
335 <td>Constructor</td>
336 </tr>
337 <tr>
338 <td><a href="#BlackReport.done">done</a></td>
339 <td>Public method to handle the end of a reformat.</td>
340 </tr>
341 <tr>
342 <td><a href="#BlackReport.failed">failed</a></td>
343 <td>Public method to handle a reformat failure.</td>
344 </tr>
345 <tr>
346 <td><a href="#BlackReport.path_ignored">path_ignored</a></td>
347 <td>Public method handling an ignored path.</td>
348 </tr>
349 </table>
350 <h3>Static Methods</h3>
351
352 <table>
353 <tr><td>None</td></tr>
354 </table>
355
356 <a NAME="BlackReport.__init__" ID="BlackReport.__init__"></a>
357 <h4>BlackReport (Constructor)</h4>
358 <b>BlackReport</b>(<i>dialog</i>)
359
360 <p>
361 Constructor
362 </p>
363 <dl>
364
365 <dt><i>dialog</i> (QDialog)</dt>
366 <dd>
367 reference to the result dialog
368 </dd>
369 </dl>
370 <a NAME="BlackReport.done" ID="BlackReport.done"></a>
371 <h4>BlackReport.done</h4>
372 <b>done</b>(<i>src, changed, diff=""</i>)
373
374 <p>
375 Public method to handle the end of a reformat.
376 </p>
377 <dl>
378
379 <dt><i>src</i> (pathlib.Path)</dt>
380 <dd>
381 name of the processed file
382 </dd>
383 <dt><i>changed</i> (black.Changed)</dt>
384 <dd>
385 change status
386 </dd>
387 <dt><i>diff</i> (str)</dt>
388 <dd>
389 unified diff of potential changes (defaults to "")
390 </dd>
391 </dl>
392 <a NAME="BlackReport.failed" ID="BlackReport.failed"></a>
393 <h4>BlackReport.failed</h4>
394 <b>failed</b>(<i>src, message</i>)
395
396 <p>
397 Public method to handle a reformat failure.
398 </p>
399 <dl>
400
401 <dt><i>src</i> (pathlib.Path)</dt>
402 <dd>
403 name of the processed file
404 </dd>
405 <dt><i>message</i> (str)</dt>
406 <dd>
407 error message
408 </dd>
409 </dl>
410 <a NAME="BlackReport.path_ignored" ID="BlackReport.path_ignored"></a>
411 <h4>BlackReport.path_ignored</h4>
412 <b>path_ignored</b>(<i>src, message=""</i>)
413
414 <p>
415 Public method handling an ignored path.
416 </p>
417 <dl>
418
419 <dt><i>src</i> (pathlib.Path or str)</dt>
420 <dd>
421 name of the processed file
422 </dd>
423 <dt><i>message</i> (str (optional))</dt>
424 <dd>
425 ignore message (default to "")
426 </dd>
427 </dl>
428 <div align="right"><a href="#top">Up</a></div>
429 <hr />
430 </body></html>

eric ide

mercurial