Tue, 04 Jan 2011 17:37:48 +0100
Added a tabnanny checker function for Python 2 files.
--- a/APIs/Python3/eric5.api Mon Jan 03 17:45:11 2011 +0100 +++ b/APIs/Python3/eric5.api Tue Jan 04 17:37:48 2011 +0100 @@ -6247,11 +6247,27 @@ eric5.Utilities.win32_GetUserName?4() eric5.Utilities.win32_Kill?4(pid) eric5.Utilities.writeEncodedFile?4(filename, text, orig_coding) -eric5.UtilitiesPython2.Py2SyntaxChecker.coding_regexps?7 -eric5.UtilitiesPython2.Py2SyntaxChecker.compile?4(file) -eric5.UtilitiesPython2.Py2SyntaxChecker.decode?4(text) +eric5.UtilitiesPython2.Py2SyntaxChecker.compile?4(file, codestring) eric5.UtilitiesPython2.Py2SyntaxChecker.flakesCheck?4(fileName, codestring, ignoreStarImportWarnings) -eric5.UtilitiesPython2.Py2SyntaxChecker.get_coding?4(text) +eric5.UtilitiesPython2.Tabnanny.NannyNag.get_line?4() +eric5.UtilitiesPython2.Tabnanny.NannyNag.get_lineno?4() +eric5.UtilitiesPython2.Tabnanny.NannyNag.get_msg?4() +eric5.UtilitiesPython2.Tabnanny.NannyNag?1(lineno, msg, line) +eric5.UtilitiesPython2.Tabnanny.Whitespace.equal?4(other) +eric5.UtilitiesPython2.Tabnanny.Whitespace.indent_level?4(tabsize) +eric5.UtilitiesPython2.Tabnanny.Whitespace.less?4(other) +eric5.UtilitiesPython2.Tabnanny.Whitespace.longest_run_of_spaces?4() +eric5.UtilitiesPython2.Tabnanny.Whitespace.not_equal_witness?4(other) +eric5.UtilitiesPython2.Tabnanny.Whitespace.not_less_witness?4(other) +eric5.UtilitiesPython2.Tabnanny.Whitespace?1(ws) +eric5.UtilitiesPython2.Tabnanny.check?4(filename, codestring) +eric5.UtilitiesPython2.Tabnanny.format_witnesses?4(w) +eric5.UtilitiesPython2.Tabnanny.process_tokens?4(tokens) +eric5.UtilitiesPython2.Tools.coding_regexps?7 +eric5.UtilitiesPython2.Tools.decode?4(text) +eric5.UtilitiesPython2.Tools.get_coding?4(text) +eric5.UtilitiesPython2.Tools.normalizeCode?4(codestring) +eric5.UtilitiesPython2.Tools.readEncodedFile?4(filename) eric5.UtilitiesPython2.py2flakes.checker.Binding?1(name, source) eric5.UtilitiesPython2.py2flakes.checker.Checker.ASSIGN?4(node) eric5.UtilitiesPython2.py2flakes.checker.Checker.ASSLIST?7
--- a/Documentation/Help/source.qhp Mon Jan 03 17:45:11 2011 +0100 +++ b/Documentation/Help/source.qhp Tue Jan 04 17:37:48 2011 +0100 @@ -737,6 +737,9 @@ <section title="eric5.UtilitiesPython2.py2flakes.messages" ref="eric5.UtilitiesPython2.py2flakes.messages.html" /> </section> <section title="eric5.UtilitiesPython2.Py2SyntaxChecker" ref="eric5.UtilitiesPython2.Py2SyntaxChecker.html" /> + <section title="eric5.UtilitiesPython2.Tabnanny" ref="eric5.UtilitiesPython2.Tabnanny.html" /> + <section title="eric5.UtilitiesPython2.TabnannyChecker" ref="eric5.UtilitiesPython2.TabnannyChecker.html" /> + <section title="eric5.UtilitiesPython2.Tools" ref="eric5.UtilitiesPython2.Tools.html" /> </section> <section title="eric5.VCS" ref="index-eric5.VCS.html"> <section title="eric5.VCS.CommandOptionsDialog" ref="eric5.VCS.CommandOptionsDialog.html" /> @@ -3237,11 +3240,32 @@ <keyword name="CooperationClient.sendMessage" id="CooperationClient.sendMessage" ref="eric5.Cooperation.CooperationClient.html#CooperationClient.sendMessage" /> <keyword name="CooperationClient.server" id="CooperationClient.server" ref="eric5.Cooperation.CooperationClient.html#CooperationClient.server" /> <keyword name="UtilitiesPython2 (Package)" id="UtilitiesPython2 (Package)" ref="index-eric5.UtilitiesPython2.html" /> + <keyword name="Tools (Module)" id="Tools (Module)" ref="eric5.UtilitiesPython2.Tools.html" /> + <keyword name="decode" id="decode" ref="eric5.UtilitiesPython2.Tools.html#decode" /> + <keyword name="get_coding" id="get_coding" ref="eric5.UtilitiesPython2.Tools.html#get_coding" /> + <keyword name="normalizeCode" id="normalizeCode" ref="eric5.UtilitiesPython2.Tools.html#normalizeCode" /> + <keyword name="readEncodedFile" id="readEncodedFile" ref="eric5.UtilitiesPython2.Tools.html#readEncodedFile" /> + <keyword name="TabnannyChecker (Module)" id="TabnannyChecker (Module)" ref="eric5.UtilitiesPython2.TabnannyChecker.html" /> <keyword name="Py2SyntaxChecker (Module)" id="Py2SyntaxChecker (Module)" ref="eric5.UtilitiesPython2.Py2SyntaxChecker.html" /> <keyword name="compile" id="compile" ref="eric5.UtilitiesPython2.Py2SyntaxChecker.html#compile" /> - <keyword name="decode" id="decode" ref="eric5.UtilitiesPython2.Py2SyntaxChecker.html#decode" /> <keyword name="flakesCheck" id="flakesCheck" ref="eric5.UtilitiesPython2.Py2SyntaxChecker.html#flakesCheck" /> - <keyword name="get_coding" id="get_coding" ref="eric5.UtilitiesPython2.Py2SyntaxChecker.html#get_coding" /> + <keyword name="Tabnanny (Module)" id="Tabnanny (Module)" ref="eric5.UtilitiesPython2.Tabnanny.html" /> + <keyword name="NannyNag" id="NannyNag" ref="eric5.UtilitiesPython2.Tabnanny.html#NannyNag" /> + <keyword name="Whitespace" id="Whitespace" ref="eric5.UtilitiesPython2.Tabnanny.html#Whitespace" /> + <keyword name="check" id="check" ref="eric5.UtilitiesPython2.Tabnanny.html#check" /> + <keyword name="format_witnesses" id="format_witnesses" ref="eric5.UtilitiesPython2.Tabnanny.html#format_witnesses" /> + <keyword name="process_tokens" id="process_tokens" ref="eric5.UtilitiesPython2.Tabnanny.html#process_tokens" /> + <keyword name="NannyNag (Constructor)" id="NannyNag (Constructor)" ref="eric5.UtilitiesPython2.Tabnanny.html#NannyNag.__init__" /> + <keyword name="NannyNag.get_line" id="NannyNag.get_line" ref="eric5.UtilitiesPython2.Tabnanny.html#NannyNag.get_line" /> + <keyword name="NannyNag.get_lineno" id="NannyNag.get_lineno" ref="eric5.UtilitiesPython2.Tabnanny.html#NannyNag.get_lineno" /> + <keyword name="NannyNag.get_msg" id="NannyNag.get_msg" ref="eric5.UtilitiesPython2.Tabnanny.html#NannyNag.get_msg" /> + <keyword name="Whitespace (Constructor)" id="Whitespace (Constructor)" ref="eric5.UtilitiesPython2.Tabnanny.html#Whitespace.__init__" /> + <keyword name="Whitespace.equal" id="Whitespace.equal" ref="eric5.UtilitiesPython2.Tabnanny.html#Whitespace.equal" /> + <keyword name="Whitespace.indent_level" id="Whitespace.indent_level" ref="eric5.UtilitiesPython2.Tabnanny.html#Whitespace.indent_level" /> + <keyword name="Whitespace.less" id="Whitespace.less" ref="eric5.UtilitiesPython2.Tabnanny.html#Whitespace.less" /> + <keyword name="Whitespace.longest_run_of_spaces" id="Whitespace.longest_run_of_spaces" ref="eric5.UtilitiesPython2.Tabnanny.html#Whitespace.longest_run_of_spaces" /> + <keyword name="Whitespace.not_equal_witness" id="Whitespace.not_equal_witness" ref="eric5.UtilitiesPython2.Tabnanny.html#Whitespace.not_equal_witness" /> + <keyword name="Whitespace.not_less_witness" id="Whitespace.not_less_witness" ref="eric5.UtilitiesPython2.Tabnanny.html#Whitespace.not_less_witness" /> <keyword name="ViewManager (Package)" id="ViewManager (Package)" ref="index-eric5.ViewManager.html" /> <keyword name="factory" id="factory" ref="eric5.ViewManager.__init__.html#factory" /> <keyword name="ViewManager (Module)" id="ViewManager (Module)" ref="eric5.ViewManager.ViewManager.html" /> @@ -9221,6 +9245,7 @@ <keyword name="TabnannyDialog (Constructor)" id="TabnannyDialog (Constructor)" ref="eric5.Plugins.CheckerPlugins.Tabnanny.TabnannyDialog.html#TabnannyDialog.__init__" /> <keyword name="TabnannyDialog.__createResultItem" id="TabnannyDialog.__createResultItem" ref="eric5.Plugins.CheckerPlugins.Tabnanny.TabnannyDialog.html#TabnannyDialog.__createResultItem" /> <keyword name="TabnannyDialog.__finish" id="TabnannyDialog.__finish" ref="eric5.Plugins.CheckerPlugins.Tabnanny.TabnannyDialog.html#TabnannyDialog.__finish" /> + <keyword name="TabnannyDialog.__py2check" id="TabnannyDialog.__py2check" ref="eric5.Plugins.CheckerPlugins.Tabnanny.TabnannyDialog.html#TabnannyDialog.__py2check" /> <keyword name="TabnannyDialog.__resort" id="TabnannyDialog.__resort" ref="eric5.Plugins.CheckerPlugins.Tabnanny.TabnannyDialog.html#TabnannyDialog.__resort" /> <keyword name="TabnannyDialog.on_buttonBox_clicked" id="TabnannyDialog.on_buttonBox_clicked" ref="eric5.Plugins.CheckerPlugins.Tabnanny.TabnannyDialog.html#TabnannyDialog.on_buttonBox_clicked" /> <keyword name="TabnannyDialog.on_resultList_itemActivated" id="TabnannyDialog.on_resultList_itemActivated" ref="eric5.Plugins.CheckerPlugins.Tabnanny.TabnannyDialog.html#TabnannyDialog.on_resultList_itemActivated" /> @@ -10536,6 +10561,9 @@ <file>eric5.Utilities.py3flakes.messages.html</file> <file>eric5.Utilities.uic.html</file> <file>eric5.UtilitiesPython2.Py2SyntaxChecker.html</file> + <file>eric5.UtilitiesPython2.Tabnanny.html</file> + <file>eric5.UtilitiesPython2.TabnannyChecker.html</file> + <file>eric5.UtilitiesPython2.Tools.html</file> <file>eric5.UtilitiesPython2.py2flakes.checker.html</file> <file>eric5.UtilitiesPython2.py2flakes.messages.html</file> <file>eric5.VCS.CommandOptionsDialog.html</file>
--- a/Documentation/Source/eric5.Plugins.CheckerPlugins.Tabnanny.TabnannyDialog.html Mon Jan 03 17:45:11 2011 +0100 +++ b/Documentation/Source/eric5.Plugins.CheckerPlugins.Tabnanny.TabnannyDialog.html Tue Jan 04 17:37:48 2011 +0100 @@ -63,6 +63,9 @@ <td><a href="#TabnannyDialog.__finish">__finish</a></td> <td>Private slot called when the action or the user pressed the button.</td> </tr><tr> +<td><a href="#TabnannyDialog.__py2check">__py2check</a></td> +<td>Private method to perform the indentation check for Python 2 files.</td> +</tr><tr> <td><a href="#TabnannyDialog.__resort">__resort</a></td> <td>Private method to resort the tree.</td> </tr><tr> @@ -113,7 +116,25 @@ <b>__finish</b>(<i></i>) <p> Private slot called when the action or the user pressed the button. -</p><a NAME="TabnannyDialog.__resort" ID="TabnannyDialog.__resort"></a> +</p><a NAME="TabnannyDialog.__py2check" ID="TabnannyDialog.__py2check"></a> +<h4>TabnannyDialog.__py2check</h4> +<b>__py2check</b>(<i>filename</i>) +<p> + Private method to perform the indentation check for Python 2 files. +</p><dl> +<dt><i>filename</i></dt> +<dd> +name of the file to be checked (string) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +A tuple indicating status (True = an error was found), the + filename, the linenumber and the error message + (boolean, string, string, string). The values are only + valid, if the status is True. +</dd> +</dl><a NAME="TabnannyDialog.__resort" ID="TabnannyDialog.__resort"></a> <h4>TabnannyDialog.__resort</h4> <b>__resort</b>(<i></i>) <p>
--- a/Documentation/Source/eric5.UtilitiesPython2.Py2SyntaxChecker.html Mon Jan 03 17:45:11 2011 +0100 +++ b/Documentation/Source/eric5.UtilitiesPython2.Py2SyntaxChecker.html Tue Jan 04 17:37:48 2011 +0100 @@ -26,7 +26,7 @@ </p> <h3>Global Attributes</h3> <table> -<tr><td>coding_regexps</td></tr> +<tr><td>None</td></tr> </table> <h3>Classes</h3> <table> @@ -38,53 +38,31 @@ <td><a href="#compile">compile</a></td> <td>Function to compile one Python source file to Python bytecode.</td> </tr><tr> -<td><a href="#decode">decode</a></td> -<td>Function to decode a text.</td> -</tr><tr> <td><a href="#flakesCheck">flakesCheck</a></td> <td>Function to perform a pyflakes check.</td> -</tr><tr> -<td><a href="#get_coding">get_coding</a></td> -<td>Function to get the coding of a text.</td> </tr> </table> <hr /><hr /> <a NAME="compile" ID="compile"></a> <h2>compile</h2> -<b>compile</b>(<i>file</i>) +<b>compile</b>(<i>file, codestring</i>) <p> Function to compile one Python source file to Python bytecode. </p><dl> <dt><i>file</i></dt> <dd> source filename (string) +</dd><dt><i>codestring</i></dt> +<dd> +source code (string) </dd> </dl><dl> <dt>Returns:</dt> <dd> A tuple indicating status (1 = an error was found), the - filename, the linenumber, the code string, the error message - and the full source code (boolean, string, string, string, - string, string). The values are only valid, if the status - equals 1. -</dd> -</dl> -<div align="right"><a href="#top">Up</a></div> -<hr /><hr /> -<a NAME="decode" ID="decode"></a> -<h2>decode</h2> -<b>decode</b>(<i>text</i>) -<p> - Function to decode a text. -</p><dl> -<dt><i>text</i></dt> -<dd> -text to decode (string) -</dd> -</dl><dl> -<dt>Returns:</dt> -<dd> -decoded text and encoding + filename, the linenumber, the code string and the error message + (boolean, string, string, string, string). The values are only + valid, if the status equals 1. </dd> </dl> <div align="right"><a href="#top">Up</a></div> @@ -114,23 +92,5 @@ </dd> </dl> <div align="right"><a href="#top">Up</a></div> -<hr /><hr /> -<a NAME="get_coding" ID="get_coding"></a> -<h2>get_coding</h2> -<b>get_coding</b>(<i>text</i>) -<p> - Function to get the coding of a text. -</p><dl> -<dt><i>text</i></dt> -<dd> -text to inspect (string) -</dd> -</dl><dl> -<dt>Returns:</dt> -<dd> -coding 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/Documentation/Source/eric5.UtilitiesPython2.Tabnanny.html Tue Jan 04 17:37:48 2011 +0100 @@ -0,0 +1,348 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' +'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> +<html><head> +<title>eric5.UtilitiesPython2.Tabnanny</title> +<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.UtilitiesPython2.Tabnanny</h1> +<p> +The Tab Nanny despises ambiguous indentation. She knows no mercy. +</p><p> +tabnanny -- Detection of ambiguous indentation +</p><p> +For the time being this module is intended to be called as a script. +However it is possible to import it into an IDE and use the function +check() described below. +</p><p> +Warning: The API provided by this module is likely to change in future +releases; such changes may not be backward compatible. +</p><p> +This is a modified version to make the original tabnanny better suitable +for being called from within the eric5 IDE. +</p><dl> +<dt>Raises <b>ValueError</b>:</dt> +<dd> +The tokenize module is too old. +</dd> +</dl> +<h3>Global Attributes</h3> +<table> +<tr><td>__all__</td></tr><tr><td>__version__</td></tr> +</table> +<h3>Classes</h3> +<table> +<tr> +<td><a href="#NannyNag">NannyNag</a></td> +<td>Raised by tokeneater() if detecting an ambiguous indent.</td> +</tr><tr> +<td><a href="#Whitespace">Whitespace</a></td> +<td>Class implementing the whitespace checker.</td> +</tr> +</table> +<h3>Functions</h3> +<table> +<tr> +<td><a href="#check">check</a></td> +<td>Private function to check one Python source file for whitespace related problems.</td> +</tr><tr> +<td><a href="#format_witnesses">format_witnesses</a></td> +<td>Function to format the witnesses as a readable string.</td> +</tr><tr> +<td><a href="#process_tokens">process_tokens</a></td> +<td>Function processing all tokens generated by a tokenizer run.</td> +</tr> +</table> +<hr /><hr /> +<a NAME="NannyNag" ID="NannyNag"></a> +<h2>NannyNag</h2> +<p> + Raised by tokeneater() if detecting an ambiguous indent. + Captured and handled in check(). +</p> +<h3>Derived from</h3> +Exception +<h3>Class Attributes</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Methods</h3> +<table> +<tr> +<td><a href="#NannyNag.__init__">NannyNag</a></td> +<td>Constructor</td> +</tr><tr> +<td><a href="#NannyNag.get_line">get_line</a></td> +<td>Method to retrieve the offending line.</td> +</tr><tr> +<td><a href="#NannyNag.get_lineno">get_lineno</a></td> +<td>Method to retrieve the line number.</td> +</tr><tr> +<td><a href="#NannyNag.get_msg">get_msg</a></td> +<td>Method to retrieve the message.</td> +</tr> +</table> +<a NAME="NannyNag.__init__" ID="NannyNag.__init__"></a> +<h4>NannyNag (Constructor)</h4> +<b>NannyNag</b>(<i>lineno, msg, line</i>) +<p> + Constructor +</p><dl> +<dt><i>lineno</i></dt> +<dd> +Line number of the ambiguous indent. +</dd><dt><i>msg</i></dt> +<dd> +Descriptive message assigned to this problem. +</dd><dt><i>line</i></dt> +<dd> +The offending source line. +</dd> +</dl><a NAME="NannyNag.get_line" ID="NannyNag.get_line"></a> +<h4>NannyNag.get_line</h4> +<b>get_line</b>(<i></i>) +<p> + Method to retrieve the offending line. +</p><dl> +<dt>Returns:</dt> +<dd> +The line of code (string) +</dd> +</dl><a NAME="NannyNag.get_lineno" ID="NannyNag.get_lineno"></a> +<h4>NannyNag.get_lineno</h4> +<b>get_lineno</b>(<i></i>) +<p> + Method to retrieve the line number. +</p><dl> +<dt>Returns:</dt> +<dd> +The line number (integer) +</dd> +</dl><a NAME="NannyNag.get_msg" ID="NannyNag.get_msg"></a> +<h4>NannyNag.get_msg</h4> +<b>get_msg</b>(<i></i>) +<p> + Method to retrieve the message. +</p><dl> +<dt>Returns:</dt> +<dd> +The error message (string) +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> +<a NAME="Whitespace" ID="Whitespace"></a> +<h2>Whitespace</h2> +<p> + Class implementing the whitespace checker. +</p> +<h3>Derived from</h3> +object +<h3>Class Attributes</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Methods</h3> +<table> +<tr> +<td><a href="#Whitespace.__init__">Whitespace</a></td> +<td>Constructor</td> +</tr><tr> +<td><a href="#Whitespace.equal">equal</a></td> +<td>Method to compare the indentation levels of two Whitespace objects for equality.</td> +</tr><tr> +<td><a href="#Whitespace.indent_level">indent_level</a></td> +<td>Method to determine the indentation level.</td> +</tr><tr> +<td><a href="#Whitespace.less">less</a></td> +<td>Method to compare the indentation level against another Whitespace objects to be smaller.</td> +</tr><tr> +<td><a href="#Whitespace.longest_run_of_spaces">longest_run_of_spaces</a></td> +<td>Method to calculate the length of longest contiguous run of spaces.</td> +</tr><tr> +<td><a href="#Whitespace.not_equal_witness">not_equal_witness</a></td> +<td>Method to calculate a tuple of witnessing tab size.</td> +</tr><tr> +<td><a href="#Whitespace.not_less_witness">not_less_witness</a></td> +<td>Method to calculate a tuple of witnessing tab size.</td> +</tr> +</table> +<a NAME="Whitespace.__init__" ID="Whitespace.__init__"></a> +<h4>Whitespace (Constructor)</h4> +<b>Whitespace</b>(<i>ws</i>) +<p> + Constructor +</p><dl> +<dt><i>ws</i></dt> +<dd> +The string to be checked. +</dd> +</dl><a NAME="Whitespace.equal" ID="Whitespace.equal"></a> +<h4>Whitespace.equal</h4> +<b>equal</b>(<i>other</i>) +<p> + Method to compare the indentation levels of two Whitespace objects for equality. +</p><dl> +<dt><i>other</i></dt> +<dd> +Whitespace object to compare against. +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +True, if we compare equal against the other Whitespace object. +</dd> +</dl><a NAME="Whitespace.indent_level" ID="Whitespace.indent_level"></a> +<h4>Whitespace.indent_level</h4> +<b>indent_level</b>(<i>tabsize</i>) +<p> + Method to determine the indentation level. +</p><dl> +<dt><i>tabsize</i></dt> +<dd> +The length of a tab stop. (integer) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +indentation level (integer) +</dd> +</dl><a NAME="Whitespace.less" ID="Whitespace.less"></a> +<h4>Whitespace.less</h4> +<b>less</b>(<i>other</i>) +<p> + Method to compare the indentation level against another Whitespace objects to + be smaller. +</p><dl> +<dt><i>other</i></dt> +<dd> +Whitespace object to compare against. +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +True, if we compare less against the other Whitespace object. +</dd> +</dl><a NAME="Whitespace.longest_run_of_spaces" ID="Whitespace.longest_run_of_spaces"></a> +<h4>Whitespace.longest_run_of_spaces</h4> +<b>longest_run_of_spaces</b>(<i></i>) +<p> + Method to calculate the length of longest contiguous run of spaces. +</p><dl> +<dt>Returns:</dt> +<dd> +The length of longest contiguous run of spaces (whether or not + preceding a tab) +</dd> +</dl><a NAME="Whitespace.not_equal_witness" ID="Whitespace.not_equal_witness"></a> +<h4>Whitespace.not_equal_witness</h4> +<b>not_equal_witness</b>(<i>other</i>) +<p> + Method to calculate a tuple of witnessing tab size. +</p><p> + Intended to be used after not self.equal(other) is known, in which + case it will return at least one witnessing tab size. +</p><dl> +<dt><i>other</i></dt> +<dd> +Whitespace object to calculate against. +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +A list of tuples (ts, i1, i2) such that + i1 == self.indent_level(ts) != other.indent_level(ts) == i2. +</dd> +</dl><a NAME="Whitespace.not_less_witness" ID="Whitespace.not_less_witness"></a> +<h4>Whitespace.not_less_witness</h4> +<b>not_less_witness</b>(<i>other</i>) +<p> + Method to calculate a tuple of witnessing tab size. +</p><p> + Intended to be used after not self.less(other is known, in which + case it will return at least one witnessing tab size. +</p><dl> +<dt><i>other</i></dt> +<dd> +Whitespace object to calculate against. +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +A list of tuples (ts, i1, i2) such that + i1 == self.indent_level(ts) >= other.indent_level(ts) == i2. +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> +<a NAME="check" ID="check"></a> +<h2>check</h2> +<b>check</b>(<i>filename, codestring</i>) +<p> + Private function to check one Python source file for whitespace related problems. +</p><dl> +<dt><i>filename</i></dt> +<dd> +source filename (string) +</dd><dt><i>codestring</i></dt> +<dd> +source code (string) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +A tuple indicating status (True = an error was found), the + filename, the linenumber and the error message + (boolean, string, string, string). The values are only + valid, if the status is True. +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> +<a NAME="format_witnesses" ID="format_witnesses"></a> +<h2>format_witnesses</h2> +<b>format_witnesses</b>(<i>w</i>) +<p> + Function to format the witnesses as a readable string. +</p><dl> +<dt><i>w</i></dt> +<dd> +A list of witnesses +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +A formated string of the witnesses. +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> +<a NAME="process_tokens" ID="process_tokens"></a> +<h2>process_tokens</h2> +<b>process_tokens</b>(<i>tokens</i>) +<p> + Function processing all tokens generated by a tokenizer run. +</p><dl> +<dt><i>tokens</i></dt> +<dd> +list of tokens +</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/Documentation/Source/eric5.UtilitiesPython2.TabnannyChecker.html Tue Jan 04 17:37:48 2011 +0100 @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' +'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> +<html><head> +<title>eric5.UtilitiesPython2.TabnannyChecker</title> +<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.UtilitiesPython2.TabnannyChecker</h1> +<p> +Module implementing the indentation check for Python 2. +</p> +<h3>Global Attributes</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Classes</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Functions</h3> +<table> +<tr><td>None</td></tr> +</table> +<hr /> +</body></html> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Documentation/Source/eric5.UtilitiesPython2.Tools.html Tue Jan 04 17:37:48 2011 +0100 @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' +'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> +<html><head> +<title>eric5.UtilitiesPython2.Tools</title> +<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.UtilitiesPython2.Tools</h1> +<p> +Module implementing tool functions. +</p> +<h3>Global Attributes</h3> +<table> +<tr><td>coding_regexps</td></tr> +</table> +<h3>Classes</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Functions</h3> +<table> +<tr> +<td><a href="#decode">decode</a></td> +<td>Function to decode a text.</td> +</tr><tr> +<td><a href="#get_coding">get_coding</a></td> +<td>Function to get the coding of a text.</td> +</tr><tr> +<td><a href="#normalizeCode">normalizeCode</a></td> +<td>Function to normalize the given code.</td> +</tr><tr> +<td><a href="#readEncodedFile">readEncodedFile</a></td> +<td>Function to read a file and decode it's contents into proper text.</td> +</tr> +</table> +<hr /><hr /> +<a NAME="decode" ID="decode"></a> +<h2>decode</h2> +<b>decode</b>(<i>text</i>) +<p> + Function to decode a text. +</p><dl> +<dt><i>text</i></dt> +<dd> +text to decode (string) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +decoded text and encoding +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> +<a NAME="get_coding" ID="get_coding"></a> +<h2>get_coding</h2> +<b>get_coding</b>(<i>text</i>) +<p> + Function to get the coding of a text. +</p><dl> +<dt><i>text</i></dt> +<dd> +text to inspect (string) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +coding string +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> +<a NAME="normalizeCode" ID="normalizeCode"></a> +<h2>normalizeCode</h2> +<b>normalizeCode</b>(<i>codestring</i>) +<p> + Function to normalize the given code. +</p><dl> +<dt><i>codestring</i></dt> +<dd> +code to be normalized (string) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +normalized code (string) +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> +<a NAME="readEncodedFile" ID="readEncodedFile"></a> +<h2>readEncodedFile</h2> +<b>readEncodedFile</b>(<i>filename</i>) +<p> + Function to read a file and decode it's contents into proper text. +</p><dl> +<dt><i>filename</i></dt> +<dd> +name of the file to read (string) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +tuple of decoded text and encoding (string, string) +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /> +</body></html> \ No newline at end of file
--- a/Documentation/Source/index-eric5.UtilitiesPython2.html Mon Jan 03 17:45:11 2011 +0100 +++ b/Documentation/Source/index-eric5.UtilitiesPython2.html Tue Jan 04 17:37:48 2011 +0100 @@ -38,6 +38,15 @@ <tr> <td><a href="eric5.UtilitiesPython2.Py2SyntaxChecker.html">Py2SyntaxChecker</a></td> <td>Module implementing the syntax check for Python 2.</td> +</tr><tr> +<td><a href="eric5.UtilitiesPython2.Tabnanny.html">Tabnanny</a></td> +<td>The Tab Nanny despises ambiguous indentation.</td> +</tr><tr> +<td><a href="eric5.UtilitiesPython2.TabnannyChecker.html">TabnannyChecker</a></td> +<td>Module implementing the indentation check for Python 2.</td> +</tr><tr> +<td><a href="eric5.UtilitiesPython2.Tools.html">Tools</a></td> +<td>Module implementing tool functions.</td> </tr> </table> </body></html> \ No newline at end of file
--- a/Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py Mon Jan 03 17:45:11 2011 +0100 +++ b/Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py Tue Jan 04 17:37:48 2011 +0100 @@ -22,6 +22,8 @@ import Preferences import UI.PixmapCache +from eric5config import getConfig + class TabnannyDialog(QDialog, Ui_TabnannyDialog): """ Class implementing a dialog to show the results of the tabnanny check run. @@ -95,6 +97,9 @@ @param fn File or list of files or directory to be checked (string or list of strings) """ + 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) @@ -107,18 +112,22 @@ 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] files = [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(files) > 0: - self.checkProgress.setMaximum(len(files)) + if len(files) + len(py2files) > 0: + self.checkProgress.setMaximum(len(files) + len(py2files)) QApplication.processEvents() # now go through all the files progress = 0 - for file in files: + for file in files + py2files: self.checkProgress.setValue(progress) QApplication.processEvents() self.__resort() @@ -138,15 +147,21 @@ continue flags = Utilities.extractFlags(source) - if "FileType" in flags and flags["FileType"] != "Python3": - # skip non Python 3 files - progress += 1 - continue - - nok, fname, line, error = Tabnanny.check(file, source) + ext = os.path.splitext(file)[1] + 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"]): + nok, fname, line, error = self.__py2check(file) + else: + nok, fname, line, error = Tabnanny.check(file, source) if nok: self.noResults = False - self.__createResultItem(fname, line, error.rstrip()[1:-1]) + self.__createResultItem(fname, line, error.rstrip()) progress += 1 self.checkProgress.setValue(progress) @@ -220,3 +235,47 @@ lineno = int(itm.text(1)) e5App().getObject("ViewManager").openSourceFile(fn, lineno) + + ############################################################################ + ## Python 2 interface below + ############################################################################ + + def __py2check(self, filename): + """ + Private method to perform the indentation check for Python 2 files. + + @param filename name of the file to be checked (string) + @return A tuple indicating status (True = an error was found), the + filename, the linenumber and the error message + (boolean, string, string, string). The values are only + valid, if the status is True. + """ + interpreter = Preferences.getDebugger("PythonInterpreter") + if interpreter == "" or not Utilities.isExecutable(interpreter): + return (True, filename, "1", + self.trUtf8("Python2 interpreter not configured.")) + + checker = os.path.join(getConfig('ericDir'), + "UtilitiesPython2", "TabnannyChecker.py") + + proc = QProcess() + proc.setProcessChannelMode(QProcess.MergedChannels) + proc.start(interpreter, [checker, filename]) + finished = proc.waitForFinished(15000) + if finished: + output = \ + str(proc.readAllStandardOutput(), + Preferences.getSystem("IOEncoding"), + 'replace').splitlines() + + nok = output[0] == "ERROR" + if nok: + fn = output[1] + line = output[2] + error = output[3] + return (True, fn, line, error) + else: + return (False, None, None, None) + + return (True, filename, "1", + self.trUtf8("Python2 interpreter did not finish within 15s."))
--- a/Plugins/PluginTabnanny.py Mon Jan 03 17:45:11 2011 +0100 +++ b/Plugins/PluginTabnanny.py Tue Jan 04 17:37:48 2011 +0100 @@ -143,7 +143,8 @@ """ if menuName == "Checks" and self.__projectAct is not None: self.__projectAct.setEnabled( - e5App().getObject("Project").getProjectLanguage() == "Python3") + e5App().getObject("Project").getProjectLanguage() in \ + ["Python3", "Python2", "Python"]) def __projectBrowserShowMenu(self, menuName, menu): """ @@ -154,7 +155,8 @@ @param menu reference to the menu (QMenu) """ if menuName == "Checks" and \ - e5App().getObject("Project").getProjectLanguage() == "Python3": + e5App().getObject("Project").getProjectLanguage() in \ + ["Python3", "Python2", "Python"]: self.__projectBrowserMenu = menu if self.__projectBrowserAct is None: self.__projectBrowserAct = E5Action(self.trUtf8('Check Indentations'), @@ -179,7 +181,8 @@ ppath = project.getProjectPath() files = [os.path.join(ppath, file) \ for file in project.pdata["SOURCES"] \ - if file.endswith(tuple(Preferences.getPython("Python3Extensions")))] + if file.endswith(tuple(Preferences.getPython("Python3Extensions")) + + tuple(Preferences.getPython("PythonExtensions")))] self.__projectTabnannyDialog = TabnannyDialog() self.__projectTabnannyDialog.show() @@ -236,7 +239,7 @@ if menuName == "Checks": if not self.__editorAct in menu.actions(): menu.addAction(self.__editorAct) - self.__editorAct.setEnabled(editor.isPy3File()) + self.__editorAct.setEnabled(editor.isPy3File() or editor.isPy2File()) def __editorTabnanny(self): """
--- a/Tools/TRPreviewer.py Mon Jan 03 17:45:11 2011 +0100 +++ b/Tools/TRPreviewer.py Tue Jan 04 17:37:48 2011 +0100 @@ -853,4 +853,4 @@ @return flag signaling if any widget was loaded (boolean) """ - return len(self.widgets) > 0 \ No newline at end of file + return len(self.widgets) > 0
--- a/Utilities/__init__.py Mon Jan 03 17:45:11 2011 +0100 +++ b/Utilities/__init__.py Tue Jan 04 17:37:48 2011 +0100 @@ -1127,7 +1127,8 @@ if interpreter == "" or not isExecutable(interpreter): return (True, file, "1", "", QCoreApplication.translate("Utilities", - "Python2 interpreter not configured.")) + "Python2 interpreter not configured."), + []) syntaxChecker = os.path.join(getConfig('ericDir'), "UtilitiesPython2", "Py2SyntaxChecker.py") @@ -1171,7 +1172,8 @@ return (True, file, "1", "", QCoreApplication.translate("Utilities", - "Python2 interpreter did not finish within 30s.")) + "Python2 interpreter did not finish within 30s."), + []) def getConfigDir(): """
--- a/UtilitiesPython2/Py2SyntaxChecker.py Mon Jan 03 17:45:11 2011 +0100 +++ b/UtilitiesPython2/Py2SyntaxChecker.py Tue Jan 04 17:37:48 2011 +0100 @@ -1,3 +1,4 @@ +#!/usr/bin/env python2 # -*- coding: utf-8 -*- # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de> @@ -10,91 +11,24 @@ import sys import re import traceback -from codecs import BOM_UTF8, BOM_UTF16, BOM_UTF32 + +from Tools import readEncodedFile, normalizeCode from py2flakes.checker import Checker from py2flakes.messages import ImportStarUsed -coding_regexps = [ - (2, re.compile(r'''coding[:=]\s*([-\w_.]+)''')), - (1, re.compile(r'''<\?xml.*\bencoding\s*=\s*['"]([-\w_.]+)['"]\?>''')), -] - -def get_coding(text): - """ - Function to get the coding of a text. - - @param text text to inspect (string) - @return coding string - """ - lines = text.splitlines() - for coding in coding_regexps: - coding_re = coding[1] - head = lines[:coding[0]] - for l in head: - m = coding_re.search(l) - if m: - return m.group(1).lower() - return None - -def decode(text): - """ - Function to decode a text. - - @param text text to decode (string) - @return decoded text and encoding - """ - try: - if text.startswith(BOM_UTF8): - # UTF-8 with BOM - return unicode(text[len(BOM_UTF8):], 'utf-8'), 'utf-8-bom' - elif text.startswith(BOM_UTF16): - # UTF-16 with BOM - return unicode(text[len(BOM_UTF16):], 'utf-16'), 'utf-16' - elif text.startswith(BOM_UTF32): - # UTF-32 with BOM - return unicode(text[len(BOM_UTF32):], 'utf-32'), 'utf-32' - coding = get_coding(text) - if coding: - return unicode(text, coding), coding - except (UnicodeError, LookupError): - pass - - # Assume UTF-8 - try: - return unicode(text, 'utf-8'), 'utf-8-guessed' - except (UnicodeError, LookupError): - pass - - # Assume Latin-1 (behaviour before 3.7.1) - return unicode(text, "latin-1"), 'latin-1-guessed' - -def compile(file): +def compile(file, codestring): """ Function to compile one Python source file to Python bytecode. @param file source filename (string) + @param codestring source code (string) @return A tuple indicating status (1 = an error was found), the - filename, the linenumber, the code string, the error message - and the full source code (boolean, string, string, string, - string, string). The values are only valid, if the status - equals 1. + filename, the linenumber, the code string and the error message + (boolean, string, string, string, string). The values are only + valid, if the status equals 1. """ import __builtin__ - try: - f = open(file) - codestring, encoding = decode(f.read()) - f.close() - except IOError, msg: - return (1, file, "1", "", "I/O Error: %s" % unicode(msg), "") - - if type(codestring) == type(u""): - codestring = codestring.encode('utf-8') - codestring = codestring.replace("\r\n","\n") - codestring = codestring.replace("\r","\n") - - if codestring and codestring[-1] != '\n': - codestring = codestring + '\n' try: if type(file) == type(u""): @@ -129,7 +63,7 @@ line = detail.lineno and detail.lineno or 1 code = "" error = detail.msg - return (1, fn, line, code, error, codestring) + return (1, fn, line, code, error) except ValueError, detail: try: fn = detail.filename @@ -140,18 +74,18 @@ line = 1 error = unicode(detail) code = "" - return (1, fn, line, code, error, codestring) + return (1, fn, line, code, error) except StandardError, detail: try: fn = detail.filename line = detail.lineno code = "" error = detail.msg - return (1, fn, line, code, error, codestring) + return (1, fn, line, code, error) except: # this catchall is intentional pass - return (0, None, None, None, None, codestring) + return (0, None, None, None, None) def flakesCheck(fileName, codestring, ignoreStarImportWarnings): """ @@ -198,7 +132,15 @@ print "No file name given." else: filename = sys.argv[-1] - syntaxerror, fname, line, code, error, codestring = compile(filename) + try: + codestring = readEncodedFile(filename)[0] + codestring = normalizeCode(codestring) + + syntaxerror, fname, line, code, error = compile(filename, codestring) + except IOError, msg: + # fake a syntax error + syntaxerror, fname, line, code, error = \ + 1, filename, "1", "", "I/O Error: %s" % unicode(msg) if syntaxerror: print "ERROR"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UtilitiesPython2/Tabnanny.py Tue Jan 04 17:37:48 2011 +0100 @@ -0,0 +1,385 @@ +# -*- coding: utf-8 -*- + +""" +The Tab Nanny despises ambiguous indentation. She knows no mercy. + +tabnanny -- Detection of ambiguous indentation + +For the time being this module is intended to be called as a script. +However it is possible to import it into an IDE and use the function +check() described below. + +Warning: The API provided by this module is likely to change in future +releases; such changes may not be backward compatible. + +This is a modified version to make the original tabnanny better suitable +for being called from within the eric5 IDE. + +@exception ValueError The tokenize module is too old. +""" + +# Released to the public domain, by Tim Peters, 15 April 1998. + +# XXX Note: this is now a standard library module. +# XXX The API needs to undergo changes however; the current code is too +# XXX script-like. This will be addressed later. + +# +# This is a modified version to make the original tabnanny better suitable +# for being called from within the eric4 IDE. The modifications are as +# follows: +# +# - there is no main function anymore +# - check function has been modified to only accept a filename and return +# a tuple indicating status (1 = an error was found), the filename, the +# linenumber and the error message (boolean, string, string, string). The +# values are only valid, if the status equals 1. +# +# Modifications copyright (c) 2003 Detlev Offenbach <detlev@die-offenbachs.de> +# + +__version__ = "6_eric5" + +import tokenize +import cStringIO + +if not hasattr(tokenize, 'NL'): + raise ValueError("tokenize.NL doesn't exist -- tokenize module too old") + +__all__ = ["check", "NannyNag", "process_tokens"] + +class NannyNag(Exception): + """ + Raised by tokeneater() if detecting an ambiguous indent. + Captured and handled in check(). + """ + def __init__(self, lineno, msg, line): + """ + Constructor + + @param lineno Line number of the ambiguous indent. + @param msg Descriptive message assigned to this problem. + @param line The offending source line. + """ + self.lineno, self.msg, self.line = lineno, msg, line + + def get_lineno(self): + """ + Method to retrieve the line number. + + @return The line number (integer) + """ + return self.lineno + + def get_msg(self): + """ + Method to retrieve the message. + + @return The error message (string) + """ + return self.msg + + def get_line(self): + """ + Method to retrieve the offending line. + + @return The line of code (string) + """ + return self.line + +def check(filename, codestring): + """ + Private function to check one Python source file for whitespace related problems. + + @param filename source filename (string) + @param codestring source code (string) + @return A tuple indicating status (True = an error was found), the + filename, the linenumber and the error message + (boolean, string, string, string). The values are only + valid, if the status is True. + """ + global indents, check_equal + indents = [Whitespace("")] + check_equal = 0 + + source = cStringIO.StringIO(codestring) + try: + process_tokens(tokenize.generate_tokens(source.readline)) + + except tokenize.TokenError, msg: + return (True, filename, "1", "Token Error: %s" % unicode(msg)) + + except IndentationError, err: + return (True, filename, err.lineno, "Indentation Error: %s" % unicode(err.msg)) + + except NannyNag, nag: + badline = nag.get_lineno() + line = nag.get_line() + return (True, filename, str(badline), line) + + except Exception, err: + return (True, filename, "1", "Unspecific Error: %s" % unicode(err)) + + return (False, None, None, None) + +class Whitespace(object): + """ + Class implementing the whitespace checker. + """ + # the characters used for space and tab + S, T = ' \t' + + # members: + # raw + # the original string + # n + # the number of leading whitespace characters in raw + # nt + # the number of tabs in raw[:n] + # norm + # the normal form as a pair (count, trailing), where: + # count + # a tuple such that raw[:n] contains count[i] + # instances of S * i + T + # trailing + # the number of trailing spaces in raw[:n] + # It's A Theorem that m.indent_level(t) == + # n.indent_level(t) for all t >= 1 iff m.norm == n.norm. + # is_simple + # true iff raw[:n] is of the form (T*)(S*) + + def __init__(self, ws): + """ + Constructor + + @param ws The string to be checked. + """ + self.raw = ws + S, T = Whitespace.S, Whitespace.T + count = [] + b = n = nt = 0 + for ch in self.raw: + if ch == S: + n = n + 1 + b = b + 1 + elif ch == T: + n = n + 1 + nt = nt + 1 + if b >= len(count): + count = count + [0] * (b - len(count) + 1) + count[b] = count[b] + 1 + b = 0 + else: + break + self.n = n + self.nt = nt + self.norm = tuple(count), b + self.is_simple = len(count) <= 1 + + # return length of longest contiguous run of spaces (whether or not + # preceding a tab) + def longest_run_of_spaces(self): + """ + Method to calculate the length of longest contiguous run of spaces. + + @return The length of longest contiguous run of spaces (whether or not + preceding a tab) + """ + count, trailing = self.norm + return max(len(count)-1, trailing) + + def indent_level(self, tabsize): + """ + Method to determine the indentation level. + + @param tabsize The length of a tab stop. (integer) + @return indentation level (integer) + """ + # count, il = self.norm + # for i in range(len(count)): + # if count[i]: + # il = il + (i/tabsize + 1)*tabsize * count[i] + # return il + + # quicker: + # il = trailing + sum (i/ts + 1)*ts*count[i] = + # trailing + ts * sum (i/ts + 1)*count[i] = + # trailing + ts * sum i/ts*count[i] + count[i] = + # trailing + ts * [(sum i/ts*count[i]) + (sum count[i])] = + # trailing + ts * [(sum i/ts*count[i]) + num_tabs] + # and note that i/ts*count[i] is 0 when i < ts + + count, trailing = self.norm + il = 0 + for i in range(tabsize, len(count)): + il = il + i/tabsize * count[i] + return trailing + tabsize * (il + self.nt) + + # return true iff self.indent_level(t) == other.indent_level(t) + # for all t >= 1 + def equal(self, other): + """ + Method to compare the indentation levels of two Whitespace objects for equality. + + @param other Whitespace object to compare against. + @return True, if we compare equal against the other Whitespace object. + """ + return self.norm == other.norm + + # return a list of tuples (ts, i1, i2) such that + # i1 == self.indent_level(ts) != other.indent_level(ts) == i2. + # Intended to be used after not self.equal(other) is known, in which + # case it will return at least one witnessing tab size. + def not_equal_witness(self, other): + """ + Method to calculate a tuple of witnessing tab size. + + Intended to be used after not self.equal(other) is known, in which + case it will return at least one witnessing tab size. + + @param other Whitespace object to calculate against. + @return A list of tuples (ts, i1, i2) such that + i1 == self.indent_level(ts) != other.indent_level(ts) == i2. + """ + n = max(self.longest_run_of_spaces(), + other.longest_run_of_spaces()) + 1 + a = [] + for ts in range(1, n+1): + if self.indent_level(ts) != other.indent_level(ts): + a.append( (ts, + self.indent_level(ts), + other.indent_level(ts)) ) + return a + + # Return True iff self.indent_level(t) < other.indent_level(t) + # for all t >= 1. + # The algorithm is due to Vincent Broman. + # Easy to prove it's correct. + # XXXpost that. + # Trivial to prove n is sharp (consider T vs ST). + # Unknown whether there's a faster general way. I suspected so at + # first, but no longer. + # For the special (but common!) case where M and N are both of the + # form (T*)(S*), M.less(N) iff M.len() < N.len() and + # M.num_tabs() <= N.num_tabs(). Proof is easy but kinda long-winded. + # XXXwrite that up. + # Note that M is of the form (T*)(S*) iff len(M.norm[0]) <= 1. + def less(self, other): + """ + Method to compare the indentation level against another Whitespace objects to + be smaller. + + @param other Whitespace object to compare against. + @return True, if we compare less against the other Whitespace object. + """ + if self.n >= other.n: + return False + if self.is_simple and other.is_simple: + return self.nt <= other.nt + n = max(self.longest_run_of_spaces(), + other.longest_run_of_spaces()) + 1 + # the self.n >= other.n test already did it for ts=1 + for ts in range(2, n+1): + if self.indent_level(ts) >= other.indent_level(ts): + return False + return True + + # return a list of tuples (ts, i1, i2) such that + # i1 == self.indent_level(ts) >= other.indent_level(ts) == i2. + # Intended to be used after not self.less(other) is known, in which + # case it will return at least one witnessing tab size. + def not_less_witness(self, other): + """ + Method to calculate a tuple of witnessing tab size. + + Intended to be used after not self.less(other is known, in which + case it will return at least one witnessing tab size. + + @param other Whitespace object to calculate against. + @return A list of tuples (ts, i1, i2) such that + i1 == self.indent_level(ts) >= other.indent_level(ts) == i2. + """ + n = max(self.longest_run_of_spaces(), + other.longest_run_of_spaces()) + 1 + a = [] + for ts in range(1, n+1): + if self.indent_level(ts) >= other.indent_level(ts): + a.append( (ts, + self.indent_level(ts), + other.indent_level(ts)) ) + return a + +def format_witnesses(w): + """ + Function to format the witnesses as a readable string. + + @param w A list of witnesses + @return A formated string of the witnesses. + """ + firsts = map(lambda tup: str(tup[0]), w) + prefix = "at tab size" + if len(w) > 1: + prefix = prefix + "s" + return prefix + " " + ', '.join(firsts) + +def process_tokens(tokens): + """ + Function processing all tokens generated by a tokenizer run. + + @param tokens list of tokens + """ + INDENT = tokenize.INDENT + DEDENT = tokenize.DEDENT + NEWLINE = tokenize.NEWLINE + JUNK = tokenize.COMMENT, tokenize.NL + indents = [Whitespace("")] + check_equal = 0 + + for (type, token, start, end, line) in tokens: + if type == NEWLINE: + # a program statement, or ENDMARKER, will eventually follow, + # after some (possibly empty) run of tokens of the form + # (NL | COMMENT)* (INDENT | DEDENT+)? + # If an INDENT appears, setting check_equal is wrong, and will + # be undone when we see the INDENT. + check_equal = 1 + + elif type == INDENT: + check_equal = 0 + thisguy = Whitespace(token) + if not indents[-1].less(thisguy): + witness = indents[-1].not_less_witness(thisguy) + msg = "indent not greater e.g. " + format_witnesses(witness) + raise NannyNag(start[0], msg, line) + indents.append(thisguy) + + elif type == DEDENT: + # there's nothing we need to check here! what's important is + # that when the run of DEDENTs ends, the indentation of the + # program statement (or ENDMARKER) that triggered the run is + # equal to what's left at the top of the indents stack + + # Ouch! This assert triggers if the last line of the source + # is indented *and* lacks a newline -- then DEDENTs pop out + # of thin air. + # assert check_equal # else no earlier NEWLINE, or an earlier INDENT + check_equal = 1 + + del indents[-1] + + elif check_equal and type not in JUNK: + # this is the first "real token" following a NEWLINE, so it + # must be the first token of the next program statement, or an + # ENDMARKER; the "line" argument exposes the leading whitespace + # for this statement; in the case of ENDMARKER, line is an empty + # string, so will properly match the empty string with which the + # "indents" stack was seeded + check_equal = 0 + thisguy = Whitespace(line) + if not indents[-1].equal(thisguy): + witness = indents[-1].not_equal_witness(thisguy) + msg = "indent not equal e.g. " + format_witnesses(witness) + raise NannyNag(start[0], msg, line) + +# +# eflag: FileType = Python2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UtilitiesPython2/TabnannyChecker.py Tue Jan 04 17:37:48 2011 +0100 @@ -0,0 +1,46 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- + +# Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing the indentation check for Python 2. +""" + +import sys + +import Tabnanny + +from Tools import readEncodedFile, normalizeCode + +if __name__ == "__main__": + if len(sys.argv) < 2: + print "ERROR" + print "" + print "" + print "No file name given." + else: + filename = sys.argv[-1] + try: + codestring = readEncodedFile(filename)[0] + codestring = normalizeCode(codestring) + + nok, fname, line, error = Tabnanny.check(filename, codestring) + except IOError, msg: + # fake an indentation error + nok, fname, line, error = \ + True, filename, "1", "I/O Error: %s" % unicode(msg) + + if nok: + print "ERROR" + else: + print "NO_ERROR" + print fname + print line + print error + + sys.exit(0) + +# +# eflag: FileType = Python2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UtilitiesPython2/Tools.py Tue Jan 04 17:37:48 2011 +0100 @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing tool functions. +""" + +import re +from codecs import BOM_UTF8, BOM_UTF16, BOM_UTF32 + +coding_regexps = [ + (2, re.compile(r'''coding[:=]\s*([-\w_.]+)''')), + (1, re.compile(r'''<\?xml.*\bencoding\s*=\s*['"]([-\w_.]+)['"]\?>''')), +] + +def get_coding(text): + """ + Function to get the coding of a text. + + @param text text to inspect (string) + @return coding string + """ + lines = text.splitlines() + for coding in coding_regexps: + coding_re = coding[1] + head = lines[:coding[0]] + for l in head: + m = coding_re.search(l) + if m: + return m.group(1).lower() + return None + +def decode(text): + """ + Function to decode a text. + + @param text text to decode (string) + @return decoded text and encoding + """ + try: + if text.startswith(BOM_UTF8): + # UTF-8 with BOM + return unicode(text[len(BOM_UTF8):], 'utf-8'), 'utf-8-bom' + elif text.startswith(BOM_UTF16): + # UTF-16 with BOM + return unicode(text[len(BOM_UTF16):], 'utf-16'), 'utf-16' + elif text.startswith(BOM_UTF32): + # UTF-32 with BOM + return unicode(text[len(BOM_UTF32):], 'utf-32'), 'utf-32' + coding = get_coding(text) + if coding: + return unicode(text, coding), coding + except (UnicodeError, LookupError): + pass + + # Assume UTF-8 + try: + return unicode(text, 'utf-8'), 'utf-8-guessed' + except (UnicodeError, LookupError): + pass + + # Assume Latin-1 (behaviour before 3.7.1) + return unicode(text, "latin-1"), 'latin-1-guessed' + +def readEncodedFile(filename): + """ + Function to read a file and decode it's contents into proper text. + + @param filename name of the file to read (string) + @return tuple of decoded text and encoding (string, string) + """ + f = open(filename) + text = f.read() + f.close() + return decode(text) + +def normalizeCode(codestring): + """ + Function to normalize the given code. + + @param codestring code to be normalized (string) + @return normalized code (string) + """ + if type(codestring) == type(u""): + codestring = codestring.encode('utf-8') + codestring = codestring.replace("\r\n","\n").replace("\r","\n") + + if codestring and codestring[-1] != '\n': + codestring = codestring + '\n' + + return codestring + +# +# eflag: FileType = Python2
--- a/changelog Mon Jan 03 17:45:11 2011 +0100 +++ b/changelog Tue Jan 04 17:37:48 2011 +0100 @@ -14,6 +14,7 @@ mechanism. - added a syntax checker function for Python 2 files - added a pyflakes checker function for Python 2 files +- added a tabnanny checker function for Python 2 files Version 5.1-snapshot-20101029: - bug fixes
--- a/eric5.e4p Mon Jan 03 17:45:11 2011 +0100 +++ b/eric5.e4p Tue Jan 04 17:37:48 2011 +0100 @@ -839,6 +839,9 @@ <Source>UtilitiesPython2/py2flakes/__init__.py</Source> <Source>UtilitiesPython2/py2flakes/checker.py</Source> <Source>UtilitiesPython2/py2flakes/messages.py</Source> + <Source>UtilitiesPython2/Tools.py</Source> + <Source>UtilitiesPython2/Tabnanny.py</Source> + <Source>UtilitiesPython2/TabnannyChecker.py</Source> </Sources> <Forms> <Form>PyUnit/UnittestDialog.ui</Form>
--- a/i18n/eric5_cs.ts Mon Jan 03 17:45:11 2011 +0100 +++ b/i18n/eric5_cs.ts Tue Jan 04 17:37:48 2011 +0100 @@ -35508,7 +35508,7 @@ <translation>Stisknout pro zobrazení všech souborů, které obsahují problém</translation> </message> <message> - <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="251"/> + <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="253"/> <source>No issues found.</source> <translation>Žádné problémy nenalezeny.</translation> </message> @@ -35900,6 +35900,9 @@ </message> </context> <context> + <name>Tabnanny</name> +</context> +<context> <name>TabnannyDialog</name> <message> <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.ui" line="14"/> @@ -35944,7 +35947,7 @@ <translation>Zobrazit průběh akce tabnanny</translation> </message> <message> - <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="170"/> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="185"/> <source>No indentation errors found.</source> <translation>Žádné chyby zarážek nebyly nalezeny.</translation> </message> @@ -35973,16 +35976,26 @@ <source>Start</source> <translation type="unfinished"></translation> </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="255"/> + <source>Python2 interpreter not configured.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="280"/> + <source>Python2 interpreter did not finish within 15s.</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>TabnannyPlugin</name> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>Check Indentations</source> <translation>Kontrola odsazení</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>&Indentations...</source> <translation>&Odsazení...</translation> </message> @@ -35992,7 +36005,7 @@ <translation>Kontrola odsazení za použití tabnanny.</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="163"/> + <location filename="Plugins/PluginTabnanny.py" line="165"/> <source><b>Check Indentations...</b><p>This checks Python files for bad indentations using tabnanny.</p></source> <translation><b>Kontrola odsazení....</b><p>Zkontroluje všechny Python soubory na správné odsazení za použití funkce tabnanny.</p></translation> </message> @@ -40681,7 +40694,7 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="Utilities/__init__.py" line="1172"/> + <location filename="Utilities/__init__.py" line="1173"/> <source>Python2 interpreter did not finish within 30s.</source> <translation type="unfinished"></translation> </message>
--- a/i18n/eric5_de.ts Mon Jan 03 17:45:11 2011 +0100 +++ b/i18n/eric5_de.ts Tue Jan 04 17:37:48 2011 +0100 @@ -35135,7 +35135,7 @@ <translation>Drücken, um alle Dateien mit Problemen anzuzeigen</translation> </message> <message> - <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="251"/> + <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="253"/> <source>No issues found.</source> <translation>Keine Probleme gefunden.</translation> </message> @@ -35529,7 +35529,7 @@ <context> <name>TabnannyDialog</name> <message> - <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="170"/> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="185"/> <source>No indentation errors found.</source> <translation>Keine Einrückungsfehler gefunden.</translation> </message> @@ -35604,16 +35604,26 @@ <source>Start</source> <translation>Starten</translation> </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="255"/> + <source>Python2 interpreter not configured.</source> + <translation>Kein Python2 Interpreter konfiguriert.</translation> + </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="280"/> + <source>Python2 interpreter did not finish within 15s.</source> + <translation>Python2 Interpreter wurde nicht innerhalb von 15s beendet.</translation> + </message> </context> <context> <name>TabnannyPlugin</name> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>Check Indentations</source> <translation>Einrückungen prüfen</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>&Indentations...</source> <translation>&Einrückungen...</translation> </message> @@ -35623,7 +35633,7 @@ <translation>Einrückungen mit Tabnanny überprüfen.</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="163"/> + <location filename="Plugins/PluginTabnanny.py" line="165"/> <source><b>Check Indentations...</b><p>This checks Python files for bad indentations using tabnanny.</p></source> <translation><b>Einrückungen überprüfen...</b><p>Dies überprüft Python Dateien auf fehlerhafte Einrückungen mittels Tabnanny.</p></translation> </message> @@ -40275,7 +40285,7 @@ <translation>Kein Python2 Interpreter konfiguriert.</translation> </message> <message> - <location filename="Utilities/__init__.py" line="1172"/> + <location filename="Utilities/__init__.py" line="1173"/> <source>Python2 interpreter did not finish within 30s.</source> <translation>Python2 Interpreter wurde nicht innerhalb von 30s beendet.</translation> </message>
--- a/i18n/eric5_en.ts Mon Jan 03 17:45:11 2011 +0100 +++ b/i18n/eric5_en.ts Tue Jan 04 17:37:48 2011 +0100 @@ -34831,7 +34831,7 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="251"/> + <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="253"/> <source>No issues found.</source> <translation type="unfinished"></translation> </message> @@ -35265,20 +35265,30 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="170"/> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="185"/> <source>No indentation errors found.</source> <translation type="unfinished"></translation> </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="255"/> + <source>Python2 interpreter not configured.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="280"/> + <source>Python2 interpreter did not finish within 15s.</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>TabnannyPlugin</name> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>Check Indentations</source> <translation type="unfinished"></translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>&Indentations...</source> <translation type="unfinished"></translation> </message> @@ -35288,7 +35298,7 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="163"/> + <location filename="Plugins/PluginTabnanny.py" line="165"/> <source><b>Check Indentations...</b><p>This checks Python files for bad indentations using tabnanny.</p></source> <translation type="unfinished"></translation> </message> @@ -39902,7 +39912,7 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="Utilities/__init__.py" line="1172"/> + <location filename="Utilities/__init__.py" line="1173"/> <source>Python2 interpreter did not finish within 30s.</source> <translation type="unfinished"></translation> </message>
--- a/i18n/eric5_es.ts Mon Jan 03 17:45:11 2011 +0100 +++ b/i18n/eric5_es.ts Tue Jan 04 17:37:48 2011 +0100 @@ -35153,7 +35153,7 @@ <translation>Pulsar para mostrar todos los archivos con algún problema</translation> </message> <message> - <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="251"/> + <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="253"/> <source>No issues found.</source> <translation>No se han encontrado problemas.</translation> </message> @@ -35545,6 +35545,9 @@ </message> </context> <context> + <name>Tabnanny</name> +</context> +<context> <name>TabnannyDialog</name> <message> <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.ui" line="14"/> @@ -35591,7 +35594,7 @@ <translation>Muestra el progreso de la acción de tabnanny</translation> </message> <message> - <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="170"/> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="185"/> <source>No indentation errors found.</source> <translation>No se han encontrado errores de indentación.</translation> </message> @@ -35620,16 +35623,26 @@ <source>Start</source> <translation>Iniciar</translation> </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="255"/> + <source>Python2 interpreter not configured.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="280"/> + <source>Python2 interpreter did not finish within 15s.</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>TabnannyPlugin</name> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>Check Indentations</source> <translation>Verificar Indentaciones</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>&Indentations...</source> <translation>&Indentaciones...</translation> </message> @@ -35639,7 +35652,7 @@ <translation>Verificar indentaciones utilizando tabnanny.</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="163"/> + <location filename="Plugins/PluginTabnanny.py" line="165"/> <source><b>Check Indentations...</b><p>This checks Python files for bad indentations using tabnanny.</p></source> <translation><b>Verificar Indentaciones...</b><p>Chequea archivos Python buscando indentaciones mal hechas usando tabnanny.</p></translation> </message> @@ -40308,7 +40321,7 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="Utilities/__init__.py" line="1172"/> + <location filename="Utilities/__init__.py" line="1173"/> <source>Python2 interpreter did not finish within 30s.</source> <translation type="unfinished"></translation> </message>
--- a/i18n/eric5_fr.ts Mon Jan 03 17:45:11 2011 +0100 +++ b/i18n/eric5_fr.ts Tue Jan 04 17:37:48 2011 +0100 @@ -38819,7 +38819,7 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="251"/> + <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="253"/> <source>No issues found.</source> <translation type="unfinished"></translation> </message> @@ -39216,9 +39216,12 @@ </message> </context> <context> + <name>Tabnanny</name> +</context> +<context> <name>TabnannyDialog</name> <message> - <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="170"/> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="185"/> <source>No indentation errors found.</source> <translation>Aucune erreur d'indentation trouvée.</translation> </message> @@ -39293,16 +39296,26 @@ <source>Start</source> <translation type="unfinished"></translation> </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="255"/> + <source>Python2 interpreter not configured.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="280"/> + <source>Python2 interpreter did not finish within 15s.</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>TabnannyPlugin</name> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>Check Indentations</source> <translation>Vérification des indentations</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>&Indentations...</source> <translation>&Indentations...</translation> </message> @@ -39312,7 +39325,7 @@ <translation>Vérifie les indentation en utilisant tabanny.</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="163"/> + <location filename="Plugins/PluginTabnanny.py" line="165"/> <source><b>Check Indentations...</b><p>This checks Python files for bad indentations using tabnanny.</p></source> <translation><b>Vérification des indentations...</b><p>Vérifie les mauvaises indentations des fichiers Python en utilisant tabanny.</p></translation> </message> @@ -44582,7 +44595,7 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="Utilities/__init__.py" line="1172"/> + <location filename="Utilities/__init__.py" line="1173"/> <source>Python2 interpreter did not finish within 30s.</source> <translation type="unfinished"></translation> </message>
--- a/i18n/eric5_it.ts Mon Jan 03 17:45:11 2011 +0100 +++ b/i18n/eric5_it.ts Tue Jan 04 17:37:48 2011 +0100 @@ -35654,7 +35654,7 @@ <translation>Premi per mostrare tutti i file che contengono errori di sintassi</translation> </message> <message> - <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="251"/> + <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="253"/> <source>No issues found.</source> <translation>Nessun problema trovato.</translation> </message> @@ -36046,9 +36046,12 @@ </message> </context> <context> + <name>Tabnanny</name> +</context> +<context> <name>TabnannyDialog</name> <message> - <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="170"/> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="185"/> <source>No indentation errors found.</source> <translation>Nessun errore di identazione trovato.</translation> </message> @@ -36121,16 +36124,26 @@ <source>Start</source> <translation type="unfinished">Inizia</translation> </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="255"/> + <source>Python2 interpreter not configured.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="280"/> + <source>Python2 interpreter did not finish within 15s.</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>TabnannyPlugin</name> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>Check Indentations</source> <translation>Controlla indentazione</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>&Indentations...</source> <translation>&Indentazione...</translation> </message> @@ -36140,7 +36153,7 @@ <translation>Controlla indentazione con tabnanny.</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="163"/> + <location filename="Plugins/PluginTabnanny.py" line="165"/> <source><b>Check Indentations...</b><p>This checks Python files for bad indentations using tabnanny.</p></source> <translation><b>Controlla indentazione...</b><p>Controlla i file Python per errori di indentazione usando tabnanny.</p></translation> </message> @@ -40846,7 +40859,7 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="Utilities/__init__.py" line="1172"/> + <location filename="Utilities/__init__.py" line="1173"/> <source>Python2 interpreter did not finish within 30s.</source> <translation type="unfinished"></translation> </message>
--- a/i18n/eric5_ru.ts Mon Jan 03 17:45:11 2011 +0100 +++ b/i18n/eric5_ru.ts Tue Jan 04 17:37:48 2011 +0100 @@ -35733,7 +35733,7 @@ <translation>Показать все файлы, содержащие синтаксические ошибки</translation> </message> <message> - <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="251"/> + <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="253"/> <source>No issues found.</source> <translation>Синтаксисические ошибки не найдены.</translation> </message> @@ -36128,9 +36128,12 @@ </message> </context> <context> + <name>Tabnanny</name> +</context> +<context> <name>TabnannyDialog</name> <message> - <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="170"/> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="185"/> <source>No indentation errors found.</source> <translation>Ошибки в отступах не найдены.</translation> </message> @@ -36203,16 +36206,26 @@ <source>Start</source> <translation type="unfinished">Начало</translation> </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="255"/> + <source>Python2 interpreter not configured.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="280"/> + <source>Python2 interpreter did not finish within 15s.</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>TabnannyPlugin</name> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>Check Indentations</source> <translation>Проверить отступы</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>&Indentations...</source> <translation>&Отступы...</translation> </message> @@ -36222,7 +36235,7 @@ <translation>Проверить отступы с помощью tabnanny.</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="163"/> + <location filename="Plugins/PluginTabnanny.py" line="165"/> <source><b>Check Indentations...</b><p>This checks Python files for bad indentations using tabnanny.</p></source> <translation><b>Проверить отступы...</b><p>Проверяет файлы Python на некорректные отступы при помощи tabnanny.</p></translation> </message> @@ -40963,7 +40976,7 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="Utilities/__init__.py" line="1172"/> + <location filename="Utilities/__init__.py" line="1173"/> <source>Python2 interpreter did not finish within 30s.</source> <translation type="unfinished"></translation> </message>
--- a/i18n/eric5_tr.ts Mon Jan 03 17:45:11 2011 +0100 +++ b/i18n/eric5_tr.ts Tue Jan 04 17:37:48 2011 +0100 @@ -38058,7 +38058,7 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="251"/> + <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="253"/> <source>No issues found.</source> <translation type="unfinished"></translation> </message> @@ -38455,6 +38455,9 @@ </message> </context> <context> + <name>Tabnanny</name> +</context> +<context> <name>TabnannyDialog</name> <message> <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.ui" line="14"/> @@ -38497,7 +38500,7 @@ <translation>Sekme yardımcısının işlemlerini gösterir</translation> </message> <message> - <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="170"/> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="185"/> <source>No indentation errors found.</source> <translation>Girinti hatası bulunamadı.</translation> </message> @@ -38526,16 +38529,26 @@ <source>Start</source> <translation type="unfinished">Başla</translation> </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="255"/> + <source>Python2 interpreter not configured.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="280"/> + <source>Python2 interpreter did not finish within 15s.</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>TabnannyPlugin</name> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>Check Indentations</source> <translation>Girinti Kontrolü</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>&Indentations...</source> <translation>G&irintiler...</translation> </message> @@ -38545,7 +38558,7 @@ <translation>Girintileri sekmeyardımcıları kullanarak kontrol et.</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="163"/> + <location filename="Plugins/PluginTabnanny.py" line="165"/> <source><b>Check Indentations...</b><p>This checks Python files for bad indentations using tabnanny.</p></source> <translation><b>Girinti Kontrolu...</b><p>bu kontrol python dosyalarında sekmelerin yanlış kullanımına karşı yapılır.</p></translation> </message> @@ -43674,7 +43687,7 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="Utilities/__init__.py" line="1172"/> + <location filename="Utilities/__init__.py" line="1173"/> <source>Python2 interpreter did not finish within 30s.</source> <translation type="unfinished"></translation> </message>
--- a/i18n/eric5_zh_CN.GB2312.ts Mon Jan 03 17:45:11 2011 +0100 +++ b/i18n/eric5_zh_CN.GB2312.ts Tue Jan 04 17:37:48 2011 +0100 @@ -38795,7 +38795,7 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="251"/> + <location filename="Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py" line="253"/> <source>No issues found.</source> <translation type="unfinished"></translation> </message> @@ -39192,6 +39192,9 @@ </message> </context> <context> + <name>Tabnanny</name> +</context> +<context> <name>TabnannyDialog</name> <message> <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.ui" line="14"/> @@ -39238,7 +39241,7 @@ <translation>显示 tabnanny 行为的进程</translation> </message> <message> - <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="170"/> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="185"/> <source>No indentation errors found.</source> <translation>未找到缩进错误。</translation> </message> @@ -39267,16 +39270,26 @@ <source>Start</source> <translation type="unfinished">开始</translation> </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="255"/> + <source>Python2 interpreter not configured.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py" line="280"/> + <source>Python2 interpreter did not finish within 15s.</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>TabnannyPlugin</name> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>Check Indentations</source> <translation>检查缩进</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="160"/> + <location filename="Plugins/PluginTabnanny.py" line="162"/> <source>&Indentations...</source> <translation>缩进(&I)……</translation> </message> @@ -39286,7 +39299,7 @@ <translation>使用 tabnanny 检查缩进。</translation> </message> <message> - <location filename="Plugins/PluginTabnanny.py" line="163"/> + <location filename="Plugins/PluginTabnanny.py" line="165"/> <source><b>Check Indentations...</b><p>This checks Python files for bad indentations using tabnanny.</p></source> <translation><b>检查缩进……</b><p>使用 tabnanny 检查 Python 文件的不良缩进。</p></translation> </message> @@ -44560,7 +44573,7 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="Utilities/__init__.py" line="1172"/> + <location filename="Utilities/__init__.py" line="1173"/> <source>Python2 interpreter did not finish within 30s.</source> <translation type="unfinished"></translation> </message>