Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py

changeset 4506
57666e501a42
parent 4503
d68dcbe1deb3
child 4509
7797ee4a45f9
equal deleted inserted replaced
4505:3b437ae320bd 4506:57666e501a42
164 fixable = False 164 fixable = False
165 code, message = message.split(None, 1) 165 code, message = message.split(None, 1)
166 itm = QTreeWidgetItem( 166 itm = QTreeWidgetItem(
167 self.__lastFileItem, 167 self.__lastFileItem,
168 ["{0:6}".format(line), code, message]) 168 ["{0:6}".format(line), code, message])
169 if code.startswith(("W", "-", "C")): 169 if code.startswith(("W", "-", "C", "M")):
170 itm.setIcon(1, UI.PixmapCache.getIcon("warning.png")) 170 itm.setIcon(1, UI.PixmapCache.getIcon("warning.png"))
171 elif code.startswith("N"): 171 elif code.startswith("N"):
172 itm.setIcon(1, UI.PixmapCache.getIcon("namingError.png")) 172 itm.setIcon(1, UI.PixmapCache.getIcon("namingError.png"))
173 elif code.startswith("D"): 173 elif code.startswith("D"):
174 itm.setIcon(1, UI.PixmapCache.getIcon("docstringError.png")) 174 itm.setIcon(1, UI.PixmapCache.getIcon("docstringError.png"))
299 self.__data["DocstringType"] = "pep257" 299 self.__data["DocstringType"] = "pep257"
300 if "ShowIgnored" not in self.__data: 300 if "ShowIgnored" not in self.__data:
301 self.__data["ShowIgnored"] = False 301 self.__data["ShowIgnored"] = False
302 if "MaxCodeComplexity" not in self.__data: 302 if "MaxCodeComplexity" not in self.__data:
303 self.__data["MaxCodeComplexity"] = 10 303 self.__data["MaxCodeComplexity"] = 10
304 if "ValidEncodings" not in self.__data:
305 self.__data["ValidEncodings"] = "latin-1, utf-8"
306 if "CopyrightMinFileSize" not in self.__data or \
307 "CopyrightAuthor" not in self.__data:
308 self.__data["CopyrightMinFileSize"] = 0
309 self.__data["CopyrightAuthor"] = ""
304 310
305 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) 311 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"])
306 self.excludeMessagesEdit.setText(self.__data["ExcludeMessages"]) 312 self.excludeMessagesEdit.setText(self.__data["ExcludeMessages"])
307 self.includeMessagesEdit.setText(self.__data["IncludeMessages"]) 313 self.includeMessagesEdit.setText(self.__data["IncludeMessages"])
308 self.repeatCheckBox.setChecked(self.__data["RepeatMessages"]) 314 self.repeatCheckBox.setChecked(self.__data["RepeatMessages"])
313 self.lineLengthSpinBox.setValue(self.__data["MaxLineLength"]) 319 self.lineLengthSpinBox.setValue(self.__data["MaxLineLength"])
314 self.hangClosingCheckBox.setChecked(self.__data["HangClosing"]) 320 self.hangClosingCheckBox.setChecked(self.__data["HangClosing"])
315 self.docTypeComboBox.setCurrentIndex( 321 self.docTypeComboBox.setCurrentIndex(
316 self.docTypeComboBox.findData(self.__data["DocstringType"])) 322 self.docTypeComboBox.findData(self.__data["DocstringType"]))
317 self.complexitySpinBox.setValue(self.__data["MaxCodeComplexity"]) 323 self.complexitySpinBox.setValue(self.__data["MaxCodeComplexity"])
324 self.encodingsEdit.setText(self.__data["ValidEncodings"])
325 self.copyrightFileSizeSpinBox.setValue(
326 self.__data["CopyrightMinFileSize"])
327 self.copyrightAuthorEdit.setText(self.__data["CopyrightAuthor"])
318 328
319 def start(self, fn, save=False, repeat=None): 329 def start(self, fn, save=False, repeat=None):
320 """ 330 """
321 Public slot to start the code style check. 331 Public slot to start the code style check.
322 332
392 maxLineLength = self.lineLengthSpinBox.value() 402 maxLineLength = self.lineLengthSpinBox.value()
393 hangClosing = self.hangClosingCheckBox.isChecked() 403 hangClosing = self.hangClosingCheckBox.isChecked()
394 docType = self.docTypeComboBox.itemData( 404 docType = self.docTypeComboBox.itemData(
395 self.docTypeComboBox.currentIndex()) 405 self.docTypeComboBox.currentIndex())
396 maxCodeComplexity = self.complexitySpinBox.value() 406 maxCodeComplexity = self.complexitySpinBox.value()
407 miscellaneousArgs = {
408 "CodingChecker": self.encodingsEdit.text(),
409 "CopyrightChecker": {
410 "MinFilesize": self.copyrightFileSizeSpinBox.value(),
411 "Author": self.copyrightAuthorEdit.text(),
412 }
413 }
397 414
398 self.__options = [excludeMessages, includeMessages, repeatMessages, 415 self.__options = [excludeMessages, includeMessages, repeatMessages,
399 fixCodes, noFixCodes, fixIssues, maxLineLength, 416 fixCodes, noFixCodes, fixIssues, maxLineLength,
400 hangClosing, docType, maxCodeComplexity] 417 hangClosing, docType, maxCodeComplexity,
418 miscellaneousArgs]
401 419
402 # now go through all the files 420 # now go through all the files
403 self.progress = 0 421 self.progress = 0
404 self.files.sort() 422 self.files.sort()
405 if len(self.files) == 1: 423 if len(self.files) == 1:
434 return 452 return
435 453
436 self.__lastFileItem = None 454 self.__lastFileItem = None
437 455
438 if codestring: 456 if codestring:
439 source = codestring 457 source = codestring.splitlines(True)
440 encoding = Utilities.get_coding(source) 458 encoding = Utilities.get_coding(source)
441 else: 459 else:
442 try: 460 try:
443 source, encoding = Utilities.readEncodedFile( 461 source, encoding = Utilities.readEncodedFile(
444 self.filename) 462 self.filename)
675 "MaxLineLength": self.lineLengthSpinBox.value(), 693 "MaxLineLength": self.lineLengthSpinBox.value(),
676 "HangClosing": self.hangClosingCheckBox.isChecked(), 694 "HangClosing": self.hangClosingCheckBox.isChecked(),
677 "DocstringType": self.docTypeComboBox.itemData( 695 "DocstringType": self.docTypeComboBox.itemData(
678 self.docTypeComboBox.currentIndex()), 696 self.docTypeComboBox.currentIndex()),
679 "MaxCodeComplexity": self.complexitySpinBox.value(), 697 "MaxCodeComplexity": self.complexitySpinBox.value(),
698 "ValidEncodings": self.encodingsEdit.text(),
699 "CopyrightMinFileSize": self.copyrightFileSizeSpinBox.value(),
700 "CopyrightAuthor": self.copyrightAuthorEdit.text(),
680 } 701 }
681 if data != self.__data: 702 if data != self.__data:
682 self.__data = data 703 self.__data = data
683 self.__project.setData("CHECKERSPARMS", "Pep8Checker", 704 self.__project.setData("CHECKERSPARMS", "Pep8Checker",
684 self.__data) 705 self.__data)
848 Preferences.Prefs.settings.value("PEP8/HangClosing"))) 869 Preferences.Prefs.settings.value("PEP8/HangClosing")))
849 self.docTypeComboBox.setCurrentIndex(self.docTypeComboBox.findData( 870 self.docTypeComboBox.setCurrentIndex(self.docTypeComboBox.findData(
850 Preferences.Prefs.settings.value("PEP8/DocstringType", "pep257"))) 871 Preferences.Prefs.settings.value("PEP8/DocstringType", "pep257")))
851 self.complexitySpinBox.setValue(int(Preferences.Prefs.settings.value( 872 self.complexitySpinBox.setValue(int(Preferences.Prefs.settings.value(
852 "PEP8/MaxCodeComplexity", 10))) 873 "PEP8/MaxCodeComplexity", 10)))
874 self.encodingsEdit.setText(Preferences.Prefs.settings.value(
875 "PEP8/ValidEncodings", "latin-1, utf-8"))
876 self.copyrightFileSizeSpinBox.setValue(int(
877 Preferences.Prefs.settings.value("PEP8/CopyrightMinFileSize", 0)))
878 self.copyrightAuthorEdit.setText(
879 Preferences.Prefs.settings.value("PEP8/CopyrightAuthor"))
853 880
854 @pyqtSlot() 881 @pyqtSlot()
855 def on_storeDefaultButton_clicked(self): 882 def on_storeDefaultButton_clicked(self):
856 """ 883 """
857 Private slot to store the current configuration values as 884 Private slot to store the current configuration values as
880 Preferences.Prefs.settings.setValue( 907 Preferences.Prefs.settings.setValue(
881 "PEP8/DocstringType", self.docTypeComboBox.itemData( 908 "PEP8/DocstringType", self.docTypeComboBox.itemData(
882 self.docTypeComboBox.currentIndex())) 909 self.docTypeComboBox.currentIndex()))
883 Preferences.Prefs.settings.setValue( 910 Preferences.Prefs.settings.setValue(
884 "PEP8/MaxCodeComplexity", self.complexitySpinBox.value()) 911 "PEP8/MaxCodeComplexity", self.complexitySpinBox.value())
912 Preferences.Prefs.settings.setValue(
913 "PEP8/ValidEncodings", self.encodingsEdit.text())
914 Preferences.Prefs.settings.setValue(
915 "PEP8/CopyrightMinFileSize", self.copyrightFileSizeSpinBox.value())
916 Preferences.Prefs.settings.setValue(
917 "PEP8/CopyrightAuthor", self.copyrightAuthorEdit.text())
885 918
886 @pyqtSlot() 919 @pyqtSlot()
887 def on_resetDefaultButton_clicked(self): 920 def on_resetDefaultButton_clicked(self):
888 """ 921 """
889 Private slot to reset the configuration values to their default values. 922 Private slot to reset the configuration values to their default values.
900 Preferences.Prefs.settings.setValue( 933 Preferences.Prefs.settings.setValue(
901 "PEP8/MaxLineLength", pep8.MAX_LINE_LENGTH) 934 "PEP8/MaxLineLength", pep8.MAX_LINE_LENGTH)
902 Preferences.Prefs.settings.setValue("PEP8/HangClosing", False) 935 Preferences.Prefs.settings.setValue("PEP8/HangClosing", False)
903 Preferences.Prefs.settings.setValue("PEP8/DocstringType", "pep257") 936 Preferences.Prefs.settings.setValue("PEP8/DocstringType", "pep257")
904 Preferences.Prefs.settings.setValue("PEP8/MaxCodeComplexity", 10) 937 Preferences.Prefs.settings.setValue("PEP8/MaxCodeComplexity", 10)
938 Preferences.Prefs.settings.setValue(
939 "PEP8/ValidEncodings", "latin-1, utf-8")
940 Preferences.Prefs.settings.setValue("PEP8/CopyrightMinFileSize", 0)
941 Preferences.Prefs.settings.setValue("PEP8/CopyrightAuthor", "")
905 942
906 @pyqtSlot(QAbstractButton) 943 @pyqtSlot(QAbstractButton)
907 def on_buttonBox_clicked(self, button): 944 def on_buttonBox_clicked(self, button):
908 """ 945 """
909 Private slot called by a button of the button box clicked. 946 Private slot called by a button of the button box clicked.

eric ide

mercurial