Mon, 30 Sep 2013 19:21:19 +0200
Continued changing the names of the various code style checkers to make them more appropriate to the broadened scope.
--- a/Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.Pep8Checker.html Mon Sep 30 19:06:37 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -<!DOCTYPE html> -<html><head> -<title>eric5.Plugins.CheckerPlugins.Pep8.Pep8Checker</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.Pep8Checker</h1> -<p> -Module implementing the PEP 8 checker. -</p> -<h3>Global Attributes</h3> -<table> -<tr><td>None</td></tr> -</table> -<h3>Classes</h3> -<table> -<tr> -<td><a href="#Pep8Py2Checker">Pep8Py2Checker</a></td> -<td>Class implementing the PEP 8 checker interface for Python 2.</td> -</tr> -</table> -<h3>Functions</h3> -<table> -<tr><td>None</td></tr> -</table> -<hr /><hr /> -<a NAME="Pep8Py2Checker" ID="Pep8Py2Checker"></a> -<h2>Pep8Py2Checker</h2> -<p> - Class implementing the PEP 8 checker interface for Python 2. -</p> -<h3>Derived from</h3> -object -<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="#Pep8Py2Checker.__init__">Pep8Py2Checker</a></td> -<td>Constructor</td> -</tr> -</table> -<h3>Static Methods</h3> -<table> -<tr><td>None</td></tr> -</table> -<a NAME="Pep8Py2Checker.__init__" ID="Pep8Py2Checker.__init__"></a> -<h4>Pep8Py2Checker (Constructor)</h4> -<b>Pep8Py2Checker</b>(<i>filename, lines, repeat=False, select="", ignore="", max_line_length=79, hang_closing=False, docType="pep257"</i>) -<p> - Constructor -</p><dl> -<dt><i>filename</i></dt> -<dd> -name of the file to check (string) -</dd><dt><i>lines</i></dt> -<dd> -source of the file (list of strings) (ignored) -</dd><dt><i>repeat=</i></dt> -<dd> -flag indicating to repeat message categories (boolean) -</dd><dt><i>select=</i></dt> -<dd> -list of message IDs to check for - (comma separated string) -</dd><dt><i>ignore=</i></dt> -<dd> -list of message IDs to ignore - (comma separated string) -</dd><dt><i>max_line_length=</i></dt> -<dd> -maximum allowed line length (integer) -</dd><dt><i>hang_closing=</i></dt> -<dd> -flag indicating to allow hanging closing - brackets (boolean) -</dd><dt><i>docType=</i></dt> -<dd> -type of the documentation strings - (string, one of 'eric' or 'pep257') -</dd> -</dl> -<div align="right"><a href="#top">Up</a></div> -<hr /> -</body></html> \ No newline at end of file
--- a/Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.Pep8CodeSelectionDialog.html Mon Sep 30 19:06:37 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -<!DOCTYPE html> -<html><head> -<title>eric5.Plugins.CheckerPlugins.Pep8.Pep8CodeSelectionDialog</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.Pep8CodeSelectionDialog</h1> -<p> -Module implementing a dialog to select PEP 8 message codes. -</p> -<h3>Global Attributes</h3> -<table> -<tr><td>None</td></tr> -</table> -<h3>Classes</h3> -<table> -<tr> -<td><a href="#Pep8CodeSelectionDialog">Pep8CodeSelectionDialog</a></td> -<td>Class implementing a dialog to select PEP 8 message codes.</td> -</tr> -</table> -<h3>Functions</h3> -<table> -<tr><td>None</td></tr> -</table> -<hr /><hr /> -<a NAME="Pep8CodeSelectionDialog" ID="Pep8CodeSelectionDialog"></a> -<h2>Pep8CodeSelectionDialog</h2> -<p> - Class implementing a dialog to select PEP 8 message codes. -</p> -<h3>Derived from</h3> -QDialog, Ui_Pep8CodeSelectionDialog -<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="#Pep8CodeSelectionDialog.__init__">Pep8CodeSelectionDialog</a></td> -<td>Constructor</td> -</tr><tr> -<td><a href="#Pep8CodeSelectionDialog.getSelectedCodes">getSelectedCodes</a></td> -<td>Public method to get a comma separated list of codes selected.</td> -</tr> -</table> -<h3>Static Methods</h3> -<table> -<tr><td>None</td></tr> -</table> -<a NAME="Pep8CodeSelectionDialog.__init__" ID="Pep8CodeSelectionDialog.__init__"></a> -<h4>Pep8CodeSelectionDialog (Constructor)</h4> -<b>Pep8CodeSelectionDialog</b>(<i>codes, showFixCodes, parent=None</i>) -<p> - Constructor -</p><dl> -<dt><i>codes</i></dt> -<dd> -comma separated list of selected codes (string) -</dd><dt><i>showFixCodes</i></dt> -<dd> -flag indicating to show a list of fixable - issues (boolean) -</dd><dt><i>parent</i></dt> -<dd> -reference to the parent widget (QWidget) -</dd> -</dl><a NAME="Pep8CodeSelectionDialog.getSelectedCodes" ID="Pep8CodeSelectionDialog.getSelectedCodes"></a> -<h4>Pep8CodeSelectionDialog.getSelectedCodes</h4> -<b>getSelectedCodes</b>(<i></i>) -<p> - Public method to get a comma separated list of codes selected. -</p><dl> -<dt>Returns:</dt> -<dd> -comma separated list of selected codes (string) -</dd> -</dl> -<div align="right"><a href="#top">Up</a></div> -<hr /> -</body></html> \ No newline at end of file
--- a/Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.Pep8StatisticsDialog.html Mon Sep 30 19:06:37 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -<!DOCTYPE html> -<html><head> -<title>eric5.Plugins.CheckerPlugins.Pep8.Pep8StatisticsDialog</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.Pep8StatisticsDialog</h1> -<p> -Module implementing a dialog showing statistical data for the last code -style checker run. -</p> -<h3>Global Attributes</h3> -<table> -<tr><td>None</td></tr> -</table> -<h3>Classes</h3> -<table> -<tr> -<td><a href="#Pep8StatisticsDialog">Pep8StatisticsDialog</a></td> -<td>Class implementing a dialog showing statistical data for the last code style checker run.</td> -</tr> -</table> -<h3>Functions</h3> -<table> -<tr><td>None</td></tr> -</table> -<hr /><hr /> -<a NAME="Pep8StatisticsDialog" ID="Pep8StatisticsDialog"></a> -<h2>Pep8StatisticsDialog</h2> -<p> - Class implementing a dialog showing statistical data for the last - code style checker run. -</p> -<h3>Derived from</h3> -QDialog, Ui_Pep8StatisticsDialog -<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="#Pep8StatisticsDialog.__init__">Pep8StatisticsDialog</a></td> -<td>Constructor</td> -</tr><tr> -<td><a href="#Pep8StatisticsDialog.__createItem">__createItem</a></td> -<td>Private method to create an entry in the result list.</td> -</tr> -</table> -<h3>Static Methods</h3> -<table> -<tr><td>None</td></tr> -</table> -<a NAME="Pep8StatisticsDialog.__init__" ID="Pep8StatisticsDialog.__init__"></a> -<h4>Pep8StatisticsDialog (Constructor)</h4> -<b>Pep8StatisticsDialog</b>(<i>statistics, parent=None</i>) -<p> - Constructor -</p><dl> -<dt><i>statistics</i></dt> -<dd> -dictionary with the statistical data -</dd><dt><i>parent</i></dt> -<dd> -reference to the parent widget (QWidget) -</dd> -</dl><a NAME="Pep8StatisticsDialog.__createItem" ID="Pep8StatisticsDialog.__createItem"></a> -<h4>Pep8StatisticsDialog.__createItem</h4> -<b>__createItem</b>(<i>count, code, message</i>) -<p> - Private method to create an entry in the result list. -</p><dl> -<dt><i>count</i></dt> -<dd> -occurrences of the issue (integer) -</dd><dt><i>code</i></dt> -<dd> -of a PEP 8 message (string) -</dd><dt><i>message</i></dt> -<dd> -PEP 8 message to be shown (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/CodeStyleChecker.py Mon Sep 30 19:21:19 2013 +0200 @@ -0,0 +1,128 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing the PEP 8 checker. +""" + +import os + +from PyQt4.QtCore import QProcess, QCoreApplication + +from . import pep8 +from .Pep8NamingChecker import Pep8NamingChecker +from .DocStyleChecker import DocStyleChecker + +import Preferences +import Utilities + +from eric5config import getConfig + + +class CodeStyleCheckerPy2(object): + """ + Class implementing the PEP 8 checker interface for Python 2. + """ + def __init__(self, filename, lines, repeat=False, + select="", ignore="", max_line_length=79, + hang_closing=False, docType="pep257"): + """ + Constructor + + @param filename name of the file to check (string) + @param lines source of the file (list of strings) (ignored) + @keyparam repeat flag indicating to repeat message categories (boolean) + @keyparam select list of message IDs to check for + (comma separated string) + @keyparam ignore list of message IDs to ignore + (comma separated string) + @keyparam max_line_length maximum allowed line length (integer) + @keyparam hang_closing flag indicating to allow hanging closing + brackets (boolean) + @keyparam docType type of the documentation strings + (string, one of 'eric' or 'pep257') + """ + assert docType in ("eric", "pep257") + + self.errors = [] + self.counters = {} + + interpreter = Preferences.getDebugger("PythonInterpreter") + if interpreter == "" or not Utilities.isExecutable(interpreter): + self.errors.append((filename, 1, 1, + QCoreApplication.translate("CodeStyleCheckerPy2", + "Python2 interpreter not configured."))) + return + + checker = os.path.join(getConfig('ericDir'), + "UtilitiesPython2", "Pep8Checker.py") + + args = [checker] + if repeat: + args.append("-r") + if select: + args.append("-s") + args.append(select) + if ignore: + args.append("-i") + args.append(ignore) + args.append("-m") + args.append(str(max_line_length)) + if hang_closing: + args.append("-h") + args.append("-d") + args.append(docType) + args.append("-f") + args.append(filename) + + proc = QProcess() + proc.setProcessChannelMode(QProcess.MergedChannels) + proc.start(interpreter, args) + finished = proc.waitForFinished(15000) + if finished: + output = \ + str(proc.readAllStandardOutput(), + Preferences.getSystem("IOEncoding"), + 'replace').splitlines() + if output[0] == "ERROR": + self.errors.append((filename, 1, 1, output[2])) + return + + if output[0] == "NO_PEP8": + return + + index = 0 + while index < len(output): + if output[index] == "PEP8_STATISTICS": + index += 1 + break + + fname = output[index + 1] + lineno = int(output[index + 2]) + position = int(output[index + 3]) + code = output[index + 4] + arglen = int(output[index + 5]) + args = [] + argindex = 0 + while argindex < arglen: + args.append(output[index + 6 + argindex]) + argindex += 1 + index += 6 + arglen + + if code in Pep8NamingChecker.Codes: + text = Pep8NamingChecker.getMessage(code, *args) + elif code in DocStyleChecker.Codes: + text = DocStyleChecker.getMessage(code, *args) + else: + text = pep8.getMessage(code, *args) + self.errors.append((fname, lineno, position, text)) + while index < len(output): + code, countStr = output[index].split(None, 1) + self.counters[code] = int(countStr) + index += 1 + else: + self.errors.append((filename, 1, 1, + QCoreApplication.translate("CodeStyleCheckerPy2", + "Python2 interpreter did not finish within 15s.")))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/CheckerPlugins/Pep8/CodeStyleCodeSelectionDialog.py Mon Sep 30 19:21:19 2013 +0200 @@ -0,0 +1,90 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing a dialog to select PEP 8 message codes. +""" + +from PyQt4.QtCore import QCoreApplication +from PyQt4.QtGui import QDialog, QTreeWidgetItem + +from . import pep8 +from .Pep8NamingChecker import Pep8NamingChecker +from .DocStyleChecker import DocStyleChecker + +from .Ui_CodeStyleCodeSelectionDialog import Ui_CodeStyleCodeSelectionDialog + +import UI.PixmapCache + + +class CodeStyleCodeSelectionDialog(QDialog, Ui_CodeStyleCodeSelectionDialog): + """ + Class implementing a dialog to select PEP 8 message codes. + """ + def __init__(self, codes, showFixCodes, parent=None): + """ + Constructor + + @param codes comma separated list of selected codes (string) + @param showFixCodes flag indicating to show a list of fixable + issues (boolean) + @param parent reference to the parent widget (QWidget) + """ + super().__init__(parent) + self.setupUi(self) + + codeList = [code.strip() for code in codes.split(",") if code.strip()] + + if showFixCodes: + from .Pep8Fixer import Pep8FixableIssues + selectableCodes = Pep8FixableIssues + else: + selectableCodes = list(pep8.pep8_messages.keys()) + selectableCodes.extend(Pep8NamingChecker.Messages.keys()) + selectableCodes.extend(DocStyleChecker.Messages.keys()) + for code in sorted(selectableCodes): + if code in pep8.pep8_messages_sample_args: + message = QCoreApplication.translate( + "pep8", pep8.pep8_messages[code]).format( + *pep8.pep8_messages_sample_args[code]) + elif code in pep8.pep8_messages: + message = QCoreApplication.translate( + "pep8", pep8.pep8_messages[code]) + elif code in Pep8NamingChecker.Messages: + message = QCoreApplication.translate( + "Pep8NamingChecker", + Pep8NamingChecker.Messages[code]) + elif code in DocStyleChecker.Messages: + message = QCoreApplication.translate( + "DocStyleChecker", DocStyleChecker.Messages[code]) + else: + continue + itm = QTreeWidgetItem(self.codeTable, [code, message]) + if code.startswith("W"): + itm.setIcon(0, UI.PixmapCache.getIcon("warning.png")) + elif code.startswith("E"): + itm.setIcon(0, UI.PixmapCache.getIcon("syntaxError.png")) + elif code.startswith("N"): + itm.setIcon(0, UI.PixmapCache.getIcon("namingError.png")) + elif code.startswith("D"): + itm.setIcon(0, UI.PixmapCache.getIcon("docstringError.png")) + if code in codeList: + itm.setSelected(True) + codeList.remove(code) + + self.__extraCodes = codeList[:] + + def getSelectedCodes(self): + """ + Public method to get a comma separated list of codes selected. + + @return comma separated list of selected codes (string) + """ + selectedCodes = [] + + for itm in self.codeTable.selectedItems(): + selectedCodes.append(itm.text(0)) + + return ", ".join(self.__extraCodes + selectedCodes)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/CheckerPlugins/Pep8/CodeStyleCodeSelectionDialog.ui Mon Sep 30 19:21:19 2013 +0200 @@ -0,0 +1,116 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CodeStyleCodeSelectionDialog</class> + <widget class="QDialog" name="CodeStyleCodeSelectionDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>450</width> + <height>350</height> + </rect> + </property> + <property name="windowTitle"> + <string>Code Style Message Codes</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Select the message codes from the list:</string> + </property> + </widget> + </item> + <item> + <widget class="QTreeWidget" name="codeTable"> + <property name="toolTip"> + <string>Select the message codes from this table</string> + </property> + <property name="editTriggers"> + <set>QAbstractItemView::NoEditTriggers</set> + </property> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="selectionMode"> + <enum>QAbstractItemView::ExtendedSelection</enum> + </property> + <property name="selectionBehavior"> + <enum>QAbstractItemView::SelectRows</enum> + </property> + <property name="rootIsDecorated"> + <bool>false</bool> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <column> + <property name="text"> + <string>Code</string> + </property> + </column> + <column> + <property name="text"> + <string>Message</string> + </property> + </column> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <tabstops> + <tabstop>codeTable</tabstop> + <tabstop>buttonBox</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>CodeStyleCodeSelectionDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>227</x> + <y>279</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>CodeStyleCodeSelectionDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>295</x> + <y>285</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/CheckerPlugins/Pep8/CodeStyleStatisticsDialog.py Mon Sep 30 19:21:19 2013 +0200 @@ -0,0 +1,101 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing a dialog showing statistical data for the last code +style checker run. +""" + +from PyQt4.QtCore import Qt, QCoreApplication +from PyQt4.QtGui import QDialog, QTreeWidgetItem + +from . import pep8 +from .Pep8NamingChecker import Pep8NamingChecker +from .DocStyleChecker import DocStyleChecker + +from .Ui_CodeStyleStatisticsDialog import Ui_CodeStyleStatisticsDialog + +import UI.PixmapCache + + +class CodeStyleStatisticsDialog(QDialog, Ui_CodeStyleStatisticsDialog): + """ + Class implementing a dialog showing statistical data for the last + code style checker run. + """ + def __init__(self, statistics, parent=None): + """ + Constructor + + @param statistics dictionary with the statistical data + @param parent reference to the parent widget (QWidget) + """ + super().__init__(parent) + self.setupUi(self) + + stats = statistics.copy() + filesCount = stats["_FilesCount"] + filesIssues = stats["_FilesIssues"] + fixesCount = stats["_IssuesFixed"] + del stats["_FilesCount"] + del stats["_FilesIssues"] + del stats["_IssuesFixed"] + + totalIssues = 0 + + for code in sorted(stats.keys()): + if code in pep8.pep8_messages_sample_args: + message = QCoreApplication.translate( + "pep8", pep8.pep8_messages[code]).format( + *pep8.pep8_messages_sample_args[code]) + elif code in pep8.pep8_messages: + message = QCoreApplication.translate( + "pep8", pep8.pep8_messages[code]) + elif code in Pep8NamingChecker.Messages: + message = QCoreApplication.translate( + "Pep8NamingChecker", Pep8NamingChecker.Messages[code]) + elif code in DocStyleChecker.Messages: + message = QCoreApplication.translate( + "DocStyleChecker", DocStyleChecker.Messages[code]) + else: + continue + self.__createItem(stats[code], code, message) + totalIssues += stats[code] + + self.totalIssues.setText( + self.trUtf8("%n issue(s) found", "", totalIssues)) + self.fixedIssues.setText( + self.trUtf8("%n issue(s) fixed", "", fixesCount)) + self.filesChecked.setText( + self.trUtf8("%n file(s) checked", "", filesCount)) + self.filesIssues.setText( + self.trUtf8("%n file(s) with issues found", "", filesIssues)) + + self.statisticsList.resizeColumnToContents(0) + self.statisticsList.resizeColumnToContents(1) + + def __createItem(self, count, code, message): + """ + Private method to create an entry in the result list. + + @param count occurrences of the issue (integer) + @param code of a PEP 8 message (string) + @param message PEP 8 message to be shown (string) + """ + itm = QTreeWidgetItem(self.statisticsList) + itm.setData(0, Qt.DisplayRole, count) + itm.setData(1, Qt.DisplayRole, code) + itm.setData(2, Qt.DisplayRole, message) + if code.startswith("W"): + itm.setIcon(1, UI.PixmapCache.getIcon("warning.png")) + elif code.startswith("E"): + itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError.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")) + + itm.setTextAlignment(0, Qt.AlignRight) + itm.setTextAlignment(1, Qt.AlignHCenter)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/CheckerPlugins/Pep8/CodeStyleStatisticsDialog.ui Mon Sep 30 19:21:19 2013 +0200 @@ -0,0 +1,128 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CodeStyleStatisticsDialog</class> + <widget class="QDialog" name="CodeStyleStatisticsDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>531</width> + <height>372</height> + </rect> + </property> + <property name="windowTitle"> + <string>Code Style Checker Statistics</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTreeWidget" name="statisticsList"> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="rootIsDecorated"> + <bool>false</bool> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <column> + <property name="text"> + <string>Count</string> + </property> + </column> + <column> + <property name="text"> + <string>Code</string> + </property> + </column> + <column> + <property name="text"> + <string>Message</string> + </property> + </column> + </widget> + </item> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="filesChecked"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="filesIssues"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="totalIssues"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="fixedIssues"> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Close</set> + </property> + </widget> + </item> + </layout> + </widget> + <tabstops> + <tabstop>statisticsList</tabstop> + <tabstop>buttonBox</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>CodeStyleStatisticsDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>CodeStyleStatisticsDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui>
--- a/Plugins/CheckerPlugins/Pep8/Pep8Checker.py Mon Sep 30 19:06:37 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing the PEP 8 checker. -""" - -import os - -from PyQt4.QtCore import QProcess, QCoreApplication - -from . import pep8 -from .Pep8NamingChecker import Pep8NamingChecker -from .DocStyleChecker import DocStyleChecker - -import Preferences -import Utilities - -from eric5config import getConfig - - -class Pep8Py2Checker(object): - """ - Class implementing the PEP 8 checker interface for Python 2. - """ - def __init__(self, filename, lines, repeat=False, - select="", ignore="", max_line_length=79, - hang_closing=False, docType="pep257"): - """ - Constructor - - @param filename name of the file to check (string) - @param lines source of the file (list of strings) (ignored) - @keyparam repeat flag indicating to repeat message categories (boolean) - @keyparam select list of message IDs to check for - (comma separated string) - @keyparam ignore list of message IDs to ignore - (comma separated string) - @keyparam max_line_length maximum allowed line length (integer) - @keyparam hang_closing flag indicating to allow hanging closing - brackets (boolean) - @keyparam docType type of the documentation strings - (string, one of 'eric' or 'pep257') - """ - assert docType in ("eric", "pep257") - - self.errors = [] - self.counters = {} - - interpreter = Preferences.getDebugger("PythonInterpreter") - if interpreter == "" or not Utilities.isExecutable(interpreter): - self.errors.append((filename, 1, 1, - QCoreApplication.translate("Pep8Py2Checker", - "Python2 interpreter not configured."))) - return - - checker = os.path.join(getConfig('ericDir'), - "UtilitiesPython2", "Pep8Checker.py") - - args = [checker] - if repeat: - args.append("-r") - if select: - args.append("-s") - args.append(select) - if ignore: - args.append("-i") - args.append(ignore) - args.append("-m") - args.append(str(max_line_length)) - if hang_closing: - args.append("-h") - args.append("-d") - args.append(docType) - args.append("-f") - args.append(filename) - - proc = QProcess() - proc.setProcessChannelMode(QProcess.MergedChannels) - proc.start(interpreter, args) - finished = proc.waitForFinished(15000) - if finished: - output = \ - str(proc.readAllStandardOutput(), - Preferences.getSystem("IOEncoding"), - 'replace').splitlines() - if output[0] == "ERROR": - self.errors.append((filename, 1, 1, output[2])) - return - - if output[0] == "NO_PEP8": - return - - index = 0 - while index < len(output): - if output[index] == "PEP8_STATISTICS": - index += 1 - break - - fname = output[index + 1] - lineno = int(output[index + 2]) - position = int(output[index + 3]) - code = output[index + 4] - arglen = int(output[index + 5]) - args = [] - argindex = 0 - while argindex < arglen: - args.append(output[index + 6 + argindex]) - argindex += 1 - index += 6 + arglen - - if code in Pep8NamingChecker.Codes: - text = Pep8NamingChecker.getMessage(code, *args) - elif code in DocStyleChecker.Codes: - text = DocStyleChecker.getMessage(code, *args) - else: - text = pep8.getMessage(code, *args) - self.errors.append((fname, lineno, position, text)) - while index < len(output): - code, countStr = output[index].split(None, 1) - self.counters[code] = int(countStr) - index += 1 - else: - self.errors.append((filename, 1, 1, - QCoreApplication.translate("Pep8Py2Checker", - "Python2 interpreter did not finish within 15s.")))
--- a/Plugins/CheckerPlugins/Pep8/Pep8CodeSelectionDialog.py Mon Sep 30 19:06:37 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a dialog to select PEP 8 message codes. -""" - -from PyQt4.QtCore import QCoreApplication -from PyQt4.QtGui import QDialog, QTreeWidgetItem - -from . import pep8 -from .Pep8NamingChecker import Pep8NamingChecker -from .DocStyleChecker import DocStyleChecker - -from .Ui_Pep8CodeSelectionDialog import Ui_Pep8CodeSelectionDialog - -import UI.PixmapCache - - -class Pep8CodeSelectionDialog(QDialog, Ui_Pep8CodeSelectionDialog): - """ - Class implementing a dialog to select PEP 8 message codes. - """ - def __init__(self, codes, showFixCodes, parent=None): - """ - Constructor - - @param codes comma separated list of selected codes (string) - @param showFixCodes flag indicating to show a list of fixable - issues (boolean) - @param parent reference to the parent widget (QWidget) - """ - super().__init__(parent) - self.setupUi(self) - - codeList = [code.strip() for code in codes.split(",") if code.strip()] - - if showFixCodes: - from .Pep8Fixer import Pep8FixableIssues - selectableCodes = Pep8FixableIssues - else: - selectableCodes = list(pep8.pep8_messages.keys()) - selectableCodes.extend(Pep8NamingChecker.Messages.keys()) - selectableCodes.extend(DocStyleChecker.Messages.keys()) - for code in sorted(selectableCodes): - if code in pep8.pep8_messages_sample_args: - message = QCoreApplication.translate( - "pep8", pep8.pep8_messages[code]).format( - *pep8.pep8_messages_sample_args[code]) - elif code in pep8.pep8_messages: - message = QCoreApplication.translate( - "pep8", pep8.pep8_messages[code]) - elif code in Pep8NamingChecker.Messages: - message = QCoreApplication.translate( - "Pep8NamingChecker", - Pep8NamingChecker.Messages[code]) - elif code in DocStyleChecker.Messages: - message = QCoreApplication.translate( - "DocStyleChecker", DocStyleChecker.Messages[code]) - else: - continue - itm = QTreeWidgetItem(self.codeTable, [code, message]) - if code.startswith("W"): - itm.setIcon(0, UI.PixmapCache.getIcon("warning.png")) - elif code.startswith("E"): - itm.setIcon(0, UI.PixmapCache.getIcon("syntaxError.png")) - elif code.startswith("N"): - itm.setIcon(0, UI.PixmapCache.getIcon("namingError.png")) - elif code.startswith("D"): - itm.setIcon(0, UI.PixmapCache.getIcon("docstringError.png")) - if code in codeList: - itm.setSelected(True) - codeList.remove(code) - - self.__extraCodes = codeList[:] - - def getSelectedCodes(self): - """ - Public method to get a comma separated list of codes selected. - - @return comma separated list of selected codes (string) - """ - selectedCodes = [] - - for itm in self.codeTable.selectedItems(): - selectedCodes.append(itm.text(0)) - - return ", ".join(self.__extraCodes + selectedCodes)
--- a/Plugins/CheckerPlugins/Pep8/Pep8CodeSelectionDialog.ui Mon Sep 30 19:06:37 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Pep8CodeSelectionDialog</class> - <widget class="QDialog" name="Pep8CodeSelectionDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>450</width> - <height>350</height> - </rect> - </property> - <property name="windowTitle"> - <string>Code Style Message Codes</string> - </property> - <property name="sizeGripEnabled"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Select the message codes from the list:</string> - </property> - </widget> - </item> - <item> - <widget class="QTreeWidget" name="codeTable"> - <property name="toolTip"> - <string>Select the message codes from this table</string> - </property> - <property name="editTriggers"> - <set>QAbstractItemView::NoEditTriggers</set> - </property> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> - </property> - <property name="selectionBehavior"> - <enum>QAbstractItemView::SelectRows</enum> - </property> - <property name="rootIsDecorated"> - <bool>false</bool> - </property> - <property name="allColumnsShowFocus"> - <bool>true</bool> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - <column> - <property name="text"> - <string>Code</string> - </property> - </column> - <column> - <property name="text"> - <string>Message</string> - </property> - </column> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <tabstops> - <tabstop>codeTable</tabstop> - <tabstop>buttonBox</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>Pep8CodeSelectionDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>227</x> - <y>279</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>Pep8CodeSelectionDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>295</x> - <y>285</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui>
--- a/Plugins/CheckerPlugins/Pep8/Pep8Dialog.py Mon Sep 30 19:06:37 2013 +0200 +++ b/Plugins/CheckerPlugins/Pep8/Pep8Dialog.py Mon Sep 30 19:21:19 2013 +0200 @@ -420,8 +420,8 @@ self.__project.isProjectFile(file) and \ self.__project.getProjectLanguage() in ["Python", "Python2"]): - from .Pep8Checker import Pep8Py2Checker - report = Pep8Py2Checker(file, [], + from .CodeStyleChecker import CodeStyleCheckerPy2 + report = CodeStyleCheckerPy2(file, [], repeat=repeatMessages, select=includeMessages, ignore=excludeMessages, @@ -581,8 +581,8 @@ @param showFixCodes flag indicating to show a list of fixable issues (boolean) """ - from .Pep8CodeSelectionDialog import Pep8CodeSelectionDialog - dlg = Pep8CodeSelectionDialog(edit.text(), showFixCodes, self) + from .CodeStyleCodeSelectionDialog import CodeStyleCodeSelectionDialog + dlg = CodeStyleCodeSelectionDialog(edit.text(), showFixCodes, self) if dlg.exec_() == QDialog.Accepted: edit.setText(dlg.getSelectedCodes()) @@ -696,8 +696,8 @@ """ Private slot to show the statistics dialog. """ - from .Pep8StatisticsDialog import Pep8StatisticsDialog - dlg = Pep8StatisticsDialog(self.__statistics, self) + from .CodeStyleStatisticsDialog import CodeStyleStatisticsDialog + dlg = CodeStyleStatisticsDialog(self.__statistics, self) dlg.exec_() @pyqtSlot()
--- a/Plugins/CheckerPlugins/Pep8/Pep8StatisticsDialog.py Mon Sep 30 19:06:37 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a dialog showing statistical data for the last code -style checker run. -""" - -from PyQt4.QtCore import Qt, QCoreApplication -from PyQt4.QtGui import QDialog, QTreeWidgetItem - -from . import pep8 -from .Pep8NamingChecker import Pep8NamingChecker -from .DocStyleChecker import DocStyleChecker - -from .Ui_Pep8StatisticsDialog import Ui_Pep8StatisticsDialog - -import UI.PixmapCache - - -class Pep8StatisticsDialog(QDialog, Ui_Pep8StatisticsDialog): - """ - Class implementing a dialog showing statistical data for the last - code style checker run. - """ - def __init__(self, statistics, parent=None): - """ - Constructor - - @param statistics dictionary with the statistical data - @param parent reference to the parent widget (QWidget) - """ - super().__init__(parent) - self.setupUi(self) - - stats = statistics.copy() - filesCount = stats["_FilesCount"] - filesIssues = stats["_FilesIssues"] - fixesCount = stats["_IssuesFixed"] - del stats["_FilesCount"] - del stats["_FilesIssues"] - del stats["_IssuesFixed"] - - totalIssues = 0 - - for code in sorted(stats.keys()): - if code in pep8.pep8_messages_sample_args: - message = QCoreApplication.translate( - "pep8", pep8.pep8_messages[code]).format( - *pep8.pep8_messages_sample_args[code]) - elif code in pep8.pep8_messages: - message = QCoreApplication.translate( - "pep8", pep8.pep8_messages[code]) - elif code in Pep8NamingChecker.Messages: - message = QCoreApplication.translate( - "Pep8NamingChecker", Pep8NamingChecker.Messages[code]) - elif code in DocStyleChecker.Messages: - message = QCoreApplication.translate( - "DocStyleChecker", DocStyleChecker.Messages[code]) - else: - continue - self.__createItem(stats[code], code, message) - totalIssues += stats[code] - - self.totalIssues.setText( - self.trUtf8("%n issue(s) found", "", totalIssues)) - self.fixedIssues.setText( - self.trUtf8("%n issue(s) fixed", "", fixesCount)) - self.filesChecked.setText( - self.trUtf8("%n file(s) checked", "", filesCount)) - self.filesIssues.setText( - self.trUtf8("%n file(s) with issues found", "", filesIssues)) - - self.statisticsList.resizeColumnToContents(0) - self.statisticsList.resizeColumnToContents(1) - - def __createItem(self, count, code, message): - """ - Private method to create an entry in the result list. - - @param count occurrences of the issue (integer) - @param code of a PEP 8 message (string) - @param message PEP 8 message to be shown (string) - """ - itm = QTreeWidgetItem(self.statisticsList) - itm.setData(0, Qt.DisplayRole, count) - itm.setData(1, Qt.DisplayRole, code) - itm.setData(2, Qt.DisplayRole, message) - if code.startswith("W"): - itm.setIcon(1, UI.PixmapCache.getIcon("warning.png")) - elif code.startswith("E"): - itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError.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")) - - itm.setTextAlignment(0, Qt.AlignRight) - itm.setTextAlignment(1, Qt.AlignHCenter)
--- a/Plugins/CheckerPlugins/Pep8/Pep8StatisticsDialog.ui Mon Sep 30 19:06:37 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Pep8StatisticsDialog</class> - <widget class="QDialog" name="Pep8StatisticsDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>531</width> - <height>372</height> - </rect> - </property> - <property name="windowTitle"> - <string>Code Styel Checker Statistics</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QTreeWidget" name="statisticsList"> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="rootIsDecorated"> - <bool>false</bool> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - <column> - <property name="text"> - <string>Count</string> - </property> - </column> - <column> - <property name="text"> - <string>Code</string> - </property> - </column> - <column> - <property name="text"> - <string>Message</string> - </property> - </column> - </widget> - </item> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="filesChecked"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="filesIssues"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="totalIssues"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="fixedIssues"> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Close</set> - </property> - </widget> - </item> - </layout> - </widget> - <tabstops> - <tabstop>statisticsList</tabstop> - <tabstop>buttonBox</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>Pep8StatisticsDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>Pep8StatisticsDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui>
--- a/eric5.e4p Mon Sep 30 19:06:37 2013 +0200 +++ b/eric5.e4p Mon Sep 30 19:21:19 2013 +0200 @@ -1110,6 +1110,9 @@ <Source>UtilitiesPython2/Pep8NamingCheckerPy2.py</Source> <Source>UtilitiesPython2/Pep257CheckerPy2.py</Source> <Source>Plugins/CheckerPlugins/Pep8/DocStyleChecker.py</Source> + <Source>Plugins/CheckerPlugins/Pep8/CodeStyleChecker.py</Source> + <Source>Plugins/CheckerPlugins/Pep8/CodeStyleStatisticsDialog.py</Source> + <Source>Plugins/CheckerPlugins/Pep8/CodeStyleCodeSelectionDialog.py</Source> </Sources> <Forms> <Form>PyUnit/UnittestDialog.ui</Form> @@ -1338,8 +1341,6 @@ <Form>Helpviewer/Download/DownloadManager.ui</Form> <Form>Preferences/ConfigurationPages/TrayStarterPage.ui</Form> <Form>Plugins/CheckerPlugins/Pep8/Pep8Dialog.ui</Form> - <Form>Plugins/CheckerPlugins/Pep8/Pep8CodeSelectionDialog.ui</Form> - <Form>Plugins/CheckerPlugins/Pep8/Pep8StatisticsDialog.ui</Form> <Form>Preferences/ConfigurationPages/HelpVirusTotalPage.ui</Form> <Form>Helpviewer/Download/DownloadAskActionDialog.ui</Form> <Form>Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/HgBookmarksListDialog.ui</Form> @@ -1430,6 +1431,8 @@ <Form>Plugins/VcsPlugins/vcsMercurial/ConfigurationPage/MercurialUserDataDialog.ui</Form> <Form>Plugins/VcsPlugins/vcsMercurial/HgSummaryDialog.ui</Form> <Form>Plugins/VcsPlugins/vcsMercurial/HgArchiveDialog.ui</Form> + <Form>Plugins/CheckerPlugins/Pep8/CodeStyleStatisticsDialog.ui</Form> + <Form>Plugins/CheckerPlugins/Pep8/CodeStyleCodeSelectionDialog.ui</Form> </Forms> <Translations> <Translation>i18n/eric5_cs.ts</Translation>