src/eric7/CodeFormatting/BlackFormattingDialog.py

branch
eric7
changeset 9453
e5065dde905d
parent 9413
80c06d472826
child 9460
0d1b5d0fd815
equal deleted inserted replaced
9452:325c6de4b1f5 9453:e5065dde905d
2 2
3 # Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing a dialog showing the code formatting progress and the result. 7 Module implementing a dialog showing the Black code formatting progress and the results.
8 """ 8 """
9 9
10 import copy 10 import copy
11 import datetime 11 import datetime
12 import multiprocessing 12 import multiprocessing
28 from eric7.EricWidgets import EricMessageBox 28 from eric7.EricWidgets import EricMessageBox
29 29
30 from .Ui_BlackFormattingDialog import Ui_BlackFormattingDialog 30 from .Ui_BlackFormattingDialog import Ui_BlackFormattingDialog
31 31
32 from . import BlackUtilities 32 from . import BlackUtilities
33 from .BlackDiffWidget import BlackDiffWidget 33 from .FormattingDiffWidget import FormattingDiffWidget
34 from .BlackFormattingAction import BlackFormattingAction 34 from .BlackFormattingAction import BlackFormattingAction
35 35
36 from eric7 import Preferences, Utilities 36 from eric7 import Preferences, Utilities
37 37
38 38
39 class BlackFormattingDialog(QDialog, Ui_BlackFormattingDialog): 39 class BlackFormattingDialog(QDialog, Ui_BlackFormattingDialog):
40 """ 40 """
41 Class implementing a dialog showing the code formatting progress and the result. 41 Class implementing a dialog showing the Black code formatting progress and the
42 results.
42 """ 43 """
43 44
44 DataTypeRole = Qt.ItemDataRole.UserRole 45 DataTypeRole = Qt.ItemDataRole.UserRole
45 DataRole = Qt.ItemDataRole.UserRole + 1 46 DataRole = Qt.ItemDataRole.UserRole + 1
46 47
96 97
97 self.__performAction() 98 self.__performAction()
98 99
99 def __performAction(self): 100 def __performAction(self):
100 """ 101 """
101 Private method to exceute the requested formatting action. 102 Private method to execute the requested formatting action.
102 """ 103 """
103 self.progressBar.setValue(0) 104 self.progressBar.setValue(0)
104 self.progressBar.setVisible(True) 105 self.progressBar.setVisible(True)
105 106
106 self.statisticsGroup.setVisible(False) 107 self.statisticsGroup.setVisible(False)
275 item.data(0, BlackFormattingDialog.DataRole) 276 item.data(0, BlackFormattingDialog.DataRole)
276 ), 277 ),
277 ) 278 )
278 elif dataType == "diff": 279 elif dataType == "diff":
279 if self.__diffDialog is None: 280 if self.__diffDialog is None:
280 self.__diffDialog = BlackDiffWidget() 281 self.__diffDialog = FormattingDiffWidget()
281 self.__diffDialog.showDiff(item.data(0, BlackFormattingDialog.DataRole)) 282 self.__diffDialog.showDiff(item.data(0, BlackFormattingDialog.DataRole))
282 283
283 def __formatManyFiles(self, files): 284 def __formatManyFiles(self, files):
284 """ 285 """
285 Private method to format the list of files according the configuration using 286 Private method to format the list of files according the configuration using
518 @pyqtSlot(str, str, str) 519 @pyqtSlot(str, str, str)
519 def __handleBlackFormattingResult(self, status, filename, data): 520 def __handleBlackFormattingResult(self, status, filename, data):
520 """ 521 """
521 Private slot to handle the result of a black reformatting action. 522 Private slot to handle the result of a black reformatting action.
522 523
523 @param status status of the performed action (one of 'changed', 'unchanged', 524 @param status status of the performed action (one of 'changed', 'failed',
524 'unmodified', 'failed' or 'ignored') 525 'ignored', 'unchanged' or 'unmodified')
525 @type str 526 @type str
526 @param filename name of the processed file 527 @param filename name of the processed file
527 @type str 528 @type str
528 @param data action data (error message or unified diff) 529 @param data action data (error message or unified diff)
529 @type str 530 @type str

eric ide

mercurial