eric7.CodeFormatting.BlackFormattingDialog

Module implementing a dialog showing the code formatting progress and the result.

Global Attributes

None

Classes

BlackFormattingDialog Class implementing a dialog showing the code formatting progress and the result.
BlackReport Class extending the black Report to work with our dialog.

Functions

None


BlackFormattingDialog

Class implementing a dialog showing the code formatting progress and the result.

Derived from

QDialog, Ui_BlackFormattingDialog

Class Attributes

DataRole
DataTypeRole
FileNameColumn
StatusColumn

Class Methods

None

Methods

BlackFormattingDialog Constructor
__diffFormatFile Private method to check, if the given files need to be reformatted, and generate a unified diff.
__filterFiles Private method to filter the given list of files according the configuration parameters.
__finish Private method to perform some actions after the run was performed or canceled.
__formatFiles Private method to format the list of files according the configuration.
__populateStatusFilterCombo Private method to populate the status filter combo box with allowed selections.
__resizeColumns Private method to resize the columns of the result list.
__resort Private method to resort the result list.
__updateStatistics Private method to update the statistics about the recent formatting run and make them visible.
addResultEntry Public method to add an entry to the result list.
closeEvent Protected slot implementing a close event handler.
on_buttonBox_clicked Private slot to handle button presses of the dialog buttons.
on_resultsList_itemDoubleClicked Private slot handling a double click of a result item.
on_statusFilterComboBox_currentTextChanged Private slot handling the selection of a status for items to be shown.

Static Methods

None

BlackFormattingDialog (Constructor)

BlackFormattingDialog(configuration, filesList, project=None, action=BlackFormattingAction.Format, parent=None, )

Constructor

configuration (dict)
dictionary containing the configuration parameters
filesList (list of str)
list of absolute file paths to be processed
project (Project (optional))
reference to the project object (defaults to None)
action (BlackFormattingAction (optional))
action to be performed (defaults to BlackFormattingAction.Format)
parent (QWidget (optional))
reference to the parent widget (defaults to None)

BlackFormattingDialog.__diffFormatFile

__diffFormatFile(src, fast, mode, report)

Private method to check, if the given files need to be reformatted, and generate a unified diff.

src (pathlib.Path)
path of file to be checked
fast (bool)
flag indicating fast operation
mode (black.Mode)
code formatting options
report (BlackReport)
reference to the report object

BlackFormattingDialog.__filterFiles

__filterFiles(filesList)

Private method to filter the given list of files according the configuration parameters.

filesList (list of str)
list of files
Return:
list of filtered files
Return Type:
list of str

BlackFormattingDialog.__finish

__finish()

Private method to perform some actions after the run was performed or canceled.

BlackFormattingDialog.__formatFiles

__formatFiles()

Private method to format the list of files according the configuration.

BlackFormattingDialog.__populateStatusFilterCombo

__populateStatusFilterCombo()

Private method to populate the status filter combo box with allowed selections.

BlackFormattingDialog.__resizeColumns

__resizeColumns()

Private method to resize the columns of the result list.

BlackFormattingDialog.__resort

__resort()

Private method to resort the result list.

BlackFormattingDialog.__updateStatistics

__updateStatistics()

Private method to update the statistics about the recent formatting run and make them visible.

BlackFormattingDialog.addResultEntry

addResultEntry(status, fileName, isError=False, data=None)

Public method to add an entry to the result list.

status (str)
status of the operation
fileName (str)
name of the processed file
isError (bool (optional))
flag indicating that data contains an error message (defaults to False)
data (str (optional))
associated data (diff or error message) (defaults to None)

BlackFormattingDialog.closeEvent

closeEvent(evt)

Protected slot implementing a close event handler.

evt (QCloseEvent)
reference to the close event

BlackFormattingDialog.on_buttonBox_clicked

on_buttonBox_clicked(button)

Private slot to handle button presses of the dialog buttons.

button (QAbstractButton)
reference to the pressed button

BlackFormattingDialog.on_resultsList_itemDoubleClicked

on_resultsList_itemDoubleClicked(item, column)

Private slot handling a double click of a result item.

item (QTreeWidgetItem)
reference to the double clicked item
column (int)
column number that was double clicked

BlackFormattingDialog.on_statusFilterComboBox_currentTextChanged

on_statusFilterComboBox_currentTextChanged(status)

Private slot handling the selection of a status for items to be shown.

status (str)
selected status
Up


BlackReport

Class extending the black Report to work with our dialog.

Derived from

black.Report

Class Attributes

None

Class Methods

None

Methods

BlackReport Constructor
done Public method to handle the end of a reformat.
failed Public method to handle a reformat failure.
path_ignored Public method handling an ignored path.

Static Methods

None

BlackReport (Constructor)

BlackReport(dialog)

Constructor

dialog (QDialog)
reference to the result dialog

BlackReport.done

done(src, changed, diff="")

Public method to handle the end of a reformat.

src (pathlib.Path)
name of the processed file
changed (black.Changed)
change status
diff (str)
unified diff of potential changes (defaults to "")

BlackReport.failed

failed(src, message)

Public method to handle a reformat failure.

src (pathlib.Path)
name of the processed file
message (str)
error message

BlackReport.path_ignored

path_ignored(src, message="")

Public method handling an ignored path.

src (pathlib.Path or str)
name of the processed file
message (str (optional))
ignore message (default to "")
Up