Thu, 14 Jul 2022 16:09:37 +0200
Updated source documentation.
<!DOCTYPE html> <html><head> <title>eric7.CodeFormatting.BlackFormattingDialog</title> <meta charset="UTF-8"> <link rel="stylesheet" href="styles.css"> </head> <body> <a NAME="top" ID="top"></a> <h1>eric7.CodeFormatting.BlackFormattingDialog</h1> <p> Module implementing a dialog showing the code formatting progress and the result. </p> <h3>Global Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Classes</h3> <table> <tr> <td><a href="#BlackFormattingDialog">BlackFormattingDialog</a></td> <td>Class implementing a dialog showing the code formatting progress and the result.</td> </tr> <tr> <td><a href="#BlackReport">BlackReport</a></td> <td>Class extending the black Report to work with our dialog.</td> </tr> </table> <h3>Functions</h3> <table> <tr><td>None</td></tr> </table> <hr /> <hr /> <a NAME="BlackFormattingDialog" ID="BlackFormattingDialog"></a> <h2>BlackFormattingDialog</h2> <p> Class implementing a dialog showing the code formatting progress and the result. </p> <h3>Derived from</h3> QDialog, Ui_BlackFormattingDialog <h3>Class Attributes</h3> <table> <tr><td>DataRole</td></tr><tr><td>DataTypeRole</td></tr><tr><td>FileNameColumn</td></tr><tr><td>StatusColumn</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#BlackFormattingDialog.__init__">BlackFormattingDialog</a></td> <td>Constructor</td> </tr> <tr> <td><a href="#BlackFormattingDialog.__diffFormatFile">__diffFormatFile</a></td> <td>Private method to check, if the given files need to be reformatted, and generate a unified diff.</td> </tr> <tr> <td><a href="#BlackFormattingDialog.__filterFiles">__filterFiles</a></td> <td>Private method to filter the given list of files according the configuration parameters.</td> </tr> <tr> <td><a href="#BlackFormattingDialog.__finish">__finish</a></td> <td>Private method to perform some actions after the run was performed or canceled.</td> </tr> <tr> <td><a href="#BlackFormattingDialog.__formatFiles">__formatFiles</a></td> <td>Private method to format the list of files according the configuration.</td> </tr> <tr> <td><a href="#BlackFormattingDialog.__populateStatusFilterCombo">__populateStatusFilterCombo</a></td> <td>Private method to populate the status filter combo box with allowed selections.</td> </tr> <tr> <td><a href="#BlackFormattingDialog.__resizeColumns">__resizeColumns</a></td> <td>Private method to resize the columns of the result list.</td> </tr> <tr> <td><a href="#BlackFormattingDialog.__resort">__resort</a></td> <td>Private method to resort the result list.</td> </tr> <tr> <td><a href="#BlackFormattingDialog.__updateStatistics">__updateStatistics</a></td> <td>Private method to update the statistics about the recent formatting run and make them visible.</td> </tr> <tr> <td><a href="#BlackFormattingDialog.addResultEntry">addResultEntry</a></td> <td>Public method to add an entry to the result list.</td> </tr> <tr> <td><a href="#BlackFormattingDialog.closeEvent">closeEvent</a></td> <td>Protected slot implementing a close event handler.</td> </tr> <tr> <td><a href="#BlackFormattingDialog.on_buttonBox_clicked">on_buttonBox_clicked</a></td> <td>Private slot to handle button presses of the dialog buttons.</td> </tr> <tr> <td><a href="#BlackFormattingDialog.on_resultsList_itemDoubleClicked">on_resultsList_itemDoubleClicked</a></td> <td>Private slot handling a double click of a result item.</td> </tr> <tr> <td><a href="#BlackFormattingDialog.on_statusFilterComboBox_currentTextChanged">on_statusFilterComboBox_currentTextChanged</a></td> <td>Private slot handling the selection of a status for items to be shown.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="BlackFormattingDialog.__init__" ID="BlackFormattingDialog.__init__"></a> <h4>BlackFormattingDialog (Constructor)</h4> <b>BlackFormattingDialog</b>(<i>configuration, filesList, project=None, action=BlackFormattingAction.Format, parent=None, </i>) <p> Constructor </p> <dl> <dt><i>configuration</i> (dict)</dt> <dd> dictionary containing the configuration parameters </dd> <dt><i>filesList</i> (list of str)</dt> <dd> list of absolute file paths to be processed </dd> <dt><i>project</i> (Project (optional))</dt> <dd> reference to the project object (defaults to None) </dd> <dt><i>action</i> (BlackFormattingAction (optional))</dt> <dd> action to be performed (defaults to BlackFormattingAction.Format) </dd> <dt><i>parent</i> (QWidget (optional))</dt> <dd> reference to the parent widget (defaults to None) </dd> </dl> <a NAME="BlackFormattingDialog.__diffFormatFile" ID="BlackFormattingDialog.__diffFormatFile"></a> <h4>BlackFormattingDialog.__diffFormatFile</h4> <b>__diffFormatFile</b>(<i>src, fast, mode, report</i>) <p> Private method to check, if the given files need to be reformatted, and generate a unified diff. </p> <dl> <dt><i>src</i> (pathlib.Path)</dt> <dd> path of file to be checked </dd> <dt><i>fast</i> (bool)</dt> <dd> flag indicating fast operation </dd> <dt><i>mode</i> (black.Mode)</dt> <dd> code formatting options </dd> <dt><i>report</i> (BlackReport)</dt> <dd> reference to the report object </dd> </dl> <a NAME="BlackFormattingDialog.__filterFiles" ID="BlackFormattingDialog.__filterFiles"></a> <h4>BlackFormattingDialog.__filterFiles</h4> <b>__filterFiles</b>(<i>filesList</i>) <p> Private method to filter the given list of files according the configuration parameters. </p> <dl> <dt><i>filesList</i> (list of str)</dt> <dd> list of files </dd> </dl> <dl> <dt>Return:</dt> <dd> list of filtered files </dd> </dl> <dl> <dt>Return Type:</dt> <dd> list of str </dd> </dl> <a NAME="BlackFormattingDialog.__finish" ID="BlackFormattingDialog.__finish"></a> <h4>BlackFormattingDialog.__finish</h4> <b>__finish</b>(<i></i>) <p> Private method to perform some actions after the run was performed or canceled. </p> <a NAME="BlackFormattingDialog.__formatFiles" ID="BlackFormattingDialog.__formatFiles"></a> <h4>BlackFormattingDialog.__formatFiles</h4> <b>__formatFiles</b>(<i></i>) <p> Private method to format the list of files according the configuration. </p> <a NAME="BlackFormattingDialog.__populateStatusFilterCombo" ID="BlackFormattingDialog.__populateStatusFilterCombo"></a> <h4>BlackFormattingDialog.__populateStatusFilterCombo</h4> <b>__populateStatusFilterCombo</b>(<i></i>) <p> Private method to populate the status filter combo box with allowed selections. </p> <a NAME="BlackFormattingDialog.__resizeColumns" ID="BlackFormattingDialog.__resizeColumns"></a> <h4>BlackFormattingDialog.__resizeColumns</h4> <b>__resizeColumns</b>(<i></i>) <p> Private method to resize the columns of the result list. </p> <a NAME="BlackFormattingDialog.__resort" ID="BlackFormattingDialog.__resort"></a> <h4>BlackFormattingDialog.__resort</h4> <b>__resort</b>(<i></i>) <p> Private method to resort the result list. </p> <a NAME="BlackFormattingDialog.__updateStatistics" ID="BlackFormattingDialog.__updateStatistics"></a> <h4>BlackFormattingDialog.__updateStatistics</h4> <b>__updateStatistics</b>(<i></i>) <p> Private method to update the statistics about the recent formatting run and make them visible. </p> <a NAME="BlackFormattingDialog.addResultEntry" ID="BlackFormattingDialog.addResultEntry"></a> <h4>BlackFormattingDialog.addResultEntry</h4> <b>addResultEntry</b>(<i>status, fileName, isError=False, data=None</i>) <p> Public method to add an entry to the result list. </p> <dl> <dt><i>status</i> (str)</dt> <dd> status of the operation </dd> <dt><i>fileName</i> (str)</dt> <dd> name of the processed file </dd> <dt><i>isError</i> (bool (optional))</dt> <dd> flag indicating that data contains an error message (defaults to False) </dd> <dt><i>data</i> (str (optional))</dt> <dd> associated data (diff or error message) (defaults to None) </dd> </dl> <a NAME="BlackFormattingDialog.closeEvent" ID="BlackFormattingDialog.closeEvent"></a> <h4>BlackFormattingDialog.closeEvent</h4> <b>closeEvent</b>(<i>evt</i>) <p> Protected slot implementing a close event handler. </p> <dl> <dt><i>evt</i> (QCloseEvent)</dt> <dd> reference to the close event </dd> </dl> <a NAME="BlackFormattingDialog.on_buttonBox_clicked" ID="BlackFormattingDialog.on_buttonBox_clicked"></a> <h4>BlackFormattingDialog.on_buttonBox_clicked</h4> <b>on_buttonBox_clicked</b>(<i>button</i>) <p> Private slot to handle button presses of the dialog buttons. </p> <dl> <dt><i>button</i> (QAbstractButton)</dt> <dd> reference to the pressed button </dd> </dl> <a NAME="BlackFormattingDialog.on_resultsList_itemDoubleClicked" ID="BlackFormattingDialog.on_resultsList_itemDoubleClicked"></a> <h4>BlackFormattingDialog.on_resultsList_itemDoubleClicked</h4> <b>on_resultsList_itemDoubleClicked</b>(<i>item, column</i>) <p> Private slot handling a double click of a result item. </p> <dl> <dt><i>item</i> (QTreeWidgetItem)</dt> <dd> reference to the double clicked item </dd> <dt><i>column</i> (int)</dt> <dd> column number that was double clicked </dd> </dl> <a NAME="BlackFormattingDialog.on_statusFilterComboBox_currentTextChanged" ID="BlackFormattingDialog.on_statusFilterComboBox_currentTextChanged"></a> <h4>BlackFormattingDialog.on_statusFilterComboBox_currentTextChanged</h4> <b>on_statusFilterComboBox_currentTextChanged</b>(<i>status</i>) <p> Private slot handling the selection of a status for items to be shown. </p> <dl> <dt><i>status</i> (str)</dt> <dd> selected status </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> <a NAME="BlackReport" ID="BlackReport"></a> <h2>BlackReport</h2> <p> Class extending the black Report to work with our dialog. </p> <h3>Derived from</h3> black.Report <h3>Class Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#BlackReport.__init__">BlackReport</a></td> <td>Constructor</td> </tr> <tr> <td><a href="#BlackReport.done">done</a></td> <td>Public method to handle the end of a reformat.</td> </tr> <tr> <td><a href="#BlackReport.failed">failed</a></td> <td>Public method to handle a reformat failure.</td> </tr> <tr> <td><a href="#BlackReport.path_ignored">path_ignored</a></td> <td>Public method handling an ignored path.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="BlackReport.__init__" ID="BlackReport.__init__"></a> <h4>BlackReport (Constructor)</h4> <b>BlackReport</b>(<i>dialog</i>) <p> Constructor </p> <dl> <dt><i>dialog</i> (QDialog)</dt> <dd> reference to the result dialog </dd> </dl> <a NAME="BlackReport.done" ID="BlackReport.done"></a> <h4>BlackReport.done</h4> <b>done</b>(<i>src, changed, diff=""</i>) <p> Public method to handle the end of a reformat. </p> <dl> <dt><i>src</i> (pathlib.Path)</dt> <dd> name of the processed file </dd> <dt><i>changed</i> (black.Changed)</dt> <dd> change status </dd> <dt><i>diff</i> (str)</dt> <dd> unified diff of potential changes (defaults to "") </dd> </dl> <a NAME="BlackReport.failed" ID="BlackReport.failed"></a> <h4>BlackReport.failed</h4> <b>failed</b>(<i>src, message</i>) <p> Public method to handle a reformat failure. </p> <dl> <dt><i>src</i> (pathlib.Path)</dt> <dd> name of the processed file </dd> <dt><i>message</i> (str)</dt> <dd> error message </dd> </dl> <a NAME="BlackReport.path_ignored" ID="BlackReport.path_ignored"></a> <h4>BlackReport.path_ignored</h4> <b>path_ignored</b>(<i>src, message=""</i>) <p> Public method handling an ignored path. </p> <dl> <dt><i>src</i> (pathlib.Path or str)</dt> <dd> name of the processed file </dd> <dt><i>message</i> (str (optional))</dt> <dd> ignore message (default to "") </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> </body></html>