15 QDialogButtonBox, QApplication, QHeaderView |
15 QDialogButtonBox, QApplication, QHeaderView |
16 |
16 |
17 from . import pep8 |
17 from . import pep8 |
18 |
18 |
19 from E5Gui.E5Application import e5App |
19 from E5Gui.E5Application import e5App |
20 |
|
21 from .Pep8Checker import Pep8Checker, Pep8Py2Checker |
|
22 from .Pep8CodeSelectionDialog import Pep8CodeSelectionDialog |
|
23 from .Pep8StatisticsDialog import Pep8StatisticsDialog |
|
24 from .Pep8Fixer import Pep8Fixer, Pep8FixableIssues |
|
25 |
20 |
26 from .Ui_Pep8Dialog import Ui_Pep8Dialog |
21 from .Ui_Pep8Dialog import Ui_Pep8Dialog |
27 |
22 |
28 import UI.PixmapCache |
23 import UI.PixmapCache |
29 import Preferences |
24 import Preferences |
94 @param line line number of issue (integer or string) |
89 @param line line number of issue (integer or string) |
95 @param pos character position of issue (integer or string) |
90 @param pos character position of issue (integer or string) |
96 @param message message text (string) |
91 @param message message text (string) |
97 @param fixed flag indicating a fixed issue (boolean) |
92 @param fixed flag indicating a fixed issue (boolean) |
98 """ |
93 """ |
|
94 from .Pep8Fixer import Pep8FixableIssues |
|
95 |
99 if self.__lastFileItem is None: |
96 if self.__lastFileItem is None: |
100 # It's a new file |
97 # It's a new file |
101 self.__lastFileItem = QTreeWidgetItem(self.resultList, [file]) |
98 self.__lastFileItem = QTreeWidgetItem(self.resultList, [file]) |
102 self.__lastFileItem.setFirstColumnSpanned(True) |
99 self.__lastFileItem.setFirstColumnSpanned(True) |
103 self.__lastFileItem.setExpanded(True) |
100 self.__lastFileItem.setExpanded(True) |
289 continue |
286 continue |
290 |
287 |
291 flags = Utilities.extractFlags(source) |
288 flags = Utilities.extractFlags(source) |
292 ext = os.path.splitext(file)[1] |
289 ext = os.path.splitext(file)[1] |
293 if fixIssues: |
290 if fixIssues: |
|
291 from .Pep8Fixer import Pep8Fixer |
294 fixer = Pep8Fixer(self.__project, file, source, |
292 fixer = Pep8Fixer(self.__project, file, source, |
295 fixCodes, True) # always fix in place |
293 fixCodes, True) # always fix in place |
296 else: |
294 else: |
297 fixer = None |
295 fixer = None |
298 if ("FileType" in flags and |
296 if ("FileType" in flags and |
302 Preferences.getProject("DeterminePyFromProject") and \ |
300 Preferences.getProject("DeterminePyFromProject") and \ |
303 self.__project.isOpen() and \ |
301 self.__project.isOpen() and \ |
304 self.__project.isProjectFile(file) and \ |
302 self.__project.isProjectFile(file) and \ |
305 self.__project.getProjectLanguage() in ["Python", |
303 self.__project.getProjectLanguage() in ["Python", |
306 "Python2"]): |
304 "Python2"]): |
|
305 from .Pep8Checker import Pep8Py2Checker |
307 checker = Pep8Py2Checker(file, [], |
306 checker = Pep8Py2Checker(file, [], |
308 repeat=repeatMessages, |
307 repeat=repeatMessages, |
309 select=includeMessages, |
308 select=includeMessages, |
310 ignore=excludeMessages) |
309 ignore=excludeMessages) |
311 else: |
310 else: |
|
311 from .Pep8Checker import Pep8Checker |
312 checker = Pep8Checker(file, source, |
312 checker = Pep8Checker(file, source, |
313 repeat=repeatMessages, |
313 repeat=repeatMessages, |
314 select=includeMessages, |
314 select=includeMessages, |
315 ignore=excludeMessages) |
315 ignore=excludeMessages) |
316 checker.check_all() |
316 checker.check_all() |
395 def on_excludeMessagesSelectButton_clicked(self): |
395 def on_excludeMessagesSelectButton_clicked(self): |
396 """ |
396 """ |
397 Private slot to select the message codes to be excluded via a |
397 Private slot to select the message codes to be excluded via a |
398 selection dialog. |
398 selection dialog. |
399 """ |
399 """ |
|
400 from .Pep8CodeSelectionDialog import Pep8CodeSelectionDialog |
400 dlg = Pep8CodeSelectionDialog( |
401 dlg = Pep8CodeSelectionDialog( |
401 self.excludeMessagesEdit.text(), False, self) |
402 self.excludeMessagesEdit.text(), False, self) |
402 if dlg.exec_() == QDialog.Accepted: |
403 if dlg.exec_() == QDialog.Accepted: |
403 self.excludeMessagesEdit.setText(dlg.getSelectedCodes()) |
404 self.excludeMessagesEdit.setText(dlg.getSelectedCodes()) |
404 |
405 |
406 def on_includeMessagesSelectButton_clicked(self): |
407 def on_includeMessagesSelectButton_clicked(self): |
407 """ |
408 """ |
408 Private slot to select the message codes to be included via a |
409 Private slot to select the message codes to be included via a |
409 selection dialog. |
410 selection dialog. |
410 """ |
411 """ |
|
412 from .Pep8CodeSelectionDialog import Pep8CodeSelectionDialog |
411 dlg = Pep8CodeSelectionDialog( |
413 dlg = Pep8CodeSelectionDialog( |
412 self.includeMessagesEdit.text(), False, self) |
414 self.includeMessagesEdit.text(), False, self) |
413 if dlg.exec_() == QDialog.Accepted: |
415 if dlg.exec_() == QDialog.Accepted: |
414 self.includeMessagesEdit.setText(dlg.getSelectedCodes()) |
416 self.includeMessagesEdit.setText(dlg.getSelectedCodes()) |
415 |
417 |
417 def on_fixIssuesSelectButton_clicked(self): |
419 def on_fixIssuesSelectButton_clicked(self): |
418 """ |
420 """ |
419 Private slot to select the issue codes to be fixed via a |
421 Private slot to select the issue codes to be fixed via a |
420 selection dialog. |
422 selection dialog. |
421 """ |
423 """ |
|
424 from .Pep8CodeSelectionDialog import Pep8CodeSelectionDialog |
422 dlg = Pep8CodeSelectionDialog( |
425 dlg = Pep8CodeSelectionDialog( |
423 self.fixIssuesEdit.text(), True, self) |
426 self.fixIssuesEdit.text(), True, self) |
424 if dlg.exec_() == QDialog.Accepted: |
427 if dlg.exec_() == QDialog.Accepted: |
425 self.fixIssuesEdit.setText(dlg.getSelectedCodes()) |
428 self.fixIssuesEdit.setText(dlg.getSelectedCodes()) |
426 |
429 |
488 @pyqtSlot() |
491 @pyqtSlot() |
489 def on_statisticsButton_clicked(self): |
492 def on_statisticsButton_clicked(self): |
490 """ |
493 """ |
491 Private slot to show the statistics dialog. |
494 Private slot to show the statistics dialog. |
492 """ |
495 """ |
|
496 from .Pep8StatisticsDialog import Pep8StatisticsDialog |
493 dlg = Pep8StatisticsDialog(self.__statistics, self) |
497 dlg = Pep8StatisticsDialog(self.__statistics, self) |
494 dlg.exec_() |
498 dlg.exec_() |
495 |
499 |
496 @pyqtSlot() |
500 @pyqtSlot() |
497 def on_loadDefaultButton_clicked(self): |
501 def on_loadDefaultButton_clicked(self): |