Mon, 30 Sep 2013 19:31:22 +0200
Continued changing the names of the various code style checkers to make them more appropriate to the broadened scope.
Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.html | file | annotate | diff | comparison | revisions | |
Plugins/CheckerPlugins/Pep8/CodeStyleCheckerDialog.py | file | annotate | diff | comparison | revisions | |
Plugins/CheckerPlugins/Pep8/CodeStyleCheckerDialog.ui | file | annotate | diff | comparison | revisions | |
Plugins/CheckerPlugins/Pep8/Pep8Dialog.py | file | annotate | diff | comparison | revisions | |
Plugins/CheckerPlugins/Pep8/Pep8Dialog.ui | file | annotate | diff | comparison | revisions | |
Plugins/PluginPep8Checker.py | file | annotate | diff | comparison | revisions | |
eric5.e4p | file | annotate | diff | comparison | revisions |
--- a/Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.html Mon Sep 30 19:21:19 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,486 +0,0 @@ -<!DOCTYPE html> -<html><head> -<title>eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog</title> -<meta charset="UTF-8"> -<style> -body { - background: #EDECE6; - margin: 0em 1em 10em 1em; - color: black; -} - -h1 { color: white; background: #85774A; } -h2 { color: white; background: #85774A; } -h3 { color: white; background: #9D936E; } -h4 { color: white; background: #9D936E; } - -a { color: #BA6D36; } - -</style> -</head> -<body><a NAME="top" ID="top"></a> -<h1>eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog</h1> -<p> -Module implementing a dialog to show the results of the PEP 8 check. -</p> -<h3>Global Attributes</h3> -<table> -<tr><td>None</td></tr> -</table> -<h3>Classes</h3> -<table> -<tr> -<td><a href="#Pep8Dialog">Pep8Dialog</a></td> -<td>Class implementing a dialog to show the results of the PEP 8 check.</td> -</tr><tr> -<td><a href="#Pep8Report">Pep8Report</a></td> -<td>Class implementing a special report to be used with our dialog.</td> -</tr> -</table> -<h3>Functions</h3> -<table> -<tr><td>None</td></tr> -</table> -<hr /><hr /> -<a NAME="Pep8Dialog" ID="Pep8Dialog"></a> -<h2>Pep8Dialog</h2> -<p> - Class implementing a dialog to show the results of the PEP 8 check. -</p> -<h3>Derived from</h3> -QDialog, Ui_Pep8Dialog -<h3>Class Attributes</h3> -<table> -<tr><td>codeRole</td></tr><tr><td>filenameRole</td></tr><tr><td>fixableRole</td></tr><tr><td>lineRole</td></tr><tr><td>messageRole</td></tr><tr><td>positionRole</td></tr> -</table> -<h3>Class Methods</h3> -<table> -<tr><td>None</td></tr> -</table> -<h3>Methods</h3> -<table> -<tr> -<td><a href="#Pep8Dialog.__init__">Pep8Dialog</a></td> -<td>Constructor</td> -</tr><tr> -<td><a href="#Pep8Dialog.__clearErrors">__clearErrors</a></td> -<td>Private method to clear all warning markers of open editors.</td> -</tr><tr> -<td><a href="#Pep8Dialog.__createResultItem">__createResultItem</a></td> -<td>Private method to create an entry in the result list.</td> -</tr><tr> -<td><a href="#Pep8Dialog.__finish">__finish</a></td> -<td>Private slot called when the PEP 8 check finished or the user pressed the cancel button.</td> -</tr><tr> -<td><a href="#Pep8Dialog.__getSelectedFixableItems">__getSelectedFixableItems</a></td> -<td>Private method to extract all selected items for fixable issues.</td> -</tr><tr> -<td><a href="#Pep8Dialog.__itemFixable">__itemFixable</a></td> -<td>Private method to check, if an item has a fixable issue.</td> -</tr><tr> -<td><a href="#Pep8Dialog.__modifyFixedResultItem">__modifyFixedResultItem</a></td> -<td>Private method to modify a result list entry to show its positive fixed state.</td> -</tr><tr> -<td><a href="#Pep8Dialog.__resetStatistics">__resetStatistics</a></td> -<td>Private slot to reset the statistics data.</td> -</tr><tr> -<td><a href="#Pep8Dialog.__resort">__resort</a></td> -<td>Private method to resort the tree.</td> -</tr><tr> -<td><a href="#Pep8Dialog.__selectCodes">__selectCodes</a></td> -<td>Private method to select message codes via a selection dialog.</td> -</tr><tr> -<td><a href="#Pep8Dialog.__updateFixerStatistics">__updateFixerStatistics</a></td> -<td>Private method to update the collected fixer related statistics.</td> -</tr><tr> -<td><a href="#Pep8Dialog.__updateStatistics">__updateStatistics</a></td> -<td>Private method to update the collected statistics.</td> -</tr><tr> -<td><a href="#Pep8Dialog.on_buttonBox_clicked">on_buttonBox_clicked</a></td> -<td>Private slot called by a button of the button box clicked.</td> -</tr><tr> -<td><a href="#Pep8Dialog.on_excludeMessagesSelectButton_clicked">on_excludeMessagesSelectButton_clicked</a></td> -<td>Private slot to select the message codes to be excluded via a selection dialog.</td> -</tr><tr> -<td><a href="#Pep8Dialog.on_fixButton_clicked">on_fixButton_clicked</a></td> -<td>Private slot to fix selected issues.</td> -</tr><tr> -<td><a href="#Pep8Dialog.on_fixIssuesSelectButton_clicked">on_fixIssuesSelectButton_clicked</a></td> -<td>Private slot to select the issue codes to be fixed via a selection dialog.</td> -</tr><tr> -<td><a href="#Pep8Dialog.on_includeMessagesSelectButton_clicked">on_includeMessagesSelectButton_clicked</a></td> -<td>Private slot to select the message codes to be included via a selection dialog.</td> -</tr><tr> -<td><a href="#Pep8Dialog.on_loadDefaultButton_clicked">on_loadDefaultButton_clicked</a></td> -<td>Private slot to load the default configuration values.</td> -</tr><tr> -<td><a href="#Pep8Dialog.on_noFixIssuesSelectButton_clicked">on_noFixIssuesSelectButton_clicked</a></td> -<td>Private slot to select the issue codes not to be fixed via a selection dialog.</td> -</tr><tr> -<td><a href="#Pep8Dialog.on_resetDefaultButton_clicked">on_resetDefaultButton_clicked</a></td> -<td>Private slot to reset the configuration values to their default values.</td> -</tr><tr> -<td><a href="#Pep8Dialog.on_resultList_itemActivated">on_resultList_itemActivated</a></td> -<td>Private slot to handle the activation of an item.</td> -</tr><tr> -<td><a href="#Pep8Dialog.on_resultList_itemSelectionChanged">on_resultList_itemSelectionChanged</a></td> -<td>Private slot to change the dialog state depending on the selection.</td> -</tr><tr> -<td><a href="#Pep8Dialog.on_showButton_clicked">on_showButton_clicked</a></td> -<td>Private slot to handle the "Show" button press.</td> -</tr><tr> -<td><a href="#Pep8Dialog.on_startButton_clicked">on_startButton_clicked</a></td> -<td>Private slot to start a PEP 8 check run.</td> -</tr><tr> -<td><a href="#Pep8Dialog.on_statisticsButton_clicked">on_statisticsButton_clicked</a></td> -<td>Private slot to show the statistics dialog.</td> -</tr><tr> -<td><a href="#Pep8Dialog.on_storeDefaultButton_clicked">on_storeDefaultButton_clicked</a></td> -<td>Private slot to store the current configuration values as default values.</td> -</tr><tr> -<td><a href="#Pep8Dialog.prepare">prepare</a></td> -<td>Public method to prepare the dialog with a list of filenames.</td> -</tr><tr> -<td><a href="#Pep8Dialog.start">start</a></td> -<td>Public slot to start the PEP 8 check.</td> -</tr> -</table> -<h3>Static Methods</h3> -<table> -<tr><td>None</td></tr> -</table> -<a NAME="Pep8Dialog.__init__" ID="Pep8Dialog.__init__"></a> -<h4>Pep8Dialog (Constructor)</h4> -<b>Pep8Dialog</b>(<i>parent=None</i>) -<p> - Constructor -</p><dl> -<dt><i>parent</i></dt> -<dd> -reference to the parent widget (QWidget) -</dd> -</dl><a NAME="Pep8Dialog.__clearErrors" ID="Pep8Dialog.__clearErrors"></a> -<h4>Pep8Dialog.__clearErrors</h4> -<b>__clearErrors</b>(<i></i>) -<p> - Private method to clear all warning markers of open editors. -</p><a NAME="Pep8Dialog.__createResultItem" ID="Pep8Dialog.__createResultItem"></a> -<h4>Pep8Dialog.__createResultItem</h4> -<b>__createResultItem</b>(<i>file, line, pos, message, fixed, autofixing</i>) -<p> - Private method to create an entry in the result list. -</p><dl> -<dt><i>file</i></dt> -<dd> -file name of the file (string) -</dd><dt><i>line</i></dt> -<dd> -line number of issue (integer or string) -</dd><dt><i>pos</i></dt> -<dd> -character position of issue (integer or string) -</dd><dt><i>message</i></dt> -<dd> -message text (string) -</dd><dt><i>fixed</i></dt> -<dd> -flag indicating a fixed issue (boolean) -</dd><dt><i>autofixing</i></dt> -<dd> -flag indicating, that we are fixing issues - automatically (boolean) -</dd> -</dl><dl> -<dt>Returns:</dt> -<dd> -reference to the created item (QTreeWidgetItem) -</dd> -</dl><a NAME="Pep8Dialog.__finish" ID="Pep8Dialog.__finish"></a> -<h4>Pep8Dialog.__finish</h4> -<b>__finish</b>(<i></i>) -<p> - Private slot called when the PEP 8 check finished or the user - pressed the cancel button. -</p><a NAME="Pep8Dialog.__getSelectedFixableItems" ID="Pep8Dialog.__getSelectedFixableItems"></a> -<h4>Pep8Dialog.__getSelectedFixableItems</h4> -<b>__getSelectedFixableItems</b>(<i></i>) -<p> - Private method to extract all selected items for fixable issues. -</p><dl> -<dt>Returns:</dt> -<dd> -selected items for fixable issues (list of QTreeWidgetItem) -</dd> -</dl><a NAME="Pep8Dialog.__itemFixable" ID="Pep8Dialog.__itemFixable"></a> -<h4>Pep8Dialog.__itemFixable</h4> -<b>__itemFixable</b>(<i>itm</i>) -<p> - Private method to check, if an item has a fixable issue. -</p><dl> -<dt><i>itm</i></dt> -<dd> -item to be checked (QTreeWidgetItem) -</dd> -</dl><dl> -<dt>Returns:</dt> -<dd> -flag indicating a fixable issue (boolean) -</dd> -</dl><a NAME="Pep8Dialog.__modifyFixedResultItem" ID="Pep8Dialog.__modifyFixedResultItem"></a> -<h4>Pep8Dialog.__modifyFixedResultItem</h4> -<b>__modifyFixedResultItem</b>(<i>itm, text, fixed</i>) -<p> - Private method to modify a result list entry to show its - positive fixed state. -</p><dl> -<dt><i>itm</i></dt> -<dd> -reference to the item to modify (QTreeWidgetItem) -</dd><dt><i>text</i></dt> -<dd> -text to be appended (string) -</dd><dt><i>fixed</i></dt> -<dd> -flag indicating a fixed issue (boolean) -</dd> -</dl><a NAME="Pep8Dialog.__resetStatistics" ID="Pep8Dialog.__resetStatistics"></a> -<h4>Pep8Dialog.__resetStatistics</h4> -<b>__resetStatistics</b>(<i></i>) -<p> - Private slot to reset the statistics data. -</p><a NAME="Pep8Dialog.__resort" ID="Pep8Dialog.__resort"></a> -<h4>Pep8Dialog.__resort</h4> -<b>__resort</b>(<i></i>) -<p> - Private method to resort the tree. -</p><a NAME="Pep8Dialog.__selectCodes" ID="Pep8Dialog.__selectCodes"></a> -<h4>Pep8Dialog.__selectCodes</h4> -<b>__selectCodes</b>(<i>edit, showFixCodes</i>) -<p> - Private method to select message codes via a selection dialog. -</p><dl> -<dt><i>edit</i></dt> -<dd> -reference of the line edit to be populated (QLineEdit) -</dd><dt><i>showFixCodes</i></dt> -<dd> -flag indicating to show a list of fixable - issues (boolean) -</dd> -</dl><a NAME="Pep8Dialog.__updateFixerStatistics" ID="Pep8Dialog.__updateFixerStatistics"></a> -<h4>Pep8Dialog.__updateFixerStatistics</h4> -<b>__updateFixerStatistics</b>(<i>fixer</i>) -<p> - Private method to update the collected fixer related statistics. -</p><dl> -<dt><i>fixer</i></dt> -<dd> -reference to the PEP 8 fixer (Pep8Fixer) -</dd> -</dl><a NAME="Pep8Dialog.__updateStatistics" ID="Pep8Dialog.__updateStatistics"></a> -<h4>Pep8Dialog.__updateStatistics</h4> -<b>__updateStatistics</b>(<i>statistics, fixer</i>) -<p> - Private method to update the collected statistics. -</p><dl> -<dt><i>statistics</i></dt> -<dd> -dictionary of statistical data with - message code as key and message count as value -</dd><dt><i>fixer</i></dt> -<dd> -reference to the PEP 8 fixer (Pep8Fixer) -</dd> -</dl><a NAME="Pep8Dialog.on_buttonBox_clicked" ID="Pep8Dialog.on_buttonBox_clicked"></a> -<h4>Pep8Dialog.on_buttonBox_clicked</h4> -<b>on_buttonBox_clicked</b>(<i>button</i>) -<p> - Private slot called by a button of the button box clicked. -</p><dl> -<dt><i>button</i></dt> -<dd> -button that was clicked (QAbstractButton) -</dd> -</dl><a NAME="Pep8Dialog.on_excludeMessagesSelectButton_clicked" ID="Pep8Dialog.on_excludeMessagesSelectButton_clicked"></a> -<h4>Pep8Dialog.on_excludeMessagesSelectButton_clicked</h4> -<b>on_excludeMessagesSelectButton_clicked</b>(<i></i>) -<p> - Private slot to select the message codes to be excluded via a - selection dialog. -</p><a NAME="Pep8Dialog.on_fixButton_clicked" ID="Pep8Dialog.on_fixButton_clicked"></a> -<h4>Pep8Dialog.on_fixButton_clicked</h4> -<b>on_fixButton_clicked</b>(<i></i>) -<p> - Private slot to fix selected issues. -</p><a NAME="Pep8Dialog.on_fixIssuesSelectButton_clicked" ID="Pep8Dialog.on_fixIssuesSelectButton_clicked"></a> -<h4>Pep8Dialog.on_fixIssuesSelectButton_clicked</h4> -<b>on_fixIssuesSelectButton_clicked</b>(<i></i>) -<p> - Private slot to select the issue codes to be fixed via a - selection dialog. -</p><a NAME="Pep8Dialog.on_includeMessagesSelectButton_clicked" ID="Pep8Dialog.on_includeMessagesSelectButton_clicked"></a> -<h4>Pep8Dialog.on_includeMessagesSelectButton_clicked</h4> -<b>on_includeMessagesSelectButton_clicked</b>(<i></i>) -<p> - Private slot to select the message codes to be included via a - selection dialog. -</p><a NAME="Pep8Dialog.on_loadDefaultButton_clicked" ID="Pep8Dialog.on_loadDefaultButton_clicked"></a> -<h4>Pep8Dialog.on_loadDefaultButton_clicked</h4> -<b>on_loadDefaultButton_clicked</b>(<i></i>) -<p> - Private slot to load the default configuration values. -</p><a NAME="Pep8Dialog.on_noFixIssuesSelectButton_clicked" ID="Pep8Dialog.on_noFixIssuesSelectButton_clicked"></a> -<h4>Pep8Dialog.on_noFixIssuesSelectButton_clicked</h4> -<b>on_noFixIssuesSelectButton_clicked</b>(<i></i>) -<p> - Private slot to select the issue codes not to be fixed via a - selection dialog. -</p><a NAME="Pep8Dialog.on_resetDefaultButton_clicked" ID="Pep8Dialog.on_resetDefaultButton_clicked"></a> -<h4>Pep8Dialog.on_resetDefaultButton_clicked</h4> -<b>on_resetDefaultButton_clicked</b>(<i></i>) -<p> - Private slot to reset the configuration values to their default values. -</p><a NAME="Pep8Dialog.on_resultList_itemActivated" ID="Pep8Dialog.on_resultList_itemActivated"></a> -<h4>Pep8Dialog.on_resultList_itemActivated</h4> -<b>on_resultList_itemActivated</b>(<i>item, column</i>) -<p> - Private slot to handle the activation of an item. -</p><dl> -<dt><i>item</i></dt> -<dd> -reference to the activated item (QTreeWidgetItem) -</dd><dt><i>column</i></dt> -<dd> -column the item was activated in (integer) -</dd> -</dl><a NAME="Pep8Dialog.on_resultList_itemSelectionChanged" ID="Pep8Dialog.on_resultList_itemSelectionChanged"></a> -<h4>Pep8Dialog.on_resultList_itemSelectionChanged</h4> -<b>on_resultList_itemSelectionChanged</b>(<i></i>) -<p> - Private slot to change the dialog state depending on the selection. -</p><a NAME="Pep8Dialog.on_showButton_clicked" ID="Pep8Dialog.on_showButton_clicked"></a> -<h4>Pep8Dialog.on_showButton_clicked</h4> -<b>on_showButton_clicked</b>(<i></i>) -<p> - Private slot to handle the "Show" button press. -</p><a NAME="Pep8Dialog.on_startButton_clicked" ID="Pep8Dialog.on_startButton_clicked"></a> -<h4>Pep8Dialog.on_startButton_clicked</h4> -<b>on_startButton_clicked</b>(<i></i>) -<p> - Private slot to start a PEP 8 check run. -</p><a NAME="Pep8Dialog.on_statisticsButton_clicked" ID="Pep8Dialog.on_statisticsButton_clicked"></a> -<h4>Pep8Dialog.on_statisticsButton_clicked</h4> -<b>on_statisticsButton_clicked</b>(<i></i>) -<p> - Private slot to show the statistics dialog. -</p><a NAME="Pep8Dialog.on_storeDefaultButton_clicked" ID="Pep8Dialog.on_storeDefaultButton_clicked"></a> -<h4>Pep8Dialog.on_storeDefaultButton_clicked</h4> -<b>on_storeDefaultButton_clicked</b>(<i></i>) -<p> - Private slot to store the current configuration values as - default values. -</p><a NAME="Pep8Dialog.prepare" ID="Pep8Dialog.prepare"></a> -<h4>Pep8Dialog.prepare</h4> -<b>prepare</b>(<i>fileList, project</i>) -<p> - Public method to prepare the dialog with a list of filenames. -</p><dl> -<dt><i>fileList</i></dt> -<dd> -list of filenames (list of strings) -</dd><dt><i>project</i></dt> -<dd> -reference to the project object (Project) -</dd> -</dl><a NAME="Pep8Dialog.start" ID="Pep8Dialog.start"></a> -<h4>Pep8Dialog.start</h4> -<b>start</b>(<i>fn, save=False, repeat=None</i>) -<p> - Public slot to start the PEP 8 check. -</p><dl> -<dt><i>fn</i></dt> -<dd> -file or list of files or directory to be checked - (string or list of strings) -</dd><dt><i>save=</i></dt> -<dd> -flag indicating to save the given - file/file list/directory (boolean) -</dd><dt><i>repeat=</i></dt> -<dd> -state of the repeat check box if it is not None - (None or boolean) -</dd> -</dl> -<div align="right"><a href="#top">Up</a></div> -<hr /><hr /> -<a NAME="Pep8Report" ID="Pep8Report"></a> -<h2>Pep8Report</h2> -<p> - Class implementing a special report to be used with our dialog. -</p> -<h3>Derived from</h3> -pep8.BaseReport -<h3>Class Attributes</h3> -<table> -<tr><td>None</td></tr> -</table> -<h3>Class Methods</h3> -<table> -<tr><td>None</td></tr> -</table> -<h3>Methods</h3> -<table> -<tr> -<td><a href="#Pep8Report.__init__">Pep8Report</a></td> -<td>Constructor</td> -</tr><tr> -<td><a href="#Pep8Report.error_args">error_args</a></td> -<td>Public method to collect the error messages.</td> -</tr> -</table> -<h3>Static Methods</h3> -<table> -<tr><td>None</td></tr> -</table> -<a NAME="Pep8Report.__init__" ID="Pep8Report.__init__"></a> -<h4>Pep8Report (Constructor)</h4> -<b>Pep8Report</b>(<i>options</i>) -<p> - Constructor -</p><dl> -<dt><i>options</i></dt> -<dd> -options for the report (optparse.Values) -</dd> -</dl><a NAME="Pep8Report.error_args" ID="Pep8Report.error_args"></a> -<h4>Pep8Report.error_args</h4> -<b>error_args</b>(<i>line_number, offset, code, check, *args</i>) -<p> - Public method to collect the error messages. -</p><dl> -<dt><i>line_number</i></dt> -<dd> -line number of the issue (integer) -</dd><dt><i>offset</i></dt> -<dd> -position within line of the issue (integer) -</dd><dt><i>code</i></dt> -<dd> -message code (string) -</dd><dt><i>check</i></dt> -<dd> -reference to the checker function (function) -</dd><dt><i>args</i></dt> -<dd> -arguments for the message (list) -</dd> -</dl><dl> -<dt>Returns:</dt> -<dd> -error code (string) -</dd> -</dl> -<div align="right"><a href="#top">Up</a></div> -<hr /> -</body></html> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/CheckerPlugins/Pep8/CodeStyleCheckerDialog.py Mon Sep 30 19:31:22 2013 +0200 @@ -0,0 +1,906 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing a dialog to show the results of the PEP 8 check. +""" + +import os +import fnmatch + +from PyQt4.QtCore import pyqtSlot, Qt +from PyQt4.QtGui import QDialog, QTreeWidgetItem, QAbstractButton, \ + QDialogButtonBox, QApplication, QHeaderView, QIcon + +from E5Gui.E5Application import e5App + +from .Ui_CodeStyleCheckerDialog import Ui_CodeStyleCheckerDialog + +import UI.PixmapCache +import Preferences +import Utilities + +from . import pep8 +from .Pep8NamingChecker import Pep8NamingChecker + +# register the name checker +pep8.register_check(Pep8NamingChecker, Pep8NamingChecker.Codes) + +from .DocStyleChecker import DocStyleChecker + + +class CodeStyleCheckerReport(pep8.BaseReport): + """ + Class implementing a special report to be used with our dialog. + """ + def __init__(self, options): + """ + Constructor + + @param options options for the report (optparse.Values) + """ + super().__init__(options) + + self.__repeat = options.repeat + self.errors = [] + + def error_args(self, line_number, offset, code, check, *args): + """ + Public method to collect the error messages. + + @param line_number line number of the issue (integer) + @param offset position within line of the issue (integer) + @param code message code (string) + @param check reference to the checker function (function) + @param args arguments for the message (list) + @return error code (string) + """ + code = super().error_args(line_number, offset, code, check, *args) + if code and (self.counters[code] == 1 or self.__repeat): + if code in Pep8NamingChecker.Codes: + text = Pep8NamingChecker.getMessage(code, *args) + else: + text = pep8.getMessage(code, *args) + self.errors.append( + (self.filename, line_number, offset, text) + ) + return code + + +class CodeStyleCheckerDialog(QDialog, Ui_CodeStyleCheckerDialog): + """ + Class implementing a dialog to show the results of the PEP 8 check. + """ + filenameRole = Qt.UserRole + 1 + lineRole = Qt.UserRole + 2 + positionRole = Qt.UserRole + 3 + messageRole = Qt.UserRole + 4 + fixableRole = Qt.UserRole + 5 + codeRole = Qt.UserRole + 6 + + def __init__(self, parent=None): + """ + Constructor + + @param parent reference to the parent widget (QWidget) + """ + super().__init__(parent) + self.setupUi(self) + + self.docTypeComboBox.addItem(self.trUtf8("PEP-257"), "pep257") + self.docTypeComboBox.addItem(self.trUtf8("Eric"), "eric") + + self.statisticsButton = self.buttonBox.addButton( + self.trUtf8("Statistics..."), QDialogButtonBox.ActionRole) + self.statisticsButton.setToolTip( + self.trUtf8("Press to show some statistics for the last run")) + self.statisticsButton.setEnabled(False) + self.showButton = self.buttonBox.addButton( + self.trUtf8("Show"), QDialogButtonBox.ActionRole) + self.showButton.setToolTip( + self.trUtf8("Press to show all files containing an issue")) + self.showButton.setEnabled(False) + self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) + self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) + + self.resultList.headerItem().setText(self.resultList.columnCount(), "") + self.resultList.header().setSortIndicator(0, Qt.AscendingOrder) + + self.checkProgress.setVisible(False) + self.checkProgressLabel.setVisible(False) + self.checkProgressLabel.setMaximumWidth(600) + + self.noResults = True + self.cancelled = False + self.__lastFileItem = None + + self.__fileOrFileList = "" + self.__project = None + self.__forProject = False + self.__data = {} + self.__statistics = {} + + self.on_loadDefaultButton_clicked() + + def __resort(self): + """ + Private method to resort the tree. + """ + self.resultList.sortItems(self.resultList.sortColumn(), + self.resultList.header().sortIndicatorOrder() + ) + + def __createResultItem(self, file, line, pos, message, fixed, autofixing): + """ + Private method to create an entry in the result list. + + @param file file name of the file (string) + @param line line number of issue (integer or string) + @param pos character position of issue (integer or string) + @param message message text (string) + @param fixed flag indicating a fixed issue (boolean) + @param autofixing flag indicating, that we are fixing issues + automatically (boolean) + @return reference to the created item (QTreeWidgetItem) + """ + from .Pep8Fixer import Pep8FixableIssues + + if self.__lastFileItem is None: + # It's a new file + self.__lastFileItem = QTreeWidgetItem(self.resultList, [file]) + self.__lastFileItem.setFirstColumnSpanned(True) + self.__lastFileItem.setExpanded(True) + self.__lastFileItem.setData(0, self.filenameRole, file) + + fixable = False + code, message = message.split(None, 1) + itm = QTreeWidgetItem(self.__lastFileItem, + ["{0:6}".format(line), code, message]) + if code.startswith("W"): + itm.setIcon(1, UI.PixmapCache.getIcon("warning.png")) + elif code.startswith("N"): + itm.setIcon(1, UI.PixmapCache.getIcon("namingError.png")) + elif code.startswith("D"): + itm.setIcon(1, UI.PixmapCache.getIcon("docstringError.png")) + else: + itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError.png")) + if fixed: + itm.setIcon(0, UI.PixmapCache.getIcon("issueFixed.png")) + elif code in Pep8FixableIssues and not autofixing: + itm.setIcon(0, UI.PixmapCache.getIcon("issueFixable.png")) + fixable = True + + itm.setTextAlignment(0, Qt.AlignRight) + itm.setTextAlignment(1, Qt.AlignHCenter) + + itm.setTextAlignment(0, Qt.AlignVCenter) + itm.setTextAlignment(1, Qt.AlignVCenter) + itm.setTextAlignment(2, Qt.AlignVCenter) + + itm.setData(0, self.filenameRole, file) + itm.setData(0, self.lineRole, int(line)) + itm.setData(0, self.positionRole, int(pos)) + itm.setData(0, self.messageRole, message) + itm.setData(0, self.fixableRole, fixable) + itm.setData(0, self.codeRole, code) + + return itm + + def __modifyFixedResultItem(self, itm, text, fixed): + """ + Private method to modify a result list entry to show its + positive fixed state. + + @param itm reference to the item to modify (QTreeWidgetItem) + @param text text to be appended (string) + @param fixed flag indicating a fixed issue (boolean) + """ + if fixed: + message = itm.data(0, self.messageRole) + text + itm.setText(2, message) + itm.setIcon(0, UI.PixmapCache.getIcon("issueFixed.png")) + + itm.setData(0, self.messageRole, message) + else: + itm.setIcon(0, QIcon()) + itm.setData(0, self.fixableRole, False) + + def __updateStatistics(self, statistics, fixer): + """ + Private method to update the collected statistics. + + @param statistics dictionary of statistical data with + message code as key and message count as value + @param fixer reference to the PEP 8 fixer (Pep8Fixer) + """ + self.__statistics["_FilesCount"] += 1 + stats = {v: k for v, k in statistics.items() if v[0].isupper()} + if stats: + self.__statistics["_FilesIssues"] += 1 + for key in statistics: + if key in self.__statistics: + self.__statistics[key] += statistics[key] + else: + self.__statistics[key] = statistics[key] + if fixer: + self.__statistics["_IssuesFixed"] += fixer.fixed + + def __updateFixerStatistics(self, fixer): + """ + Private method to update the collected fixer related statistics. + + @param fixer reference to the PEP 8 fixer (Pep8Fixer) + """ + self.__statistics["_IssuesFixed"] += fixer.fixed + + def __resetStatistics(self): + """ + Private slot to reset the statistics data. + """ + self.__statistics = {} + self.__statistics["_FilesCount"] = 0 + self.__statistics["_FilesIssues"] = 0 + self.__statistics["_IssuesFixed"] = 0 + + def prepare(self, fileList, project): + """ + Public method to prepare the dialog with a list of filenames. + + @param fileList list of filenames (list of strings) + @param project reference to the project object (Project) + """ + self.__fileOrFileList = fileList[:] + self.__project = project + self.__forProject = True + + self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) + self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) + self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) + + self.__data = self.__project.getData("CHECKERSPARMS", "Pep8Checker") + if self.__data is None or \ + len(self.__data) < 6: + # initialize the data structure + self.__data = { + "ExcludeFiles": "", + "ExcludeMessages": pep8.DEFAULT_IGNORE, + "IncludeMessages": "", + "RepeatMessages": False, + "FixCodes": "", + "FixIssues": False, + } + if "MaxLineLength" not in self.__data: + self.__data["MaxLineLength"] = pep8.MAX_LINE_LENGTH + if "HangClosing" not in self.__data: + self.__data["HangClosing"] = False + if "NoFixCodes" not in self.__data: + self.__data["NoFixCodes"] = "E501" + if "DocstringType" not in self.__data: + self.__data["DocstringType"] = "pep257" + + self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) + self.excludeMessagesEdit.setText(self.__data["ExcludeMessages"]) + self.includeMessagesEdit.setText(self.__data["IncludeMessages"]) + self.repeatCheckBox.setChecked(self.__data["RepeatMessages"]) + self.fixIssuesEdit.setText(self.__data["FixCodes"]) + self.noFixIssuesEdit.setText(self.__data["NoFixCodes"]) + self.fixIssuesCheckBox.setChecked(self.__data["FixIssues"]) + self.lineLengthSpinBox.setValue(self.__data["MaxLineLength"]) + self.hangClosingCheckBox.setChecked(self.__data["HangClosing"]) + self.docTypeComboBox.setCurrentIndex( + self.docTypeComboBox.findData(self.__data["DocstringType"])) + + def start(self, fn, save=False, repeat=None): + """ + Public slot to start the PEP 8 check. + + @param fn file or list of files or directory to be checked + (string or list of strings) + @keyparam save flag indicating to save the given + file/file list/directory (boolean) + @keyparam repeat state of the repeat check box if it is not None + (None or boolean) + """ + if self.__project is None: + self.__project = e5App().getObject("Project") + + self.cancelled = False + self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) + self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) + self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) + self.statisticsButton.setEnabled(False) + self.showButton.setEnabled(False) + self.fixButton.setEnabled(False) + self.startButton.setEnabled(False) + if repeat is not None: + self.repeatCheckBox.setChecked(repeat) + self.checkProgress.setVisible(True) + QApplication.processEvents() + + self.__resetStatistics() + + if save: + self.__fileOrFileList = fn + + if isinstance(fn, list): + files = fn[:] + elif os.path.isdir(fn): + files = [] + for ext in Preferences.getPython("Python3Extensions"): + files.extend( + Utilities.direntries(fn, 1, '*{0}'.format(ext), 0)) + for ext in Preferences.getPython("PythonExtensions"): + files.extend( + Utilities.direntries(fn, 1, '*{0}'.format(ext), 0)) + else: + files = [fn] + + # filter the list depending on the filter string + if files: + filterString = self.excludeFilesEdit.text() + filterList = [f.strip() for f in filterString.split(",") + if f.strip()] + for filter in filterList: + files = \ + [f for f in files + if not fnmatch.fnmatch(f, filter.strip())] + + py3files = [f for f in files \ + if f.endswith( + tuple(Preferences.getPython("Python3Extensions")))] + py2files = [f for f in files \ + if f.endswith( + tuple(Preferences.getPython("PythonExtensions")))] + + if len(py3files) + len(py2files) > 0: + self.checkProgress.setMaximum(len(py3files) + len(py2files)) + self.checkProgressLabel.setVisible( + len(py3files) + len(py2files) > 1) + QApplication.processEvents() + + # extract the configuration values + excludeMessages = self.excludeMessagesEdit.text() + includeMessages = self.includeMessagesEdit.text() + repeatMessages = self.repeatCheckBox.isChecked() + fixCodes = self.fixIssuesEdit.text() + noFixCodes = self.noFixIssuesEdit.text() + fixIssues = self.fixIssuesCheckBox.isChecked() and repeatMessages + maxLineLength = self.lineLengthSpinBox.value() + hangClosing = self.hangClosingCheckBox.isChecked() + docType = self.docTypeComboBox.itemData( + self.docTypeComboBox.currentIndex()) + + try: + # disable updates of the list for speed + self.resultList.setUpdatesEnabled(False) + self.resultList.setSortingEnabled(False) + + # now go through all the files + progress = 0 + for file in sorted(py3files + py2files): + self.checkProgress.setValue(progress) + self.checkProgressLabel.setPath(file) + QApplication.processEvents() + + if self.cancelled: + self.__resort() + return + + self.__lastFileItem = None + + try: + source, encoding = Utilities.readEncodedFile(file) + source = source.splitlines(True) + except (UnicodeError, IOError) as msg: + self.noResults = False + self.__createResultItem(file, "1", "1", + self.trUtf8("Error: {0}").format(str(msg))\ + .rstrip()[1:-1], False, False) + progress += 1 + continue + + stats = {} + flags = Utilities.extractFlags(source) + ext = os.path.splitext(file)[1] + if fixIssues: + from .Pep8Fixer import Pep8Fixer + fixer = Pep8Fixer(self.__project, file, source, + fixCodes, noFixCodes, maxLineLength, + True) # always fix in place + else: + fixer = None + if ("FileType" in flags and + flags["FileType"] in ["Python", "Python2"]) or \ + file in py2files or \ + (ext in [".py", ".pyw"] and \ + Preferences.getProject("DeterminePyFromProject") and \ + self.__project.isOpen() and \ + self.__project.isProjectFile(file) and \ + self.__project.getProjectLanguage() in ["Python", + "Python2"]): + from .CodeStyleChecker import CodeStyleCheckerPy2 + report = CodeStyleCheckerPy2(file, [], + repeat=repeatMessages, + select=includeMessages, + ignore=excludeMessages, + max_line_length=maxLineLength, + hang_closing=hangClosing, + docType=docType, + ) + errors = report.errors[:] + stats.update(report.counters) + else: + if includeMessages: + select = [s.strip() for s in includeMessages.split(',') + if s.strip()] + else: + select = [] + if excludeMessages: + ignore = [i.strip() for i in excludeMessages.split(',') + if i.strip()] + else: + ignore = [] + + # check PEP-8 + styleGuide = pep8.StyleGuide( + reporter=CodeStyleCheckerReport, + repeat=repeatMessages, + select=select, + ignore=ignore, + max_line_length=maxLineLength, + hang_closing=hangClosing, + ) + report = styleGuide.check_files([file]) + stats.update(report.counters) + + # check PEP-257 + pep257Checker = DocStyleChecker( + source, file, select, ignore, [], repeatMessages, + maxLineLength=maxLineLength, docType=docType) + pep257Checker.run() + stats.update(pep257Checker.counters) + + errors = report.errors + pep257Checker.errors + + deferredFixes = {} + for error in errors: + fname, lineno, position, text = error + if lineno > len(source): + lineno = len(source) + if "__IGNORE_WARNING__" not in Utilities.extractLineFlags( + source[lineno - 1].strip()): + self.noResults = False + if fixer: + res, msg, id_ = fixer.fixIssue(lineno, position, text) + if res == 1: + text += "\n" + \ + self.trUtf8("Fix: {0}").format(msg) + self.__createResultItem( + fname, lineno, position, text, True, True) + elif res == 0: + self.__createResultItem( + fname, lineno, position, text, False, True) + else: + itm = self.__createResultItem( + fname, lineno, position, + text, False, False) + deferredFixes[id_] = itm + else: + self.__createResultItem( + fname, lineno, position, text, False, False) + if fixer: + deferredResults = fixer.finalize() + for id_ in deferredResults: + fixed, msg = deferredResults[id_] + itm = deferredFixes[id_] + if fixed == 1: + text = "\n" + self.trUtf8("Fix: {0}").format(msg) + self.__modifyFixedResultItem(itm, text, True) + else: + self.__modifyFixedResultItem(itm, "", False) + fixer.saveFile(encoding) + self.__updateStatistics(stats, fixer) + progress += 1 + finally: + # reenable updates of the list + self.resultList.setSortingEnabled(True) + self.resultList.setUpdatesEnabled(True) + self.checkProgress.setValue(progress) + self.checkProgressLabel.setPath("") + QApplication.processEvents() + self.__resort() + else: + self.checkProgress.setMaximum(1) + self.checkProgress.setValue(1) + self.__finish() + + def __finish(self): + """ + Private slot called when the PEP 8 check finished or the user + pressed the cancel button. + """ + self.cancelled = True + self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) + self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) + self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) + self.statisticsButton.setEnabled(True) + self.showButton.setEnabled(True) + self.startButton.setEnabled(True) + + if self.noResults: + QTreeWidgetItem(self.resultList, [self.trUtf8('No issues found.')]) + QApplication.processEvents() + self.statisticsButton.setEnabled(False) + self.showButton.setEnabled(False) + self.__clearErrors() + else: + self.statisticsButton.setEnabled(True) + self.showButton.setEnabled(True) + self.resultList.header().resizeSections(QHeaderView.ResizeToContents) + self.resultList.header().setStretchLastSection(True) + + self.checkProgress.setVisible(False) + self.checkProgressLabel.setVisible(False) + + @pyqtSlot() + def on_startButton_clicked(self): + """ + Private slot to start a PEP 8 check run. + """ + if self.__forProject: + data = { + "ExcludeFiles": self.excludeFilesEdit.text(), + "ExcludeMessages": self.excludeMessagesEdit.text(), + "IncludeMessages": self.includeMessagesEdit.text(), + "RepeatMessages": self.repeatCheckBox.isChecked(), + "FixCodes": self.fixIssuesEdit.text(), + "NoFixCodes": self.noFixIssuesEdit.text(), + "FixIssues": self.fixIssuesCheckBox.isChecked(), + "MaxLineLength": self.lineLengthSpinBox.value(), + "HangClosing": self.hangClosingCheckBox.isChecked(), + "DocstringType": self.docTypeComboBox.itemData( + self.docTypeComboBox.currentIndex()), + } + if data != self.__data: + self.__data = data + self.__project.setData("CHECKERSPARMS", "Pep8Checker", + self.__data) + + self.resultList.clear() + self.noResults = True + self.cancelled = False + self.start(self.__fileOrFileList) + + def __selectCodes(self, edit, showFixCodes): + """ + Private method to select message codes via a selection dialog. + + @param edit reference of the line edit to be populated (QLineEdit) + @param showFixCodes flag indicating to show a list of fixable + issues (boolean) + """ + from .CodeStyleCodeSelectionDialog import CodeStyleCodeSelectionDialog + dlg = CodeStyleCodeSelectionDialog(edit.text(), showFixCodes, self) + if dlg.exec_() == QDialog.Accepted: + edit.setText(dlg.getSelectedCodes()) + + @pyqtSlot() + def on_excludeMessagesSelectButton_clicked(self): + """ + Private slot to select the message codes to be excluded via a + selection dialog. + """ + self.__selectCodes(self.excludeMessagesEdit, False) + + @pyqtSlot() + def on_includeMessagesSelectButton_clicked(self): + """ + Private slot to select the message codes to be included via a + selection dialog. + """ + self.__selectCodes(self.includeMessagesEdit, False) + + @pyqtSlot() + def on_fixIssuesSelectButton_clicked(self): + """ + Private slot to select the issue codes to be fixed via a + selection dialog. + """ + self.__selectCodes(self.fixIssuesEdit, True) + + @pyqtSlot() + def on_noFixIssuesSelectButton_clicked(self): + """ + Private slot to select the issue codes not to be fixed via a + selection dialog. + """ + self.__selectCodes(self.noFixIssuesEdit, True) + + @pyqtSlot(QTreeWidgetItem, int) + def on_resultList_itemActivated(self, item, column): + """ + Private slot to handle the activation of an item. + + @param item reference to the activated item (QTreeWidgetItem) + @param column column the item was activated in (integer) + """ + if self.noResults: + return + + if item.parent(): + fn = Utilities.normabspath(item.data(0, self.filenameRole)) + lineno = item.data(0, self.lineRole) + position = item.data(0, self.positionRole) + message = item.data(0, self.messageRole) + code = item.data(0, self.codeRole) + + vm = e5App().getObject("ViewManager") + vm.openSourceFile(fn, lineno=lineno, pos=position + 1) + editor = vm.getOpenEditor(fn) + + if code == "E901": + editor.toggleSyntaxError(lineno, 0, True, message, True) + else: + editor.toggleFlakesWarning( + lineno, True, message, warningType=editor.WarningStyle) + + @pyqtSlot() + def on_resultList_itemSelectionChanged(self): + """ + Private slot to change the dialog state depending on the selection. + """ + self.fixButton.setEnabled(len(self.__getSelectedFixableItems()) > 0) + + @pyqtSlot() + def on_showButton_clicked(self): + """ + Private slot to handle the "Show" button press. + """ + vm = e5App().getObject("ViewManager") + + selectedIndexes = [] + for index in range(self.resultList.topLevelItemCount()): + if self.resultList.topLevelItem(index).isSelected(): + selectedIndexes.append(index) + if len(selectedIndexes) == 0: + selectedIndexes = list(range(self.resultList.topLevelItemCount())) + for index in selectedIndexes: + itm = self.resultList.topLevelItem(index) + fn = Utilities.normabspath(itm.data(0, self.filenameRole)) + vm.openSourceFile(fn, 1) + editor = vm.getOpenEditor(fn) + editor.clearFlakesWarnings() + for cindex in range(itm.childCount()): + citm = itm.child(cindex) + lineno = citm.data(0, self.lineRole) + message = citm.data(0, self.messageRole) + editor.toggleFlakesWarning(lineno, True, message) + + # go through the list again to clear warning markers for files, + # that are ok + openFiles = vm.getOpenFilenames() + errorFiles = [] + for index in range(self.resultList.topLevelItemCount()): + itm = self.resultList.topLevelItem(index) + errorFiles.append( + Utilities.normabspath(itm.data(0, self.filenameRole))) + for file in openFiles: + if not file in errorFiles: + editor = vm.getOpenEditor(file) + editor.clearFlakesWarnings() + + @pyqtSlot() + def on_statisticsButton_clicked(self): + """ + Private slot to show the statistics dialog. + """ + from .CodeStyleStatisticsDialog import CodeStyleStatisticsDialog + dlg = CodeStyleStatisticsDialog(self.__statistics, self) + dlg.exec_() + + @pyqtSlot() + def on_loadDefaultButton_clicked(self): + """ + Private slot to load the default configuration values. + """ + self.excludeFilesEdit.setText(Preferences.Prefs.settings.value( + "PEP8/ExcludeFilePatterns")) + self.excludeMessagesEdit.setText(Preferences.Prefs.settings.value( + "PEP8/ExcludeMessages", pep8.DEFAULT_IGNORE)) + self.includeMessagesEdit.setText(Preferences.Prefs.settings.value( + "PEP8/IncludeMessages")) + self.repeatCheckBox.setChecked(Preferences.toBool( + Preferences.Prefs.settings.value("PEP8/RepeatMessages"))) + self.fixIssuesEdit.setText(Preferences.Prefs.settings.value( + "PEP8/FixCodes")) + self.noFixIssuesEdit.setText(Preferences.Prefs.settings.value( + "PEP8/NoFixCodes", "E501")) + self.fixIssuesCheckBox.setChecked(Preferences.toBool( + Preferences.Prefs.settings.value("PEP8/FixIssues"))) + self.lineLengthSpinBox.setValue(int(Preferences.Prefs.settings.value( + "PEP8/MaxLineLength", pep8.MAX_LINE_LENGTH))) + self.hangClosingCheckBox.setChecked(Preferences.toBool( + Preferences.Prefs.settings.value("PEP8/HangClosing"))) + self.docTypeComboBox.setCurrentIndex(self.docTypeComboBox.findData( + Preferences.Prefs.settings.value("PEP8/DocstringType", "pep257"))) + + @pyqtSlot() + def on_storeDefaultButton_clicked(self): + """ + Private slot to store the current configuration values as + default values. + """ + Preferences.Prefs.settings.setValue("PEP8/ExcludeFilePatterns", + self.excludeFilesEdit.text()) + Preferences.Prefs.settings.setValue("PEP8/ExcludeMessages", + self.excludeMessagesEdit.text()) + Preferences.Prefs.settings.setValue("PEP8/IncludeMessages", + self.includeMessagesEdit.text()) + Preferences.Prefs.settings.setValue("PEP8/RepeatMessages", + self.repeatCheckBox.isChecked()) + Preferences.Prefs.settings.setValue("PEP8/FixCodes", + self.fixIssuesEdit.text()) + Preferences.Prefs.settings.setValue("PEP8/NoFixCodes", + self.noFixIssuesEdit.text()) + Preferences.Prefs.settings.setValue("PEP8/FixIssues", + self.fixIssuesCheckBox.isChecked()) + Preferences.Prefs.settings.setValue("PEP8/MaxLineLength", + self.lineLengthSpinBox.value()) + Preferences.Prefs.settings.setValue("PEP8/HangClosing", + self.hangClosingCheckBox.isChecked()) + Preferences.Prefs.settings.setValue("PEP8/DocstringType", + self.docTypeComboBox.itemData( + self.docTypeComboBox.currentIndex())) + + @pyqtSlot() + def on_resetDefaultButton_clicked(self): + """ + Private slot to reset the configuration values to their default values. + """ + Preferences.Prefs.settings.setValue("PEP8/ExcludeFilePatterns", "") + Preferences.Prefs.settings.setValue("PEP8/ExcludeMessages", + pep8.DEFAULT_IGNORE) + Preferences.Prefs.settings.setValue("PEP8/IncludeMessages", "") + Preferences.Prefs.settings.setValue("PEP8/RepeatMessages", False) + Preferences.Prefs.settings.setValue("PEP8/FixCodes", "") + Preferences.Prefs.settings.setValue("PEP8/NoFixCodes", "E501") + Preferences.Prefs.settings.setValue("PEP8/FixIssues", False) + Preferences.Prefs.settings.setValue("PEP8/MaxLineLength", + pep8.MAX_LINE_LENGTH) + Preferences.Prefs.settings.setValue("PEP8/HangClosing", False) + Preferences.Prefs.settings.setValue("PEP8/DocstringType", "pep257") + + @pyqtSlot(QAbstractButton) + def on_buttonBox_clicked(self, button): + """ + Private slot called by a button of the button box clicked. + + @param button button that was clicked (QAbstractButton) + """ + if button == self.buttonBox.button(QDialogButtonBox.Close): + self.close() + elif button == self.buttonBox.button(QDialogButtonBox.Cancel): + self.__finish() + elif button == self.showButton: + self.on_showButton_clicked() + elif button == self.statisticsButton: + self.on_statisticsButton_clicked() + + def __clearErrors(self): + """ + Private method to clear all warning markers of open editors. + """ + vm = e5App().getObject("ViewManager") + openFiles = vm.getOpenFilenames() + for file in openFiles: + editor = vm.getOpenEditor(file) + editor.clearFlakesWarnings() + + @pyqtSlot() + def on_fixButton_clicked(self): + """ + Private slot to fix selected issues. + """ + from .Pep8Fixer import Pep8Fixer + + # build a dictionary of issues to fix + fixableItems = self.__getSelectedFixableItems() + fixesDict = {} # dictionary of lists of tuples containing + # the issue and the item + for itm in fixableItems: + filename = itm.data(0, self.filenameRole) + if filename not in fixesDict: + fixesDict[filename] = [] + fixesDict[filename].append(( + (itm.data(0, self.lineRole), + itm.data(0, self.positionRole), + "{0} {1}".format(itm.data(0, self.codeRole), + itm.data(0, self.messageRole))), + itm + )) + + # extract the configuration values + fixCodes = self.fixIssuesEdit.text() + noFixCodes = self.noFixIssuesEdit.text() + maxLineLength = self.lineLengthSpinBox.value() + + # now go through all the files + if fixesDict: + self.checkProgress.setMaximum(len(fixesDict)) + progress = 0 + for file in fixesDict: + self.checkProgress.setValue(progress) + QApplication.processEvents() + + try: + source, encoding = Utilities.readEncodedFile(file) + source = source.splitlines(True) + except (UnicodeError, IOError) as msg: + # skip silently because that should not happen + progress += 1 + continue + + deferredFixes = {} + fixer = Pep8Fixer(self.__project, file, source, + fixCodes, noFixCodes, maxLineLength, + True) # always fix in place + errors = fixesDict[file] + errors.sort(key=lambda a: a[0][0]) + for error in errors: + (lineno, position, text), itm = error + if lineno > len(source): + lineno = len(source) + fixed, msg, id_ = fixer.fixIssue(lineno, position, text) + if fixed == 1: + text = "\n" + self.trUtf8("Fix: {0}").format(msg) + self.__modifyFixedResultItem(itm, text, True) + elif fixed == 0: + self.__modifyFixedResultItem(itm, "", False) + else: + # remember item for the deferred fix + deferredFixes[id_] = itm + deferredResults = fixer.finalize() + for id_ in deferredResults: + fixed, msg = deferredResults[id_] + itm = deferredFixes[id_] + if fixed == 1: + text = "\n" + self.trUtf8("Fix: {0}").format(msg) + self.__modifyFixedResultItem(itm, text, True) + else: + self.__modifyFixedResultItem(itm, "", False) + fixer.saveFile(encoding) + + self.__updateFixerStatistics(fixer) + progress += 1 + + self.checkProgress.setValue(progress) + QApplication.processEvents() + + def __getSelectedFixableItems(self): + """ + Private method to extract all selected items for fixable issues. + + @return selected items for fixable issues (list of QTreeWidgetItem) + """ + fixableItems = [] + for itm in self.resultList.selectedItems(): + if itm.childCount() > 0: + for index in range(itm.childCount()): + citm = itm.child(index) + if self.__itemFixable(citm) and not citm in fixableItems: + fixableItems.append(citm) + elif self.__itemFixable(itm) and not itm in fixableItems: + fixableItems.append(itm) + + return fixableItems + + def __itemFixable(self, itm): + """ + Private method to check, if an item has a fixable issue. + + @param itm item to be checked (QTreeWidgetItem) + @return flag indicating a fixable issue (boolean) + """ + return itm.data(0, self.fixableRole)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/CheckerPlugins/Pep8/CodeStyleCheckerDialog.ui Mon Sep 30 19:31:22 2013 +0200 @@ -0,0 +1,510 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CodeStyleCheckerDialog</class> + <widget class="QDialog" name="CodeStyleCheckerDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>650</width> + <height>700</height> + </rect> + </property> + <property name="windowTitle"> + <string>Code Style Check Result</string> + </property> + <property name="whatsThis"> + <string><b>Code Style Check Results</b> +<p>This dialog shows the results of the code style check. Double clicking an +entry will open an editor window and position the cursor at the respective line and position.</p></string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QFrame" name="filterFrame"> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <layout class="QGridLayout" name="gridLayout"> + <property name="margin"> + <number>0</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Exclude Files:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="E5ClearableLineEdit" name="excludeFilesEdit"> + <property name="toolTip"> + <string>Enter filename patterns of files to be excluded separated by a comma</string> + </property> + </widget> + </item> + <item row="0" column="3" rowspan="9"> + <widget class="Line" name="line"> + <property name="lineWidth"> + <number>2</number> + </property> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + </widget> + </item> + <item row="0" column="4" rowspan="9"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QPushButton" name="startButton"> + <property name="toolTip"> + <string>Press to start the code style check run</string> + </property> + <property name="text"> + <string>Start</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="fixButton"> + <property name="toolTip"> + <string>Press to fix the selected issues</string> + </property> + <property name="text"> + <string>Fix Selected</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>18</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="loadDefaultButton"> + <property name="toolTip"> + <string>Press to load the default values</string> + </property> + <property name="text"> + <string>Load Defaults</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="storeDefaultButton"> + <property name="toolTip"> + <string>Press to store the current values as defaults</string> + </property> + <property name="text"> + <string>Store Defaults</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="resetDefaultButton"> + <property name="toolTip"> + <string>Press to reset the default values</string> + </property> + <property name="text"> + <string>Reset Defaults</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Exclude Messages:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="E5ClearableLineEdit" name="excludeMessagesEdit"> + <property name="toolTip"> + <string>Enter message codes or categories to be excluded separated by a comma</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QToolButton" name="excludeMessagesSelectButton"> + <property name="toolTip"> + <string>Press to select the message codes from a list</string> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Included Messages:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="E5ClearableLineEdit" name="includeMessagesEdit"> + <property name="toolTip"> + <string>Enter message codes or categories to be included separated by a comma</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QToolButton" name="includeMessagesSelectButton"> + <property name="toolTip"> + <string>Press to select the message codes from a list</string> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Fix Issues:</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="E5ClearableLineEdit" name="fixIssuesEdit"> + <property name="toolTip"> + <string>Enter message codes of issues to be fixed automatically (leave empty to fix all)</string> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QToolButton" name="fixIssuesSelectButton"> + <property name="toolTip"> + <string>Press to select the message codes from a list</string> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>Don't Fix Issues:</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="E5ClearableLineEdit" name="noFixIssuesEdit"> + <property name="toolTip"> + <string>Enter message codes of issues not to be fixed automatically</string> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QToolButton" name="noFixIssuesSelectButton"> + <property name="toolTip"> + <string>Press to select the message codes from a list</string> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Max. Line Length:</string> + </property> + </widget> + </item> + <item row="5" column="1" colspan="2"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QSpinBox" name="lineLengthSpinBox"> + <property name="statusTip"> + <string>Enter the maximum allowed line length (PEP-8: 79 characters)</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="minimum"> + <number>60</number> + </property> + <property name="maximum"> + <number>119</number> + </property> + <property name="value"> + <number>79</number> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>Docstring Type:</string> + </property> + </widget> + </item> + <item row="6" column="1" colspan="2"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QComboBox" name="docTypeComboBox"> + <property name="toolTip"> + <string>Select the rule set for docstrings</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_4"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="7" column="0" colspan="3"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QCheckBox" name="hangClosingCheckBox"> + <property name="toolTip"> + <string>Select to allow hanging closing brackets</string> + </property> + <property name="text"> + <string>Allow hanging closing brackets</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="8" column="0" colspan="3"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QCheckBox" name="repeatCheckBox"> + <property name="toolTip"> + <string>Select to repeat each message type</string> + </property> + <property name="text"> + <string>Repeat messages</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="fixIssuesCheckBox"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string>Select to fix some issues</string> + </property> + <property name="text"> + <string>Fix issues automatically</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + <zorder>label_2</zorder> + <zorder>excludeFilesEdit</zorder> + <zorder>line</zorder> + <zorder>label</zorder> + <zorder>excludeMessagesEdit</zorder> + <zorder>excludeMessagesSelectButton</zorder> + <zorder>label_3</zorder> + <zorder>includeMessagesEdit</zorder> + <zorder>includeMessagesSelectButton</zorder> + <zorder>label_4</zorder> + <zorder>fixIssuesEdit</zorder> + <zorder>fixIssuesSelectButton</zorder> + <zorder>label_6</zorder> + <zorder>noFixIssuesEdit</zorder> + <zorder>noFixIssuesSelectButton</zorder> + <zorder>label_5</zorder> + <zorder></zorder> + <zorder>label_7</zorder> + </widget> + </item> + <item> + <widget class="QTreeWidget" name="resultList"> + <property name="whatsThis"> + <string><b>Result List</b> +<p>This list shows the results of the code style check. Double clicking +an entry will open this entry in an editor window and position the cursor at +the respective line and position.</p></string> + </property> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="selectionMode"> + <enum>QAbstractItemView::ExtendedSelection</enum> + </property> + <property name="sortingEnabled"> + <bool>true</bool> + </property> + <column> + <property name="text"> + <string>File/Line</string> + </property> + </column> + <column> + <property name="text"> + <string>Code</string> + </property> + </column> + <column> + <property name="text"> + <string>Message</string> + </property> + </column> + </widget> + </item> + <item> + <widget class="E5SqueezeLabelPath" name="checkProgressLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QProgressBar" name="checkProgress"> + <property name="toolTip"> + <string>Shows the progress of the style check check</string> + </property> + <property name="value"> + <number>0</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Close</set> + </property> + </widget> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="6"/> + <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> + <customwidgets> + <customwidget> + <class>E5SqueezeLabelPath</class> + <extends>QLabel</extends> + <header>E5Gui/E5SqueezeLabels.h</header> + </customwidget> + <customwidget> + <class>E5ClearableLineEdit</class> + <extends>QLineEdit</extends> + <header>E5Gui/E5LineEdit.h</header> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>startButton</tabstop> + <tabstop>loadDefaultButton</tabstop> + <tabstop>excludeFilesEdit</tabstop> + <tabstop>excludeMessagesEdit</tabstop> + <tabstop>excludeMessagesSelectButton</tabstop> + <tabstop>includeMessagesEdit</tabstop> + <tabstop>includeMessagesSelectButton</tabstop> + <tabstop>fixIssuesEdit</tabstop> + <tabstop>fixIssuesSelectButton</tabstop> + <tabstop>noFixIssuesEdit</tabstop> + <tabstop>noFixIssuesSelectButton</tabstop> + <tabstop>lineLengthSpinBox</tabstop> + <tabstop>hangClosingCheckBox</tabstop> + <tabstop>repeatCheckBox</tabstop> + <tabstop>fixIssuesCheckBox</tabstop> + <tabstop>storeDefaultButton</tabstop> + <tabstop>resultList</tabstop> + <tabstop>fixButton</tabstop> + <tabstop>resetDefaultButton</tabstop> + <tabstop>buttonBox</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>repeatCheckBox</sender> + <signal>toggled(bool)</signal> + <receiver>fixIssuesCheckBox</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>121</x> + <y>153</y> + </hint> + <hint type="destinationlabel"> + <x>186</x> + <y>160</y> + </hint> + </hints> + </connection> + </connections> +</ui>
--- a/Plugins/CheckerPlugins/Pep8/Pep8Dialog.py Mon Sep 30 19:21:19 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,906 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a dialog to show the results of the PEP 8 check. -""" - -import os -import fnmatch - -from PyQt4.QtCore import pyqtSlot, Qt -from PyQt4.QtGui import QDialog, QTreeWidgetItem, QAbstractButton, \ - QDialogButtonBox, QApplication, QHeaderView, QIcon - -from E5Gui.E5Application import e5App - -from .Ui_Pep8Dialog import Ui_Pep8Dialog - -import UI.PixmapCache -import Preferences -import Utilities - -from . import pep8 -from .Pep8NamingChecker import Pep8NamingChecker - -# register the name checker -pep8.register_check(Pep8NamingChecker, Pep8NamingChecker.Codes) - -from .DocStyleChecker import DocStyleChecker - - -class Pep8Report(pep8.BaseReport): - """ - Class implementing a special report to be used with our dialog. - """ - def __init__(self, options): - """ - Constructor - - @param options options for the report (optparse.Values) - """ - super().__init__(options) - - self.__repeat = options.repeat - self.errors = [] - - def error_args(self, line_number, offset, code, check, *args): - """ - Public method to collect the error messages. - - @param line_number line number of the issue (integer) - @param offset position within line of the issue (integer) - @param code message code (string) - @param check reference to the checker function (function) - @param args arguments for the message (list) - @return error code (string) - """ - code = super().error_args(line_number, offset, code, check, *args) - if code and (self.counters[code] == 1 or self.__repeat): - if code in Pep8NamingChecker.Codes: - text = Pep8NamingChecker.getMessage(code, *args) - else: - text = pep8.getMessage(code, *args) - self.errors.append( - (self.filename, line_number, offset, text) - ) - return code - - -class Pep8Dialog(QDialog, Ui_Pep8Dialog): - """ - Class implementing a dialog to show the results of the PEP 8 check. - """ - filenameRole = Qt.UserRole + 1 - lineRole = Qt.UserRole + 2 - positionRole = Qt.UserRole + 3 - messageRole = Qt.UserRole + 4 - fixableRole = Qt.UserRole + 5 - codeRole = Qt.UserRole + 6 - - def __init__(self, parent=None): - """ - Constructor - - @param parent reference to the parent widget (QWidget) - """ - super().__init__(parent) - self.setupUi(self) - - self.docTypeComboBox.addItem(self.trUtf8("PEP-257"), "pep257") - self.docTypeComboBox.addItem(self.trUtf8("Eric"), "eric") - - self.statisticsButton = self.buttonBox.addButton( - self.trUtf8("Statistics..."), QDialogButtonBox.ActionRole) - self.statisticsButton.setToolTip( - self.trUtf8("Press to show some statistics for the last run")) - self.statisticsButton.setEnabled(False) - self.showButton = self.buttonBox.addButton( - self.trUtf8("Show"), QDialogButtonBox.ActionRole) - self.showButton.setToolTip( - self.trUtf8("Press to show all files containing an issue")) - self.showButton.setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) - - self.resultList.headerItem().setText(self.resultList.columnCount(), "") - self.resultList.header().setSortIndicator(0, Qt.AscendingOrder) - - self.checkProgress.setVisible(False) - self.checkProgressLabel.setVisible(False) - self.checkProgressLabel.setMaximumWidth(600) - - self.noResults = True - self.cancelled = False - self.__lastFileItem = None - - self.__fileOrFileList = "" - self.__project = None - self.__forProject = False - self.__data = {} - self.__statistics = {} - - self.on_loadDefaultButton_clicked() - - def __resort(self): - """ - Private method to resort the tree. - """ - self.resultList.sortItems(self.resultList.sortColumn(), - self.resultList.header().sortIndicatorOrder() - ) - - def __createResultItem(self, file, line, pos, message, fixed, autofixing): - """ - Private method to create an entry in the result list. - - @param file file name of the file (string) - @param line line number of issue (integer or string) - @param pos character position of issue (integer or string) - @param message message text (string) - @param fixed flag indicating a fixed issue (boolean) - @param autofixing flag indicating, that we are fixing issues - automatically (boolean) - @return reference to the created item (QTreeWidgetItem) - """ - from .Pep8Fixer import Pep8FixableIssues - - if self.__lastFileItem is None: - # It's a new file - self.__lastFileItem = QTreeWidgetItem(self.resultList, [file]) - self.__lastFileItem.setFirstColumnSpanned(True) - self.__lastFileItem.setExpanded(True) - self.__lastFileItem.setData(0, self.filenameRole, file) - - fixable = False - code, message = message.split(None, 1) - itm = QTreeWidgetItem(self.__lastFileItem, - ["{0:6}".format(line), code, message]) - if code.startswith("W"): - itm.setIcon(1, UI.PixmapCache.getIcon("warning.png")) - elif code.startswith("N"): - itm.setIcon(1, UI.PixmapCache.getIcon("namingError.png")) - elif code.startswith("D"): - itm.setIcon(1, UI.PixmapCache.getIcon("docstringError.png")) - else: - itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError.png")) - if fixed: - itm.setIcon(0, UI.PixmapCache.getIcon("issueFixed.png")) - elif code in Pep8FixableIssues and not autofixing: - itm.setIcon(0, UI.PixmapCache.getIcon("issueFixable.png")) - fixable = True - - itm.setTextAlignment(0, Qt.AlignRight) - itm.setTextAlignment(1, Qt.AlignHCenter) - - itm.setTextAlignment(0, Qt.AlignVCenter) - itm.setTextAlignment(1, Qt.AlignVCenter) - itm.setTextAlignment(2, Qt.AlignVCenter) - - itm.setData(0, self.filenameRole, file) - itm.setData(0, self.lineRole, int(line)) - itm.setData(0, self.positionRole, int(pos)) - itm.setData(0, self.messageRole, message) - itm.setData(0, self.fixableRole, fixable) - itm.setData(0, self.codeRole, code) - - return itm - - def __modifyFixedResultItem(self, itm, text, fixed): - """ - Private method to modify a result list entry to show its - positive fixed state. - - @param itm reference to the item to modify (QTreeWidgetItem) - @param text text to be appended (string) - @param fixed flag indicating a fixed issue (boolean) - """ - if fixed: - message = itm.data(0, self.messageRole) + text - itm.setText(2, message) - itm.setIcon(0, UI.PixmapCache.getIcon("issueFixed.png")) - - itm.setData(0, self.messageRole, message) - else: - itm.setIcon(0, QIcon()) - itm.setData(0, self.fixableRole, False) - - def __updateStatistics(self, statistics, fixer): - """ - Private method to update the collected statistics. - - @param statistics dictionary of statistical data with - message code as key and message count as value - @param fixer reference to the PEP 8 fixer (Pep8Fixer) - """ - self.__statistics["_FilesCount"] += 1 - stats = {v: k for v, k in statistics.items() if v[0].isupper()} - if stats: - self.__statistics["_FilesIssues"] += 1 - for key in statistics: - if key in self.__statistics: - self.__statistics[key] += statistics[key] - else: - self.__statistics[key] = statistics[key] - if fixer: - self.__statistics["_IssuesFixed"] += fixer.fixed - - def __updateFixerStatistics(self, fixer): - """ - Private method to update the collected fixer related statistics. - - @param fixer reference to the PEP 8 fixer (Pep8Fixer) - """ - self.__statistics["_IssuesFixed"] += fixer.fixed - - def __resetStatistics(self): - """ - Private slot to reset the statistics data. - """ - self.__statistics = {} - self.__statistics["_FilesCount"] = 0 - self.__statistics["_FilesIssues"] = 0 - self.__statistics["_IssuesFixed"] = 0 - - def prepare(self, fileList, project): - """ - Public method to prepare the dialog with a list of filenames. - - @param fileList list of filenames (list of strings) - @param project reference to the project object (Project) - """ - self.__fileOrFileList = fileList[:] - self.__project = project - self.__forProject = True - - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) - - self.__data = self.__project.getData("CHECKERSPARMS", "Pep8Checker") - if self.__data is None or \ - len(self.__data) < 6: - # initialize the data structure - self.__data = { - "ExcludeFiles": "", - "ExcludeMessages": pep8.DEFAULT_IGNORE, - "IncludeMessages": "", - "RepeatMessages": False, - "FixCodes": "", - "FixIssues": False, - } - if "MaxLineLength" not in self.__data: - self.__data["MaxLineLength"] = pep8.MAX_LINE_LENGTH - if "HangClosing" not in self.__data: - self.__data["HangClosing"] = False - if "NoFixCodes" not in self.__data: - self.__data["NoFixCodes"] = "E501" - if "DocstringType" not in self.__data: - self.__data["DocstringType"] = "pep257" - - self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) - self.excludeMessagesEdit.setText(self.__data["ExcludeMessages"]) - self.includeMessagesEdit.setText(self.__data["IncludeMessages"]) - self.repeatCheckBox.setChecked(self.__data["RepeatMessages"]) - self.fixIssuesEdit.setText(self.__data["FixCodes"]) - self.noFixIssuesEdit.setText(self.__data["NoFixCodes"]) - self.fixIssuesCheckBox.setChecked(self.__data["FixIssues"]) - self.lineLengthSpinBox.setValue(self.__data["MaxLineLength"]) - self.hangClosingCheckBox.setChecked(self.__data["HangClosing"]) - self.docTypeComboBox.setCurrentIndex( - self.docTypeComboBox.findData(self.__data["DocstringType"])) - - def start(self, fn, save=False, repeat=None): - """ - Public slot to start the PEP 8 check. - - @param fn file or list of files or directory to be checked - (string or list of strings) - @keyparam save flag indicating to save the given - file/file list/directory (boolean) - @keyparam repeat state of the repeat check box if it is not None - (None or boolean) - """ - if self.__project is None: - self.__project = e5App().getObject("Project") - - self.cancelled = False - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) - self.statisticsButton.setEnabled(False) - self.showButton.setEnabled(False) - self.fixButton.setEnabled(False) - self.startButton.setEnabled(False) - if repeat is not None: - self.repeatCheckBox.setChecked(repeat) - self.checkProgress.setVisible(True) - QApplication.processEvents() - - self.__resetStatistics() - - if save: - self.__fileOrFileList = fn - - if isinstance(fn, list): - files = fn[:] - elif os.path.isdir(fn): - files = [] - for ext in Preferences.getPython("Python3Extensions"): - files.extend( - Utilities.direntries(fn, 1, '*{0}'.format(ext), 0)) - for ext in Preferences.getPython("PythonExtensions"): - files.extend( - Utilities.direntries(fn, 1, '*{0}'.format(ext), 0)) - else: - files = [fn] - - # filter the list depending on the filter string - if files: - filterString = self.excludeFilesEdit.text() - filterList = [f.strip() for f in filterString.split(",") - if f.strip()] - for filter in filterList: - files = \ - [f for f in files - if not fnmatch.fnmatch(f, filter.strip())] - - py3files = [f for f in files \ - if f.endswith( - tuple(Preferences.getPython("Python3Extensions")))] - py2files = [f for f in files \ - if f.endswith( - tuple(Preferences.getPython("PythonExtensions")))] - - if len(py3files) + len(py2files) > 0: - self.checkProgress.setMaximum(len(py3files) + len(py2files)) - self.checkProgressLabel.setVisible( - len(py3files) + len(py2files) > 1) - QApplication.processEvents() - - # extract the configuration values - excludeMessages = self.excludeMessagesEdit.text() - includeMessages = self.includeMessagesEdit.text() - repeatMessages = self.repeatCheckBox.isChecked() - fixCodes = self.fixIssuesEdit.text() - noFixCodes = self.noFixIssuesEdit.text() - fixIssues = self.fixIssuesCheckBox.isChecked() and repeatMessages - maxLineLength = self.lineLengthSpinBox.value() - hangClosing = self.hangClosingCheckBox.isChecked() - docType = self.docTypeComboBox.itemData( - self.docTypeComboBox.currentIndex()) - - try: - # disable updates of the list for speed - self.resultList.setUpdatesEnabled(False) - self.resultList.setSortingEnabled(False) - - # now go through all the files - progress = 0 - for file in sorted(py3files + py2files): - self.checkProgress.setValue(progress) - self.checkProgressLabel.setPath(file) - QApplication.processEvents() - - if self.cancelled: - self.__resort() - return - - self.__lastFileItem = None - - try: - source, encoding = Utilities.readEncodedFile(file) - source = source.splitlines(True) - except (UnicodeError, IOError) as msg: - self.noResults = False - self.__createResultItem(file, "1", "1", - self.trUtf8("Error: {0}").format(str(msg))\ - .rstrip()[1:-1], False, False) - progress += 1 - continue - - stats = {} - flags = Utilities.extractFlags(source) - ext = os.path.splitext(file)[1] - if fixIssues: - from .Pep8Fixer import Pep8Fixer - fixer = Pep8Fixer(self.__project, file, source, - fixCodes, noFixCodes, maxLineLength, - True) # always fix in place - else: - fixer = None - if ("FileType" in flags and - flags["FileType"] in ["Python", "Python2"]) or \ - file in py2files or \ - (ext in [".py", ".pyw"] and \ - Preferences.getProject("DeterminePyFromProject") and \ - self.__project.isOpen() and \ - self.__project.isProjectFile(file) and \ - self.__project.getProjectLanguage() in ["Python", - "Python2"]): - from .CodeStyleChecker import CodeStyleCheckerPy2 - report = CodeStyleCheckerPy2(file, [], - repeat=repeatMessages, - select=includeMessages, - ignore=excludeMessages, - max_line_length=maxLineLength, - hang_closing=hangClosing, - docType=docType, - ) - errors = report.errors[:] - stats.update(report.counters) - else: - if includeMessages: - select = [s.strip() for s in includeMessages.split(',') - if s.strip()] - else: - select = [] - if excludeMessages: - ignore = [i.strip() for i in excludeMessages.split(',') - if i.strip()] - else: - ignore = [] - - # check PEP-8 - styleGuide = pep8.StyleGuide( - reporter=Pep8Report, - repeat=repeatMessages, - select=select, - ignore=ignore, - max_line_length=maxLineLength, - hang_closing=hangClosing, - ) - report = styleGuide.check_files([file]) - stats.update(report.counters) - - # check PEP-257 - pep257Checker = DocStyleChecker( - source, file, select, ignore, [], repeatMessages, - maxLineLength=maxLineLength, docType=docType) - pep257Checker.run() - stats.update(pep257Checker.counters) - - errors = report.errors + pep257Checker.errors - - deferredFixes = {} - for error in errors: - fname, lineno, position, text = error - if lineno > len(source): - lineno = len(source) - if "__IGNORE_WARNING__" not in Utilities.extractLineFlags( - source[lineno - 1].strip()): - self.noResults = False - if fixer: - res, msg, id_ = fixer.fixIssue(lineno, position, text) - if res == 1: - text += "\n" + \ - self.trUtf8("Fix: {0}").format(msg) - self.__createResultItem( - fname, lineno, position, text, True, True) - elif res == 0: - self.__createResultItem( - fname, lineno, position, text, False, True) - else: - itm = self.__createResultItem( - fname, lineno, position, - text, False, False) - deferredFixes[id_] = itm - else: - self.__createResultItem( - fname, lineno, position, text, False, False) - if fixer: - deferredResults = fixer.finalize() - for id_ in deferredResults: - fixed, msg = deferredResults[id_] - itm = deferredFixes[id_] - if fixed == 1: - text = "\n" + self.trUtf8("Fix: {0}").format(msg) - self.__modifyFixedResultItem(itm, text, True) - else: - self.__modifyFixedResultItem(itm, "", False) - fixer.saveFile(encoding) - self.__updateStatistics(stats, fixer) - progress += 1 - finally: - # reenable updates of the list - self.resultList.setSortingEnabled(True) - self.resultList.setUpdatesEnabled(True) - self.checkProgress.setValue(progress) - self.checkProgressLabel.setPath("") - QApplication.processEvents() - self.__resort() - else: - self.checkProgress.setMaximum(1) - self.checkProgress.setValue(1) - self.__finish() - - def __finish(self): - """ - Private slot called when the PEP 8 check finished or the user - pressed the cancel button. - """ - self.cancelled = True - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) - self.statisticsButton.setEnabled(True) - self.showButton.setEnabled(True) - self.startButton.setEnabled(True) - - if self.noResults: - QTreeWidgetItem(self.resultList, [self.trUtf8('No issues found.')]) - QApplication.processEvents() - self.statisticsButton.setEnabled(False) - self.showButton.setEnabled(False) - self.__clearErrors() - else: - self.statisticsButton.setEnabled(True) - self.showButton.setEnabled(True) - self.resultList.header().resizeSections(QHeaderView.ResizeToContents) - self.resultList.header().setStretchLastSection(True) - - self.checkProgress.setVisible(False) - self.checkProgressLabel.setVisible(False) - - @pyqtSlot() - def on_startButton_clicked(self): - """ - Private slot to start a PEP 8 check run. - """ - if self.__forProject: - data = { - "ExcludeFiles": self.excludeFilesEdit.text(), - "ExcludeMessages": self.excludeMessagesEdit.text(), - "IncludeMessages": self.includeMessagesEdit.text(), - "RepeatMessages": self.repeatCheckBox.isChecked(), - "FixCodes": self.fixIssuesEdit.text(), - "NoFixCodes": self.noFixIssuesEdit.text(), - "FixIssues": self.fixIssuesCheckBox.isChecked(), - "MaxLineLength": self.lineLengthSpinBox.value(), - "HangClosing": self.hangClosingCheckBox.isChecked(), - "DocstringType": self.docTypeComboBox.itemData( - self.docTypeComboBox.currentIndex()), - } - if data != self.__data: - self.__data = data - self.__project.setData("CHECKERSPARMS", "Pep8Checker", - self.__data) - - self.resultList.clear() - self.noResults = True - self.cancelled = False - self.start(self.__fileOrFileList) - - def __selectCodes(self, edit, showFixCodes): - """ - Private method to select message codes via a selection dialog. - - @param edit reference of the line edit to be populated (QLineEdit) - @param showFixCodes flag indicating to show a list of fixable - issues (boolean) - """ - from .CodeStyleCodeSelectionDialog import CodeStyleCodeSelectionDialog - dlg = CodeStyleCodeSelectionDialog(edit.text(), showFixCodes, self) - if dlg.exec_() == QDialog.Accepted: - edit.setText(dlg.getSelectedCodes()) - - @pyqtSlot() - def on_excludeMessagesSelectButton_clicked(self): - """ - Private slot to select the message codes to be excluded via a - selection dialog. - """ - self.__selectCodes(self.excludeMessagesEdit, False) - - @pyqtSlot() - def on_includeMessagesSelectButton_clicked(self): - """ - Private slot to select the message codes to be included via a - selection dialog. - """ - self.__selectCodes(self.includeMessagesEdit, False) - - @pyqtSlot() - def on_fixIssuesSelectButton_clicked(self): - """ - Private slot to select the issue codes to be fixed via a - selection dialog. - """ - self.__selectCodes(self.fixIssuesEdit, True) - - @pyqtSlot() - def on_noFixIssuesSelectButton_clicked(self): - """ - Private slot to select the issue codes not to be fixed via a - selection dialog. - """ - self.__selectCodes(self.noFixIssuesEdit, True) - - @pyqtSlot(QTreeWidgetItem, int) - def on_resultList_itemActivated(self, item, column): - """ - Private slot to handle the activation of an item. - - @param item reference to the activated item (QTreeWidgetItem) - @param column column the item was activated in (integer) - """ - if self.noResults: - return - - if item.parent(): - fn = Utilities.normabspath(item.data(0, self.filenameRole)) - lineno = item.data(0, self.lineRole) - position = item.data(0, self.positionRole) - message = item.data(0, self.messageRole) - code = item.data(0, self.codeRole) - - vm = e5App().getObject("ViewManager") - vm.openSourceFile(fn, lineno=lineno, pos=position + 1) - editor = vm.getOpenEditor(fn) - - if code == "E901": - editor.toggleSyntaxError(lineno, 0, True, message, True) - else: - editor.toggleFlakesWarning( - lineno, True, message, warningType=editor.WarningStyle) - - @pyqtSlot() - def on_resultList_itemSelectionChanged(self): - """ - Private slot to change the dialog state depending on the selection. - """ - self.fixButton.setEnabled(len(self.__getSelectedFixableItems()) > 0) - - @pyqtSlot() - def on_showButton_clicked(self): - """ - Private slot to handle the "Show" button press. - """ - vm = e5App().getObject("ViewManager") - - selectedIndexes = [] - for index in range(self.resultList.topLevelItemCount()): - if self.resultList.topLevelItem(index).isSelected(): - selectedIndexes.append(index) - if len(selectedIndexes) == 0: - selectedIndexes = list(range(self.resultList.topLevelItemCount())) - for index in selectedIndexes: - itm = self.resultList.topLevelItem(index) - fn = Utilities.normabspath(itm.data(0, self.filenameRole)) - vm.openSourceFile(fn, 1) - editor = vm.getOpenEditor(fn) - editor.clearFlakesWarnings() - for cindex in range(itm.childCount()): - citm = itm.child(cindex) - lineno = citm.data(0, self.lineRole) - message = citm.data(0, self.messageRole) - editor.toggleFlakesWarning(lineno, True, message) - - # go through the list again to clear warning markers for files, - # that are ok - openFiles = vm.getOpenFilenames() - errorFiles = [] - for index in range(self.resultList.topLevelItemCount()): - itm = self.resultList.topLevelItem(index) - errorFiles.append( - Utilities.normabspath(itm.data(0, self.filenameRole))) - for file in openFiles: - if not file in errorFiles: - editor = vm.getOpenEditor(file) - editor.clearFlakesWarnings() - - @pyqtSlot() - def on_statisticsButton_clicked(self): - """ - Private slot to show the statistics dialog. - """ - from .CodeStyleStatisticsDialog import CodeStyleStatisticsDialog - dlg = CodeStyleStatisticsDialog(self.__statistics, self) - dlg.exec_() - - @pyqtSlot() - def on_loadDefaultButton_clicked(self): - """ - Private slot to load the default configuration values. - """ - self.excludeFilesEdit.setText(Preferences.Prefs.settings.value( - "PEP8/ExcludeFilePatterns")) - self.excludeMessagesEdit.setText(Preferences.Prefs.settings.value( - "PEP8/ExcludeMessages", pep8.DEFAULT_IGNORE)) - self.includeMessagesEdit.setText(Preferences.Prefs.settings.value( - "PEP8/IncludeMessages")) - self.repeatCheckBox.setChecked(Preferences.toBool( - Preferences.Prefs.settings.value("PEP8/RepeatMessages"))) - self.fixIssuesEdit.setText(Preferences.Prefs.settings.value( - "PEP8/FixCodes")) - self.noFixIssuesEdit.setText(Preferences.Prefs.settings.value( - "PEP8/NoFixCodes", "E501")) - self.fixIssuesCheckBox.setChecked(Preferences.toBool( - Preferences.Prefs.settings.value("PEP8/FixIssues"))) - self.lineLengthSpinBox.setValue(int(Preferences.Prefs.settings.value( - "PEP8/MaxLineLength", pep8.MAX_LINE_LENGTH))) - self.hangClosingCheckBox.setChecked(Preferences.toBool( - Preferences.Prefs.settings.value("PEP8/HangClosing"))) - self.docTypeComboBox.setCurrentIndex(self.docTypeComboBox.findData( - Preferences.Prefs.settings.value("PEP8/DocstringType", "pep257"))) - - @pyqtSlot() - def on_storeDefaultButton_clicked(self): - """ - Private slot to store the current configuration values as - default values. - """ - Preferences.Prefs.settings.setValue("PEP8/ExcludeFilePatterns", - self.excludeFilesEdit.text()) - Preferences.Prefs.settings.setValue("PEP8/ExcludeMessages", - self.excludeMessagesEdit.text()) - Preferences.Prefs.settings.setValue("PEP8/IncludeMessages", - self.includeMessagesEdit.text()) - Preferences.Prefs.settings.setValue("PEP8/RepeatMessages", - self.repeatCheckBox.isChecked()) - Preferences.Prefs.settings.setValue("PEP8/FixCodes", - self.fixIssuesEdit.text()) - Preferences.Prefs.settings.setValue("PEP8/NoFixCodes", - self.noFixIssuesEdit.text()) - Preferences.Prefs.settings.setValue("PEP8/FixIssues", - self.fixIssuesCheckBox.isChecked()) - Preferences.Prefs.settings.setValue("PEP8/MaxLineLength", - self.lineLengthSpinBox.value()) - Preferences.Prefs.settings.setValue("PEP8/HangClosing", - self.hangClosingCheckBox.isChecked()) - Preferences.Prefs.settings.setValue("PEP8/DocstringType", - self.docTypeComboBox.itemData( - self.docTypeComboBox.currentIndex())) - - @pyqtSlot() - def on_resetDefaultButton_clicked(self): - """ - Private slot to reset the configuration values to their default values. - """ - Preferences.Prefs.settings.setValue("PEP8/ExcludeFilePatterns", "") - Preferences.Prefs.settings.setValue("PEP8/ExcludeMessages", - pep8.DEFAULT_IGNORE) - Preferences.Prefs.settings.setValue("PEP8/IncludeMessages", "") - Preferences.Prefs.settings.setValue("PEP8/RepeatMessages", False) - Preferences.Prefs.settings.setValue("PEP8/FixCodes", "") - Preferences.Prefs.settings.setValue("PEP8/NoFixCodes", "E501") - Preferences.Prefs.settings.setValue("PEP8/FixIssues", False) - Preferences.Prefs.settings.setValue("PEP8/MaxLineLength", - pep8.MAX_LINE_LENGTH) - Preferences.Prefs.settings.setValue("PEP8/HangClosing", False) - Preferences.Prefs.settings.setValue("PEP8/DocstringType", "pep257") - - @pyqtSlot(QAbstractButton) - def on_buttonBox_clicked(self, button): - """ - Private slot called by a button of the button box clicked. - - @param button button that was clicked (QAbstractButton) - """ - if button == self.buttonBox.button(QDialogButtonBox.Close): - self.close() - elif button == self.buttonBox.button(QDialogButtonBox.Cancel): - self.__finish() - elif button == self.showButton: - self.on_showButton_clicked() - elif button == self.statisticsButton: - self.on_statisticsButton_clicked() - - def __clearErrors(self): - """ - Private method to clear all warning markers of open editors. - """ - vm = e5App().getObject("ViewManager") - openFiles = vm.getOpenFilenames() - for file in openFiles: - editor = vm.getOpenEditor(file) - editor.clearFlakesWarnings() - - @pyqtSlot() - def on_fixButton_clicked(self): - """ - Private slot to fix selected issues. - """ - from .Pep8Fixer import Pep8Fixer - - # build a dictionary of issues to fix - fixableItems = self.__getSelectedFixableItems() - fixesDict = {} # dictionary of lists of tuples containing - # the issue and the item - for itm in fixableItems: - filename = itm.data(0, self.filenameRole) - if filename not in fixesDict: - fixesDict[filename] = [] - fixesDict[filename].append(( - (itm.data(0, self.lineRole), - itm.data(0, self.positionRole), - "{0} {1}".format(itm.data(0, self.codeRole), - itm.data(0, self.messageRole))), - itm - )) - - # extract the configuration values - fixCodes = self.fixIssuesEdit.text() - noFixCodes = self.noFixIssuesEdit.text() - maxLineLength = self.lineLengthSpinBox.value() - - # now go through all the files - if fixesDict: - self.checkProgress.setMaximum(len(fixesDict)) - progress = 0 - for file in fixesDict: - self.checkProgress.setValue(progress) - QApplication.processEvents() - - try: - source, encoding = Utilities.readEncodedFile(file) - source = source.splitlines(True) - except (UnicodeError, IOError) as msg: - # skip silently because that should not happen - progress += 1 - continue - - deferredFixes = {} - fixer = Pep8Fixer(self.__project, file, source, - fixCodes, noFixCodes, maxLineLength, - True) # always fix in place - errors = fixesDict[file] - errors.sort(key=lambda a: a[0][0]) - for error in errors: - (lineno, position, text), itm = error - if lineno > len(source): - lineno = len(source) - fixed, msg, id_ = fixer.fixIssue(lineno, position, text) - if fixed == 1: - text = "\n" + self.trUtf8("Fix: {0}").format(msg) - self.__modifyFixedResultItem(itm, text, True) - elif fixed == 0: - self.__modifyFixedResultItem(itm, "", False) - else: - # remember item for the deferred fix - deferredFixes[id_] = itm - deferredResults = fixer.finalize() - for id_ in deferredResults: - fixed, msg = deferredResults[id_] - itm = deferredFixes[id_] - if fixed == 1: - text = "\n" + self.trUtf8("Fix: {0}").format(msg) - self.__modifyFixedResultItem(itm, text, True) - else: - self.__modifyFixedResultItem(itm, "", False) - fixer.saveFile(encoding) - - self.__updateFixerStatistics(fixer) - progress += 1 - - self.checkProgress.setValue(progress) - QApplication.processEvents() - - def __getSelectedFixableItems(self): - """ - Private method to extract all selected items for fixable issues. - - @return selected items for fixable issues (list of QTreeWidgetItem) - """ - fixableItems = [] - for itm in self.resultList.selectedItems(): - if itm.childCount() > 0: - for index in range(itm.childCount()): - citm = itm.child(index) - if self.__itemFixable(citm) and not citm in fixableItems: - fixableItems.append(citm) - elif self.__itemFixable(itm) and not itm in fixableItems: - fixableItems.append(itm) - - return fixableItems - - def __itemFixable(self, itm): - """ - Private method to check, if an item has a fixable issue. - - @param itm item to be checked (QTreeWidgetItem) - @return flag indicating a fixable issue (boolean) - """ - return itm.data(0, self.fixableRole)
--- a/Plugins/CheckerPlugins/Pep8/Pep8Dialog.ui Mon Sep 30 19:21:19 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,510 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Pep8Dialog</class> - <widget class="QDialog" name="Pep8Dialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>650</width> - <height>700</height> - </rect> - </property> - <property name="windowTitle"> - <string>Code Style Check Result</string> - </property> - <property name="whatsThis"> - <string><b>Code Style Check Results</b> -<p>This dialog shows the results of the code style check. Double clicking an -entry will open an editor window and position the cursor at the respective line and position.</p></string> - </property> - <property name="sizeGripEnabled"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QFrame" name="filterFrame"> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> - </property> - <layout class="QGridLayout" name="gridLayout"> - <property name="margin"> - <number>0</number> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Exclude Files:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="E5ClearableLineEdit" name="excludeFilesEdit"> - <property name="toolTip"> - <string>Enter filename patterns of files to be excluded separated by a comma</string> - </property> - </widget> - </item> - <item row="0" column="3" rowspan="9"> - <widget class="Line" name="line"> - <property name="lineWidth"> - <number>2</number> - </property> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - </widget> - </item> - <item row="0" column="4" rowspan="9"> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QPushButton" name="startButton"> - <property name="toolTip"> - <string>Press to start the code style check run</string> - </property> - <property name="text"> - <string>Start</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="fixButton"> - <property name="toolTip"> - <string>Press to fix the selected issues</string> - </property> - <property name="text"> - <string>Fix Selected</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>18</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="loadDefaultButton"> - <property name="toolTip"> - <string>Press to load the default values</string> - </property> - <property name="text"> - <string>Load Defaults</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="storeDefaultButton"> - <property name="toolTip"> - <string>Press to store the current values as defaults</string> - </property> - <property name="text"> - <string>Store Defaults</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="resetDefaultButton"> - <property name="toolTip"> - <string>Press to reset the default values</string> - </property> - <property name="text"> - <string>Reset Defaults</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Exclude Messages:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="E5ClearableLineEdit" name="excludeMessagesEdit"> - <property name="toolTip"> - <string>Enter message codes or categories to be excluded separated by a comma</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QToolButton" name="excludeMessagesSelectButton"> - <property name="toolTip"> - <string>Press to select the message codes from a list</string> - </property> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Included Messages:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="E5ClearableLineEdit" name="includeMessagesEdit"> - <property name="toolTip"> - <string>Enter message codes or categories to be included separated by a comma</string> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QToolButton" name="includeMessagesSelectButton"> - <property name="toolTip"> - <string>Press to select the message codes from a list</string> - </property> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Fix Issues:</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="E5ClearableLineEdit" name="fixIssuesEdit"> - <property name="toolTip"> - <string>Enter message codes of issues to be fixed automatically (leave empty to fix all)</string> - </property> - </widget> - </item> - <item row="3" column="2"> - <widget class="QToolButton" name="fixIssuesSelectButton"> - <property name="toolTip"> - <string>Press to select the message codes from a list</string> - </property> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>Don't Fix Issues:</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="E5ClearableLineEdit" name="noFixIssuesEdit"> - <property name="toolTip"> - <string>Enter message codes of issues not to be fixed automatically</string> - </property> - </widget> - </item> - <item row="4" column="2"> - <widget class="QToolButton" name="noFixIssuesSelectButton"> - <property name="toolTip"> - <string>Press to select the message codes from a list</string> - </property> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Max. Line Length:</string> - </property> - </widget> - </item> - <item row="5" column="1" colspan="2"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QSpinBox" name="lineLengthSpinBox"> - <property name="statusTip"> - <string>Enter the maximum allowed line length (PEP-8: 79 characters)</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - <property name="minimum"> - <number>60</number> - </property> - <property name="maximum"> - <number>119</number> - </property> - <property name="value"> - <number>79</number> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>Docstring Type:</string> - </property> - </widget> - </item> - <item row="6" column="1" colspan="2"> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QComboBox" name="docTypeComboBox"> - <property name="toolTip"> - <string>Select the rule set for docstrings</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_4"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="7" column="0" colspan="3"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QCheckBox" name="hangClosingCheckBox"> - <property name="toolTip"> - <string>Select to allow hanging closing brackets</string> - </property> - <property name="text"> - <string>Allow hanging closing brackets</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="8" column="0" colspan="3"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QCheckBox" name="repeatCheckBox"> - <property name="toolTip"> - <string>Select to repeat each message type</string> - </property> - <property name="text"> - <string>Repeat messages</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="fixIssuesCheckBox"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="toolTip"> - <string>Select to fix some issues</string> - </property> - <property name="text"> - <string>Fix issues automatically</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - <zorder>label_2</zorder> - <zorder>excludeFilesEdit</zorder> - <zorder>line</zorder> - <zorder>label</zorder> - <zorder>excludeMessagesEdit</zorder> - <zorder>excludeMessagesSelectButton</zorder> - <zorder>label_3</zorder> - <zorder>includeMessagesEdit</zorder> - <zorder>includeMessagesSelectButton</zorder> - <zorder>label_4</zorder> - <zorder>fixIssuesEdit</zorder> - <zorder>fixIssuesSelectButton</zorder> - <zorder>label_6</zorder> - <zorder>noFixIssuesEdit</zorder> - <zorder>noFixIssuesSelectButton</zorder> - <zorder>label_5</zorder> - <zorder></zorder> - <zorder>label_7</zorder> - </widget> - </item> - <item> - <widget class="QTreeWidget" name="resultList"> - <property name="whatsThis"> - <string><b>Result List</b> -<p>This list shows the results of the code style check. Double clicking -an entry will open this entry in an editor window and position the cursor at -the respective line and position.</p></string> - </property> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> - </property> - <property name="sortingEnabled"> - <bool>true</bool> - </property> - <column> - <property name="text"> - <string>File/Line</string> - </property> - </column> - <column> - <property name="text"> - <string>Code</string> - </property> - </column> - <column> - <property name="text"> - <string>Message</string> - </property> - </column> - </widget> - </item> - <item> - <widget class="E5SqueezeLabelPath" name="checkProgressLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QProgressBar" name="checkProgress"> - <property name="toolTip"> - <string>Shows the progress of the style check check</string> - </property> - <property name="value"> - <number>0</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Close</set> - </property> - </widget> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="6"/> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> - <customwidgets> - <customwidget> - <class>E5SqueezeLabelPath</class> - <extends>QLabel</extends> - <header>E5Gui/E5SqueezeLabels.h</header> - </customwidget> - <customwidget> - <class>E5ClearableLineEdit</class> - <extends>QLineEdit</extends> - <header>E5Gui/E5LineEdit.h</header> - </customwidget> - </customwidgets> - <tabstops> - <tabstop>startButton</tabstop> - <tabstop>loadDefaultButton</tabstop> - <tabstop>excludeFilesEdit</tabstop> - <tabstop>excludeMessagesEdit</tabstop> - <tabstop>excludeMessagesSelectButton</tabstop> - <tabstop>includeMessagesEdit</tabstop> - <tabstop>includeMessagesSelectButton</tabstop> - <tabstop>fixIssuesEdit</tabstop> - <tabstop>fixIssuesSelectButton</tabstop> - <tabstop>noFixIssuesEdit</tabstop> - <tabstop>noFixIssuesSelectButton</tabstop> - <tabstop>lineLengthSpinBox</tabstop> - <tabstop>hangClosingCheckBox</tabstop> - <tabstop>repeatCheckBox</tabstop> - <tabstop>fixIssuesCheckBox</tabstop> - <tabstop>storeDefaultButton</tabstop> - <tabstop>resultList</tabstop> - <tabstop>fixButton</tabstop> - <tabstop>resetDefaultButton</tabstop> - <tabstop>buttonBox</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>repeatCheckBox</sender> - <signal>toggled(bool)</signal> - <receiver>fixIssuesCheckBox</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>121</x> - <y>153</y> - </hint> - <hint type="destinationlabel"> - <x>186</x> - <y>160</y> - </hint> - </hints> - </connection> - </connections> -</ui>
--- a/Plugins/PluginPep8Checker.py Mon Sep 30 19:21:19 2013 +0200 +++ b/Plugins/PluginPep8Checker.py Mon Sep 30 19:31:22 2013 +0200 @@ -197,8 +197,9 @@ tuple(Preferences.getPython("Python3Extensions")) + tuple(Preferences.getPython("PythonExtensions")))] - from CheckerPlugins.Pep8.Pep8Dialog import Pep8Dialog - self.__projectPep8CheckerDialog = Pep8Dialog() + from CheckerPlugins.Pep8.CodeStyleCheckerDialog import \ + CodeStyleCheckerDialog + self.__projectPep8CheckerDialog = CodeStyleCheckerDialog() self.__projectPep8CheckerDialog.show() self.__projectPep8CheckerDialog.prepare(files, project) @@ -217,8 +218,9 @@ fn = itm.dirName() isDir = True - from CheckerPlugins.Pep8.Pep8Dialog import Pep8Dialog - self.__projectBrowserPep8CheckerDialog = Pep8Dialog() + from CheckerPlugins.Pep8.CodeStyleCheckerDialog import \ + CodeStyleCheckerDialog + self.__projectBrowserPep8CheckerDialog = CodeStyleCheckerDialog() self.__projectBrowserPep8CheckerDialog.show() if isDir: self.__projectBrowserPep8CheckerDialog.start( @@ -273,8 +275,9 @@ editor = e5App().getObject("ViewManager").activeWindow() if editor is not None: if editor.checkDirty() and editor.getFileName() is not None: - from CheckerPlugins.Pep8.Pep8Dialog import Pep8Dialog - self.__editorPep8CheckerDialog = Pep8Dialog() + from CheckerPlugins.Pep8.CodeStyleCheckerDialog import \ + CodeStyleCheckerDialog + self.__editorPep8CheckerDialog = CodeStyleCheckerDialog() self.__editorPep8CheckerDialog.show() self.__editorPep8CheckerDialog.start( editor.getFileName(),
--- a/eric5.e4p Mon Sep 30 19:21:19 2013 +0200 +++ b/eric5.e4p Mon Sep 30 19:31:22 2013 +0200 @@ -806,13 +806,9 @@ <Source>ThirdParty/Pygments/pygments/lexers/hdl.py</Source> <Source>Plugins/CheckerPlugins/Pep8/__init__.py</Source> <Source>Plugins/CheckerPlugins/Pep8/pep8.py</Source> - <Source>Plugins/CheckerPlugins/Pep8/Pep8Dialog.py</Source> - <Source>Plugins/CheckerPlugins/Pep8/Pep8Checker.py</Source> <Source>Plugins/PluginPep8Checker.py</Source> - <Source>Plugins/CheckerPlugins/Pep8/Pep8CodeSelectionDialog.py</Source> <Source>UtilitiesPython2/pep8.py</Source> <Source>UtilitiesPython2/Pep8Checker.py</Source> - <Source>Plugins/CheckerPlugins/Pep8/Pep8StatisticsDialog.py</Source> <Source>Plugins/CheckerPlugins/Pep8/Pep8Fixer.py</Source> <Source>eric5_compare.py</Source> <Source>eric5_compare.pyw</Source> @@ -1113,6 +1109,7 @@ <Source>Plugins/CheckerPlugins/Pep8/CodeStyleChecker.py</Source> <Source>Plugins/CheckerPlugins/Pep8/CodeStyleStatisticsDialog.py</Source> <Source>Plugins/CheckerPlugins/Pep8/CodeStyleCodeSelectionDialog.py</Source> + <Source>Plugins/CheckerPlugins/Pep8/CodeStyleCheckerDialog.py</Source> </Sources> <Forms> <Form>PyUnit/UnittestDialog.ui</Form> @@ -1340,7 +1337,6 @@ <Form>Helpviewer/Download/DownloadItem.ui</Form> <Form>Helpviewer/Download/DownloadManager.ui</Form> <Form>Preferences/ConfigurationPages/TrayStarterPage.ui</Form> - <Form>Plugins/CheckerPlugins/Pep8/Pep8Dialog.ui</Form> <Form>Preferences/ConfigurationPages/HelpVirusTotalPage.ui</Form> <Form>Helpviewer/Download/DownloadAskActionDialog.ui</Form> <Form>Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/HgBookmarksListDialog.ui</Form> @@ -1433,6 +1429,7 @@ <Form>Plugins/VcsPlugins/vcsMercurial/HgArchiveDialog.ui</Form> <Form>Plugins/CheckerPlugins/Pep8/CodeStyleStatisticsDialog.ui</Form> <Form>Plugins/CheckerPlugins/Pep8/CodeStyleCodeSelectionDialog.ui</Form> + <Form>Plugins/CheckerPlugins/Pep8/CodeStyleCheckerDialog.ui</Form> </Forms> <Translations> <Translation>i18n/eric5_cs.ts</Translation>