Sat, 31 Aug 2013 17:57:30 +0200
Added a button to the PEP-8 dialog to reset the default values.
--- a/APIs/Python3/eric5.api Sat Aug 31 15:21:28 2013 +0200 +++ b/APIs/Python3/eric5.api Sat Aug 31 17:57:30 2013 +0200 @@ -3731,6 +3731,7 @@ eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.Pep8Dialog.on_includeMessagesSelectButton_clicked?4() eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.Pep8Dialog.on_loadDefaultButton_clicked?4() eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.Pep8Dialog.on_noFixIssuesSelectButton_clicked?4() +eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.Pep8Dialog.on_resetDefaultButton_clicked?4() eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.Pep8Dialog.on_resultList_itemActivated?4(item, column) eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.Pep8Dialog.on_resultList_itemSelectionChanged?4() eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.Pep8Dialog.on_showButton_clicked?4() @@ -3745,6 +3746,7 @@ eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.Pep8Report?1(options) eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.Pep8FixableIssues?7 eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.Pep8Fixer.fixIssue?4(line, pos, message) +eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.Pep8Fixer.mutualStartswith?4(b) eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.Pep8Fixer.saveFile?4(encoding) eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.Pep8Fixer?1(project, filename, sourceLines, fixCodes, noFixCodes, maxLineLength, inPlace) eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.Pep8IndentationWrapper.SKIP_TOKENS?7
--- a/Documentation/Help/source.qhp Sat Aug 31 15:21:28 2013 +0200 +++ b/Documentation/Help/source.qhp Sat Aug 31 17:57:30 2013 +0200 @@ -7998,6 +7998,7 @@ <keyword name="Pep8Dialog.on_includeMessagesSelectButton_clicked" id="Pep8Dialog.on_includeMessagesSelectButton_clicked" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.html#Pep8Dialog.on_includeMessagesSelectButton_clicked" /> <keyword name="Pep8Dialog.on_loadDefaultButton_clicked" id="Pep8Dialog.on_loadDefaultButton_clicked" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.html#Pep8Dialog.on_loadDefaultButton_clicked" /> <keyword name="Pep8Dialog.on_noFixIssuesSelectButton_clicked" id="Pep8Dialog.on_noFixIssuesSelectButton_clicked" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.html#Pep8Dialog.on_noFixIssuesSelectButton_clicked" /> + <keyword name="Pep8Dialog.on_resetDefaultButton_clicked" id="Pep8Dialog.on_resetDefaultButton_clicked" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.html#Pep8Dialog.on_resetDefaultButton_clicked" /> <keyword name="Pep8Dialog.on_resultList_itemActivated" id="Pep8Dialog.on_resultList_itemActivated" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.html#Pep8Dialog.on_resultList_itemActivated" /> <keyword name="Pep8Dialog.on_resultList_itemSelectionChanged" id="Pep8Dialog.on_resultList_itemSelectionChanged" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.html#Pep8Dialog.on_resultList_itemSelectionChanged" /> <keyword name="Pep8Dialog.on_showButton_clicked" id="Pep8Dialog.on_showButton_clicked" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.html#Pep8Dialog.on_showButton_clicked" /> @@ -8009,6 +8010,7 @@ <keyword name="Pep8Fixer" id="Pep8Fixer" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer" /> <keyword name="Pep8Fixer (Constructor)" id="Pep8Fixer (Constructor)" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__init__" /> <keyword name="Pep8Fixer (Module)" id="Pep8Fixer (Module)" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html" /> + <keyword name="Pep8Fixer.__codeMatch" id="Pep8Fixer.__codeMatch" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__codeMatch" /> <keyword name="Pep8Fixer.__finalize" id="Pep8Fixer.__finalize" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__finalize" /> <keyword name="Pep8Fixer.__findLogical" id="Pep8Fixer.__findLogical" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__findLogical" /> <keyword name="Pep8Fixer.__fixE101" id="Pep8Fixer.__fixE101" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__fixE101" /> @@ -8043,6 +8045,7 @@ <keyword name="Pep8Fixer.__getIndentWord" id="Pep8Fixer.__getIndentWord" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__getIndentWord" /> <keyword name="Pep8Fixer.__getLogical" id="Pep8Fixer.__getLogical" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__getLogical" /> <keyword name="Pep8Fixer.fixIssue" id="Pep8Fixer.fixIssue" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.fixIssue" /> + <keyword name="Pep8Fixer.mutualStartswith" id="Pep8Fixer.mutualStartswith" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.mutualStartswith" /> <keyword name="Pep8Fixer.saveFile" id="Pep8Fixer.saveFile" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.saveFile" /> <keyword name="Pep8IndentationWrapper" id="Pep8IndentationWrapper" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8IndentationWrapper" /> <keyword name="Pep8IndentationWrapper (Constructor)" id="Pep8IndentationWrapper (Constructor)" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8IndentationWrapper.__init__" />
--- a/Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.html Sat Aug 31 15:21:28 2013 +0200 +++ b/Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.Pep8Dialog.html Sat Aug 31 17:57:30 2013 +0200 @@ -117,6 +117,9 @@ <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>Slot documentation goes here.</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> @@ -320,6 +323,11 @@ <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> + Slot documentation goes here. </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>)
--- a/Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html Sat Aug 31 15:21:28 2013 +0200 +++ b/Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html Sat Aug 31 17:57:30 2013 +0200 @@ -66,6 +66,9 @@ <td><a href="#Pep8Fixer.__init__">Pep8Fixer</a></td> <td>Constructor</td> </tr><tr> +<td><a href="#Pep8Fixer.__codeMatch">__codeMatch</a></td> +<td>Private method to check, if the code should be fixed.</td> +</tr><tr> <td><a href="#Pep8Fixer.__finalize">__finalize</a></td> <td>Private method to apply all deferred fixes.</td> </tr><tr> @@ -168,6 +171,9 @@ <td><a href="#Pep8Fixer.fixIssue">fixIssue</a></td> <td>Public method to fix the fixable issues.</td> </tr><tr> +<td><a href="#Pep8Fixer.mutualStartswith">mutualStartswith</a></td> +<td>Local helper method to compare the beginnings of two strings against each other.</td> +</tr><tr> <td><a href="#Pep8Fixer.saveFile">saveFile</a></td> <td>Public method to save the modified file.</td> </tr> @@ -207,6 +213,21 @@ <dd> flag indicating to modify the file in place (boolean) </dd> +</dl><a NAME="Pep8Fixer.__codeMatch" ID="Pep8Fixer.__codeMatch"></a> +<h4>Pep8Fixer.__codeMatch</h4> +<b>__codeMatch</b>(<i>code</i>) +<p> + Private method to check, if the code should be fixed. +</p><dl> +<dt><i>code</i></dt> +<dd> +to check (string) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +flag indicating it should be fixed (boolean) +</dd> </dl><a NAME="Pep8Fixer.__finalize" ID="Pep8Fixer.__finalize"></a> <h4>Pep8Fixer.__finalize</h4> <b>__finalize</b>(<i></i>) @@ -956,6 +977,18 @@ flag indicating an applied fix (boolean) and a message for the fix (string) </dd> +</dl><a NAME="Pep8Fixer.mutualStartswith" ID="Pep8Fixer.mutualStartswith"></a> +<h4>Pep8Fixer.mutualStartswith</h4> +<b>mutualStartswith</b>(<i>b</i>) +<p> + Local helper method to compare the beginnings of two strings + against each other. +</p><dl> +<dt>Returns:</dt> +<dd> +flag indicating that one string starts with the other + (boolean) +</dd> </dl><a NAME="Pep8Fixer.saveFile" ID="Pep8Fixer.saveFile"></a> <h4>Pep8Fixer.saveFile</h4> <b>saveFile</b>(<i>encoding</i>)
--- a/Plugins/CheckerPlugins/Pep8/Pep8Dialog.py Sat Aug 31 15:21:28 2013 +0200 +++ b/Plugins/CheckerPlugins/Pep8/Pep8Dialog.py Sat Aug 31 17:57:30 2013 +0200 @@ -621,10 +621,12 @@ "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")) + "PEP8/NoFixCodes", "E501")) self.fixIssuesCheckBox.setChecked(Preferences.toBool( Preferences.Prefs.settings.value("PEP8/FixIssues"))) self.lineLengthSpinBox.setValue(int(Preferences.Prefs.settings.value( @@ -644,6 +646,8 @@ 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", @@ -655,6 +659,24 @@ Preferences.Prefs.settings.setValue("PEP8/HangClosing", self.hangClosingCheckBox.isChecked()) + @pyqtSlot() + def on_resetDefaultButton_clicked(self): + """ + Slot documentation goes here. + """ + raise NotImplementedError + 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) + @pyqtSlot(QAbstractButton) def on_buttonBox_clicked(self, button): """
--- a/Plugins/CheckerPlugins/Pep8/Pep8Dialog.ui Sat Aug 31 15:21:28 2013 +0200 +++ b/Plugins/CheckerPlugins/Pep8/Pep8Dialog.ui Sat Aug 31 17:57:30 2013 +0200 @@ -28,6 +28,9 @@ <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"> @@ -107,6 +110,16 @@ </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"> @@ -212,7 +225,7 @@ </property> </widget> </item> - <item row="5" column="1" colspan="2"> + <item row="5" column="1"> <layout class="QHBoxLayout" name="horizontalLayout_3"> <item> <widget class="QSpinBox" name="lineLengthSpinBox"> @@ -248,7 +261,7 @@ </item> </layout> </item> - <item row="6" column="0" colspan="3"> + <item row="6" column="0" colspan="2"> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> <widget class="QCheckBox" name="hangClosingCheckBox"> @@ -405,6 +418,7 @@ <tabstop>storeDefaultButton</tabstop> <tabstop>resultList</tabstop> <tabstop>fixButton</tabstop> + <tabstop>resetDefaultButton</tabstop> <tabstop>buttonBox</tabstop> </tabstops> <resources/>
--- a/Plugins/CheckerPlugins/Pep8/Pep8Fixer.py Sat Aug 31 15:21:28 2013 +0200 +++ b/Plugins/CheckerPlugins/Pep8/Pep8Fixer.py Sat Aug 31 17:57:30 2013 +0200 @@ -160,6 +160,36 @@ return True + def __codeMatch(self, code): + """ + Private method to check, if the code should be fixed. + + @param code to check (string) + @return flag indicating it should be fixed (boolean) + """ + def mutualStartswith(a, b): + """ + Local helper method to compare the beginnings of two strings + against each other. + + @return flag indicating that one string starts with the other + (boolean) + """ + return b.startswith(a) or a.startswith(b) + + if self.__noFixCodes: + for noFixCode in [c.strip() for c in self.__noFixCodes]: + if mutualStartswith(code.lower(), noFixCode.lower()): + return False + + if self.__fixCodes: + for fixCode in [c.strip() for c in self.__fixCodes]: + if mutualStartswith(code.lower(), fixCode.lower()): + return True + return False + + return True + def fixIssue(self, line, pos, message): """ Public method to fix the fixable issues. @@ -173,8 +203,7 @@ code = message.split(None, 1)[0].strip() if line <= len(self.__source) and \ - code not in self.__noFixCodes and \ - (code in self.__fixCodes or len(self.__fixCodes) == 0) and \ + self.__codeMatch(code) and \ code in self.__fixes: res = self.__fixes[code](code, line, pos) if res[0]: