402 self.__statistics.clear() |
402 self.__statistics.clear() |
403 self.__statistics["_FilesCount"] = 0 |
403 self.__statistics["_FilesCount"] = 0 |
404 self.__statistics["_FilesIssues"] = 0 |
404 self.__statistics["_FilesIssues"] = 0 |
405 self.__statistics["_IssuesFixed"] = 0 |
405 self.__statistics["_IssuesFixed"] = 0 |
406 self.__statistics["_SecurityOK"] = 0 |
406 self.__statistics["_SecurityOK"] = 0 |
|
407 |
|
408 def __getBanRelativeImportsValue(self): |
|
409 """ |
|
410 Private method to get the value corresponding the selected button. |
|
411 |
|
412 @return value for the BanRelativeImports argument |
|
413 @rtype str |
|
414 """ |
|
415 if self.banParentsButton.isChecked(): |
|
416 return "parents" |
|
417 elif self.banAllButton.isChecked(): |
|
418 return "true" |
|
419 else: |
|
420 return "" |
|
421 |
|
422 def __setBanRelativeImports(self, value): |
|
423 """ |
|
424 Private method to set the button according to the ban relative imports |
|
425 setting. |
|
426 |
|
427 @param value value of the ban relative imports setting |
|
428 @type str |
|
429 """ |
|
430 if value == "parents": |
|
431 self.banParentsButton.setChecked(True) |
|
432 elif value == "true": |
|
433 self.banAllButton.setChecked(True) |
|
434 else: |
|
435 self.allowAllButton.setChecked(True) |
407 |
436 |
408 def prepare(self, fileList, project): |
437 def prepare(self, fileList, project): |
409 """ |
438 """ |
410 Public method to prepare the dialog with a list of filenames. |
439 Public method to prepare the dialog with a list of filenames. |
411 |
440 |
547 } |
576 } |
548 |
577 |
549 if "ImportsChecker" not in self.__data: |
578 if "ImportsChecker" not in self.__data: |
550 self.__data["ImportsChecker"] = { |
579 self.__data["ImportsChecker"] = { |
551 "ApplicationPackageNames": [], |
580 "ApplicationPackageNames": [], |
|
581 "BannedModules": [], |
|
582 "BanRelativeImports": "", |
552 } |
583 } |
553 |
584 |
554 self.__initCategoriesList(self.__data["EnabledCheckerCategories"]) |
585 self.__initCategoriesList(self.__data["EnabledCheckerCategories"]) |
555 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
586 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
556 self.excludeMessagesEdit.setText(self.__data["ExcludeMessages"]) |
587 self.excludeMessagesEdit.setText(self.__data["ExcludeMessages"]) |
813 } |
844 } |
814 |
845 |
815 importsArgs = { |
846 importsArgs = { |
816 "ApplicationPackageNames": |
847 "ApplicationPackageNames": |
817 sorted(self.appPackagesEdit.toPlainText().split()), |
848 sorted(self.appPackagesEdit.toPlainText().split()), |
|
849 "BannedModules": |
|
850 sorted(self.bannedModulesEdit.toPlainText().split()), |
|
851 "BanRelativeImports": self.__getBanRelativeImportsValue(), |
818 } |
852 } |
819 |
853 |
820 self.__options = [excludeMessages, includeMessages, repeatMessages, |
854 self.__options = [excludeMessages, includeMessages, repeatMessages, |
821 fixCodes, noFixCodes, fixIssues, maxLineLength, |
855 fixCodes, noFixCodes, fixIssues, maxLineLength, |
822 maxDocLineLength, blankLines, hangClosing, |
856 maxDocLineLength, blankLines, hangClosing, |
1249 "CheckTypedException": |
1283 "CheckTypedException": |
1250 self.typedExceptionsCheckBox.isChecked(), |
1284 self.typedExceptionsCheckBox.isChecked(), |
1251 }, |
1285 }, |
1252 "ImportsChecker": { |
1286 "ImportsChecker": { |
1253 "ApplicationPackageNames": |
1287 "ApplicationPackageNames": |
1254 sorted(self.appPackagesEdit.toPlainText().split()) |
1288 sorted(self.appPackagesEdit.toPlainText().split()), |
|
1289 "BannedModules": |
|
1290 sorted(self.bannedModulesEdit.toPlainText().split()), |
|
1291 "BanRelativeImports": self.__getBanRelativeImportsValue(), |
1255 }, |
1292 }, |
1256 } |
1293 } |
1257 if ( |
1294 if ( |
1258 json.dumps(data, sort_keys=True) != |
1295 json.dumps(data, sort_keys=True) != |
1259 json.dumps(self.__data, sort_keys=True) |
1296 json.dumps(self.__data, sort_keys=True) |
1597 |
1634 |
1598 # Imports Checker |
1635 # Imports Checker |
1599 self.appPackagesEdit.setPlainText(" ".join( |
1636 self.appPackagesEdit.setPlainText(" ".join( |
1600 sorted(Preferences.toList(Preferences.getSettings().value( |
1637 sorted(Preferences.toList(Preferences.getSettings().value( |
1601 "PEP8/ApplicationPackageNames", []))))) |
1638 "PEP8/ApplicationPackageNames", []))))) |
|
1639 self.bannedModulesEdit.setPlainText(" ".join( |
|
1640 sorted(Preferences.toList(Preferences.getSettings().value( |
|
1641 "PEP8/BannedModules", []))))) |
|
1642 self.__setBanRelativeImports( |
|
1643 Preferences.getSettings().value( |
|
1644 "PEP8/BanRelativeImports", "")) |
1602 |
1645 |
1603 self.__cleanupData() |
1646 self.__cleanupData() |
1604 |
1647 |
1605 @pyqtSlot() |
1648 @pyqtSlot() |
1606 def on_storeDefaultButton_clicked(self): |
1649 def on_storeDefaultButton_clicked(self): |
1738 |
1781 |
1739 # Imports Checker |
1782 # Imports Checker |
1740 Preferences.getSettings().setValue( |
1783 Preferences.getSettings().setValue( |
1741 "PEP8/ApplicationPackageNames", |
1784 "PEP8/ApplicationPackageNames", |
1742 sorted(self.appPackagesEdit.toPlainText().split())) |
1785 sorted(self.appPackagesEdit.toPlainText().split())) |
|
1786 Preferences.getSettings().setValue( |
|
1787 "PEP8/BannedModules", |
|
1788 sorted(self.bannedModulesEdit.toPlainText().split())) |
|
1789 Preferences.getSettings().setValue( |
|
1790 "PEP8/BanRelativeImports", |
|
1791 self.__getBanRelativeImportsValue()) |
1743 |
1792 |
1744 @pyqtSlot() |
1793 @pyqtSlot() |
1745 def on_resetDefaultButton_clicked(self): |
1794 def on_resetDefaultButton_clicked(self): |
1746 """ |
1795 """ |
1747 Private slot to reset the configuration values to their default values. |
1796 Private slot to reset the configuration values to their default values. |
1866 SecurityDefaults["check_typed_exception"]) |
1915 SecurityDefaults["check_typed_exception"]) |
1867 |
1916 |
1868 # Imports Checker |
1917 # Imports Checker |
1869 Preferences.getSettings().setValue( |
1918 Preferences.getSettings().setValue( |
1870 "PEP8/ApplicationPackageNames", []) |
1919 "PEP8/ApplicationPackageNames", []) |
|
1920 Preferences.getSettings().setValue( |
|
1921 "PEP8/BannedModules", []) |
|
1922 Preferences.getSettings().setValue( |
|
1923 "PEP8/BanRelativeImports", "") |
1871 |
1924 |
1872 # Update UI with default values |
1925 # Update UI with default values |
1873 self.on_loadDefaultButton_clicked() |
1926 self.on_loadDefaultButton_clicked() |
1874 |
1927 |
1875 @pyqtSlot() |
1928 @pyqtSlot() |