eric7.CodeFormatting.IsortFormattingDialog

Module implementing a dialog showing the isort code formatting progress and the results.

Global Attributes

None

Classes

IsortFormattingDialog Class implementing a dialog showing the isort code formatting progress and the results.
IsortResult Class containing the isort result data.
IsortStatistics Class containing the isort statistic data.

Functions

None


IsortFormattingDialog

Class implementing a dialog showing the isort code formatting progress and the results.

Derived from

QDialog, Ui_IsortFormattingDialog

Class Attributes

DataRole
DataTypeRole
FileNameColumn
FileNameRole
StatusColumn
StatusRole

Class Methods

None

Methods

IsortFormattingDialog Constructor
__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.
__handleIsortResult Private method to handle an isort sorting result.
__performAction Private method to execute the requested sorting action.
__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.
__sortImportsButtonClicked Private slot handling the selection of the 'Sort Imports' button.
__sortManyFiles Private method to sort imports of the list of files according the configuration using multiple processes in parallel.
__sortOneFile Private method to sort the imports of the list of files according the configuration.
__updateStatistics Private method to update the statistics about the recent sorting run and make them visible.
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

__isortCheckFile Static method to check, if a file's import statements need to be changed.
__isortSortFile Static method to sort the import statements of a file.
sortingWorkerTask Static method acting as the parallel worker for the formatting task.

IsortFormattingDialog (Constructor)

IsortFormattingDialog(configuration, filesList, project=None, action=IsortFormattingAction.Sort, 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 (IsortFormattingAction (optional))
action to be performed (defaults to IsortFormattingAction.Sort)
parent (QWidget (optional))
reference to the parent widget (defaults to None)

IsortFormattingDialog.__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

IsortFormattingDialog.__finish

__finish()

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

IsortFormattingDialog.__handleIsortResult

__handleIsortResult(filename, status, data="")

Private method to handle an isort sorting result.

filename (str)
name of the processed file
status (str)
status of the performed action (one of 'changed', 'failed', 'skipped' or 'unchanged')
data (str (optional))
action data (error message or unified diff) (defaults to "")

IsortFormattingDialog.__performAction

__performAction()

Private method to execute the requested sorting action.

IsortFormattingDialog.__populateStatusFilterCombo

__populateStatusFilterCombo()

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

IsortFormattingDialog.__resizeColumns

__resizeColumns()

Private method to resize the columns of the result list.

IsortFormattingDialog.__resort

__resort()

Private method to resort the result list.

IsortFormattingDialog.__sortImportsButtonClicked

__sortImportsButtonClicked()

Private slot handling the selection of the 'Sort Imports' button.

IsortFormattingDialog.__sortManyFiles

__sortManyFiles(files)

Private method to sort imports of the list of files according the configuration using multiple processes in parallel.

files (list of str)
list of files to be processed

IsortFormattingDialog.__sortOneFile

__sortOneFile(file)

Private method to sort the imports of the list of files according the configuration.

file (str)
name of the file to be processed

IsortFormattingDialog.__updateStatistics

__updateStatistics()

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

IsortFormattingDialog.closeEvent

closeEvent(evt)

Protected slot implementing a close event handler.

evt (QCloseEvent)
reference to the close event

IsortFormattingDialog.on_buttonBox_clicked

on_buttonBox_clicked(button)

Private slot to handle button presses of the dialog buttons.

button (QAbstractButton)
reference to the pressed button

IsortFormattingDialog.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 (unused)

IsortFormattingDialog.on_statusFilterComboBox_currentTextChanged

on_statusFilterComboBox_currentTextChanged(status)

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

status (str)
selected status

IsortFormattingDialog.__isortCheckFile (static)

__isortCheckFile(isortConfig, withDiff=True)

Static method to check, if a file's import statements need to be changed.

filename (str)
name of the file to be processed
isortConfig (isort.Config)
config object for isort
withDiff (bool (optional))
flag indicating to return a unified diff, if the file needs to be changed (defaults to True)
Return:
result object
Return Type:
IsortResult

IsortFormattingDialog.__isortSortFile (static)

__isortSortFile(isortConfig)

Static method to sort the import statements of a file.

filename (str)
name of the file to be processed
isortConfig (isort.Config)
config object for isort
Return:
result object
Return Type:
IsortResult

IsortFormattingDialog.sortingWorkerTask (static)

sortingWorkerTask(outputQueue, isortConfig)

Static method acting as the parallel worker for the formatting task.

inputQueue (multiprocessing.Queue)
input queue
outputQueue (multiprocessing.Queue)
output queue
isortConfig (isort.Config)
config object for isort
Up


IsortResult

Class containing the isort result data.

Derived from

None

Class Attributes

data
filename
status

Class Methods

None

Methods

None

Static Methods

None
Up


IsortStatistics

Class containing the isort statistic data.

Derived from

None

Class Attributes

changeCount
failureCount
processedCount
sameCount
skippedCount

Class Methods

None

Methods

None

Static Methods

None
Up