Plugins/CheckerPlugins/Pep8/CodeStyleCheckerDialog.py

changeset 2980
2cb4e3c50b37
parent 2979
e2eee1b09664
equal deleted inserted replaced
2979:e2eee1b09664 2980:2cb4e3c50b37
2 2
3 # Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing a dialog to show the results of the PEP 8 check. 7 Module implementing a dialog to show the results of the code style check.
8 """ 8 """
9 9
10 import os 10 import os
11 import fnmatch 11 import fnmatch
12 12
69 return code 69 return code
70 70
71 71
72 class CodeStyleCheckerDialog(QDialog, Ui_CodeStyleCheckerDialog): 72 class CodeStyleCheckerDialog(QDialog, Ui_CodeStyleCheckerDialog):
73 """ 73 """
74 Class implementing a dialog to show the results of the PEP 8 check. 74 Class implementing a dialog to show the results of the code style check.
75 """ 75 """
76 filenameRole = Qt.UserRole + 1 76 filenameRole = Qt.UserRole + 1
77 lineRole = Qt.UserRole + 2 77 lineRole = Qt.UserRole + 2
78 positionRole = Qt.UserRole + 3 78 positionRole = Qt.UserRole + 3
79 messageRole = Qt.UserRole + 4 79 messageRole = Qt.UserRole + 4
211 """ 211 """
212 Private method to update the collected statistics. 212 Private method to update the collected statistics.
213 213
214 @param statistics dictionary of statistical data with 214 @param statistics dictionary of statistical data with
215 message code as key and message count as value 215 message code as key and message count as value
216 @param fixer reference to the PEP 8 fixer (CodeStyleFixer) 216 @param fixer reference to the code style fixer (CodeStyleFixer)
217 """ 217 """
218 self.__statistics["_FilesCount"] += 1 218 self.__statistics["_FilesCount"] += 1
219 stats = {v: k for v, k in statistics.items() if v[0].isupper()} 219 stats = {v: k for v, k in statistics.items() if v[0].isupper()}
220 if stats: 220 if stats:
221 self.__statistics["_FilesIssues"] += 1 221 self.__statistics["_FilesIssues"] += 1
229 229
230 def __updateFixerStatistics(self, fixer): 230 def __updateFixerStatistics(self, fixer):
231 """ 231 """
232 Private method to update the collected fixer related statistics. 232 Private method to update the collected fixer related statistics.
233 233
234 @param fixer reference to the PEP 8 fixer (CodeStyleFixer) 234 @param fixer reference to the code style fixer (CodeStyleFixer)
235 """ 235 """
236 self.__statistics["_IssuesFixed"] += fixer.fixed 236 self.__statistics["_IssuesFixed"] += fixer.fixed
237 237
238 def __resetStatistics(self): 238 def __resetStatistics(self):
239 """ 239 """
292 self.docTypeComboBox.setCurrentIndex( 292 self.docTypeComboBox.setCurrentIndex(
293 self.docTypeComboBox.findData(self.__data["DocstringType"])) 293 self.docTypeComboBox.findData(self.__data["DocstringType"]))
294 294
295 def start(self, fn, save=False, repeat=None): 295 def start(self, fn, save=False, repeat=None):
296 """ 296 """
297 Public slot to start the PEP 8 check. 297 Public slot to start the code style check.
298 298
299 @param fn file or list of files or directory to be checked 299 @param fn file or list of files or directory to be checked
300 (string or list of strings) 300 (string or list of strings)
301 @keyparam save flag indicating to save the given 301 @keyparam save flag indicating to save the given
302 file/file list/directory (boolean) 302 file/file list/directory (boolean)
516 self.checkProgress.setValue(1) 516 self.checkProgress.setValue(1)
517 self.__finish() 517 self.__finish()
518 518
519 def __finish(self): 519 def __finish(self):
520 """ 520 """
521 Private slot called when the PEP 8 check finished or the user 521 Private slot called when the code style check finished or the user
522 pressed the cancel button. 522 pressed the cancel button.
523 """ 523 """
524 self.cancelled = True 524 self.cancelled = True
525 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 525 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
526 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 526 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
545 self.checkProgressLabel.setVisible(False) 545 self.checkProgressLabel.setVisible(False)
546 546
547 @pyqtSlot() 547 @pyqtSlot()
548 def on_startButton_clicked(self): 548 def on_startButton_clicked(self):
549 """ 549 """
550 Private slot to start a PEP 8 check run. 550 Private slot to start a code style check run.
551 """ 551 """
552 if self.__forProject: 552 if self.__forProject:
553 data = { 553 data = {
554 "ExcludeFiles": self.excludeFilesEdit.text(), 554 "ExcludeFiles": self.excludeFilesEdit.text(),
555 "ExcludeMessages": self.excludeMessagesEdit.text(), 555 "ExcludeMessages": self.excludeMessagesEdit.text(),

eric ide

mercurial