Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py

changeset 5289
26e4a082ba54
parent 5147
d39dd5cee0c8
child 5290
174dae2b91c3
equal deleted inserted replaced
5288:ff831e3e383e 5289:26e4a082ba54
29 29
30 try: 30 try:
31 basestring # __IGNORE_WARNING__ 31 basestring # __IGNORE_WARNING__
32 except Exception: 32 except Exception:
33 basestring = str # define for Python3 33 basestring = str # define for Python3
34
35 NO_RESULTS = 0
36 NO_FILES = 1
37 HAS_RESULTS = 2
34 38
35 39
36 class CodeStyleCheckerDialog(QDialog, Ui_CodeStyleCheckerDialog): 40 class CodeStyleCheckerDialog(QDialog, Ui_CodeStyleCheckerDialog):
37 """ 41 """
38 Class implementing a dialog to show the results of the code style check. 42 Class implementing a dialog to show the results of the code style check.
99 self.styleCheckService.styleChecked.connect(self.__processResult) 103 self.styleCheckService.styleChecked.connect(self.__processResult)
100 self.styleCheckService.batchFinished.connect(self.__batchFinished) 104 self.styleCheckService.batchFinished.connect(self.__batchFinished)
101 self.styleCheckService.error.connect(self.__processError) 105 self.styleCheckService.error.connect(self.__processError)
102 self.filename = None 106 self.filename = None
103 107
104 self.noResults = True 108 self.results = NO_RESULTS
105 self.cancelled = False 109 self.cancelled = False
106 self.__lastFileItem = None 110 self.__lastFileItem = None
111 self.__batch = False
107 self.__finished = True 112 self.__finished = True
108 self.__errorItem = None 113 self.__errorItem = None
109 114
110 self.__fileOrFileList = "" 115 self.__fileOrFileList = ""
111 self.__project = None 116 self.__project = None
439 self.__batch = False 444 self.__batch = False
440 self.check() 445 self.check()
441 else: 446 else:
442 self.__batch = True 447 self.__batch = True
443 self.checkBatch() 448 self.checkBatch()
449 else:
450 self.results = NO_FILES
451 self.__finished = False
452 self.__finish()
444 453
445 def __modifyOptions(self, source): 454 def __modifyOptions(self, source):
446 """ 455 """
447 Private method to modify the options based on eflag: entries. 456 Private method to modify the options based on eflag: entries.
448 457
497 try: 506 try:
498 source, encoding = Utilities.readEncodedFile( 507 source, encoding = Utilities.readEncodedFile(
499 self.filename) 508 self.filename)
500 source = source.splitlines(True) 509 source = source.splitlines(True)
501 except (UnicodeError, IOError) as msg: 510 except (UnicodeError, IOError) as msg:
502 self.noResults = False 511 self.results = HAS_RESULTS
503 self.__createResultItem( 512 self.__createResultItem(
504 self.filename, 1, 1, 513 self.filename, 1, 1,
505 self.tr("Error: {0}").format(str(msg)) 514 self.tr("Error: {0}").format(str(msg))
506 .rstrip(), False, False, False) 515 .rstrip(), False, False, False)
507 self.progress += 1 516 self.progress += 1
548 try: 557 try:
549 source, encoding = Utilities.readEncodedFile( 558 source, encoding = Utilities.readEncodedFile(
550 filename) 559 filename)
551 source = source.splitlines(True) 560 source = source.splitlines(True)
552 except (UnicodeError, IOError) as msg: 561 except (UnicodeError, IOError) as msg:
553 self.noResults = False 562 self.results = HAS_RESULTS
554 self.__createResultItem( 563 self.__createResultItem(
555 filename, 1, 1, 564 filename, 1, 1,
556 self.tr("Error: {0}").format(str(msg)) 565 self.tr("Error: {0}").format(str(msg))
557 .rstrip(), False, False, False) 566 .rstrip(), False, False, False)
558 continue 567 continue
645 ignoredErrors += 1 654 ignoredErrors += 1
646 if self.showIgnored: 655 if self.showIgnored:
647 text = self.tr("{0} (ignored)").format(text) 656 text = self.tr("{0} (ignored)").format(text)
648 else: 657 else:
649 continue 658 continue
650 self.noResults = False 659 self.results = HAS_RESULTS
651 self.__createResultItem( 660 self.__createResultItem(
652 fn, lineno, position, text, fixed, autofixing, ignored) 661 fn, lineno, position, text, fixed, autofixing, ignored)
653 662
654 self.__updateStatistics( 663 self.__updateStatistics(
655 codeStyleCheckerStats, fixes, ignoredErrors) 664 codeStyleCheckerStats, fixes, ignoredErrors)
688 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 697 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
689 self.statisticsButton.setEnabled(True) 698 self.statisticsButton.setEnabled(True)
690 self.showButton.setEnabled(True) 699 self.showButton.setEnabled(True)
691 self.startButton.setEnabled(True) 700 self.startButton.setEnabled(True)
692 701
693 if self.noResults: 702 if self.results < HAS_RESULTS:
694 QTreeWidgetItem(self.resultList, [self.tr('No issues found.')]) 703 if self.results == NO_RESULTS:
704 QTreeWidgetItem(
705 self.resultList, [self.tr('No issues found.')])
706 else:
707 QTreeWidgetItem(
708 self.resultList,
709 [self.tr('No files found (check your ignore list).')])
695 QApplication.processEvents() 710 QApplication.processEvents()
696 self.showButton.setEnabled(False) 711 self.showButton.setEnabled(False)
697 else: 712 else:
698 self.showButton.setEnabled(True) 713 self.showButton.setEnabled(True)
699 self.resultList.header().resizeSections( 714 self.resultList.header().resizeSections(
745 self.__data = data 760 self.__data = data
746 self.__project.setData("CHECKERSPARMS", "Pep8Checker", 761 self.__project.setData("CHECKERSPARMS", "Pep8Checker",
747 self.__data) 762 self.__data)
748 763
749 self.resultList.clear() 764 self.resultList.clear()
750 self.noResults = True 765 self.results = NO_RESULTS
751 self.cancelled = False 766 self.cancelled = False
752 self.start(self.__fileOrFileList) 767 self.start(self.__fileOrFileList)
753 768
754 def __selectCodes(self, edit, showFixCodes): 769 def __selectCodes(self, edit, showFixCodes):
755 """ 770 """
802 Private slot to handle the activation of an item. 817 Private slot to handle the activation of an item.
803 818
804 @param item reference to the activated item (QTreeWidgetItem) 819 @param item reference to the activated item (QTreeWidgetItem)
805 @param column column the item was activated in (integer) 820 @param column column the item was activated in (integer)
806 """ 821 """
807 if self.noResults: 822 if self.results < HAS_RESULTS:
808 return 823 return
809 824
810 if item.parent(): 825 if item.parent():
811 fn = Utilities.normabspath(item.data(0, self.filenameRole)) 826 fn = Utilities.normabspath(item.data(0, self.filenameRole))
812 lineno = item.data(0, self.lineRole) 827 lineno = item.data(0, self.lineRole)

eric ide

mercurial