~ubuntu-branches/ubuntu/karmic/eric/karmic

« back to all changes in this revision

Viewing changes to eric/Documentation/Source/eric3doc-eric3.Checks.Tabnanny.html

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2008-01-28 18:02:25 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080128180225-6nrox6yrworh2c4v
Tags: 4.0.4-1ubuntu1
* Add python-qt3 to build-depends becuase that's where Ubuntu puts 
  pyqtconfig
* Change maintainer to MOTU

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
2
 
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
3
 
<html><head>
4
 
<title>eric3.Checks.Tabnanny</title>
5
 
</head>
6
 
<body bgcolor="#FFFFFF"><a NAME="top" ID="top"></a>
7
 
<h1><font color="#0000FF">eric3.Checks.Tabnanny</font></h1>
8
 
<p>
9
 
The Tab Nanny despises ambiguous indentation.  She knows no mercy.
10
 
</p><p>
11
 
tabnanny -- Detection of ambiguous indentation
12
 
</p><p>
13
 
For the time being this module is intended to be called as a script.
14
 
However it is possible to import it into an IDE and use the function
15
 
check() described below.
16
 
</p><p>
17
 
Warning: The API provided by this module is likely to change in future
18
 
releases; such changes may not be backward compatible.
19
 
</p><p>
20
 
This is a modified version to make the original tabnanny better suitable
21
 
for being called from within the eric3 IDE.
22
 
</p><dl>
23
 
<dt>Raises <b>ValueError</b>:</dt>
24
 
<dd>
25
 
The tokenize module is too old.
26
 
</dd>
27
 
</dl>
28
 
<h3><font color="#FF0000">Classes</font></h3>
29
 
<table>
30
 
<tr>
31
 
<td><a href="#NannyNag">NannyNag</a></td>
32
 
<td>Raised by tokeneater() if detecting an ambiguous indent.</td>
33
 
</tr><tr>
34
 
<td><a href="#Whitespace">Whitespace</a></td>
35
 
<td>Class implementing the whitespace checker.</td>
36
 
</tr>
37
 
</table>
38
 
<h3><font color="#FF0000">Functions</font></h3>
39
 
<table>
40
 
<tr>
41
 
<td><a href="#check">check</a></td>
42
 
<td>Private function to check one Python source file for whitespace related problems.</td>
43
 
</tr><tr>
44
 
<td><a href="#format_witnesses">format_witnesses</a></td>
45
 
<td>Function to format the witnesses as a readable string.</td>
46
 
</tr><tr>
47
 
<td><a href="#tokeneater">tokeneater</a></td>
48
 
<td>Function implementing the token eater.</td>
49
 
</tr>
50
 
</table>
51
 
<hr /><hr />
52
 
<a NAME="NannyNag" ID="NannyNag"></a>
53
 
<h2><font color="#0000FF">NannyNag</font></h2>
54
 
<p>
55
 
    Raised by tokeneater() if detecting an ambiguous indent.
56
 
    Captured and handled in check().
57
 
</p>
58
 
<h3><font color="#FF0000">Derived from</font></h3>
59
 
None
60
 
<h3><font color="#FF0000">Methods</font></h3>
61
 
<table>
62
 
<tr>
63
 
<td><a href="#NannyNag.__init__">NannyNag</a></td>
64
 
<td>Constructor</td>
65
 
</tr><tr>
66
 
<td><a href="#NannyNag.get_line">get_line</a></td>
67
 
<td>Method to retrieve the offending line.</td>
68
 
</tr><tr>
69
 
<td><a href="#NannyNag.get_lineno">get_lineno</a></td>
70
 
<td>Method to retrieve the line number.</td>
71
 
</tr><tr>
72
 
<td><a href="#NannyNag.get_msg">get_msg</a></td>
73
 
<td>Method to retrieve the message.</td>
74
 
</tr>
75
 
</table>
76
 
<p><a NAME="NannyNag.__init__" ID="NannyNag__init__"></a>
77
 
<h3><font color="#0000FF">NannyNag (Constructor)</font></h3>
78
 
<b>NannyNag</b>(<i>lineno, msg, line</i>)
79
 
<p>
80
 
        Constructor
81
 
</p><dl>
82
 
<dt><i>lineno</i></dt>
83
 
<dd>
84
 
Line number of the ambiguous indent.
85
 
</dd><dt><i>msg</i></dt>
86
 
<dd>
87
 
Descriptive message assigned to this problem.
88
 
</dd><dt><i>line</i></dt>
89
 
<dd>
90
 
The offending source line.
91
 
</dd>
92
 
</dl><a NAME="NannyNag.get_line" ID="NannyNagget_line"></a>
93
 
<h3><font color="#0000FF">NannyNag.get_line</font></h3>
94
 
<b>get_line</b>(<i></i>)
95
 
<p>
96
 
        Method to retrieve the offending line.
97
 
</p><dl>
98
 
<dt>Returns:</dt>
99
 
<dd>
100
 
The line of code (string)
101
 
</dd>
102
 
</dl><a NAME="NannyNag.get_lineno" ID="NannyNagget_lineno"></a>
103
 
<h3><font color="#0000FF">NannyNag.get_lineno</font></h3>
104
 
<b>get_lineno</b>(<i></i>)
105
 
<p>
106
 
        Method to retrieve the line number.
107
 
</p><dl>
108
 
<dt>Returns:</dt>
109
 
<dd>
110
 
The line number (integer)
111
 
</dd>
112
 
</dl><a NAME="NannyNag.get_msg" ID="NannyNagget_msg"></a>
113
 
<h3><font color="#0000FF">NannyNag.get_msg</font></h3>
114
 
<b>get_msg</b>(<i></i>)
115
 
<p>
116
 
        Method to retrieve the message.
117
 
</p><dl>
118
 
<dt>Returns:</dt>
119
 
<dd>
120
 
The error message (string)
121
 
</dd>
122
 
</dl></p>
123
 
<div align="right"><a href="#top">Up</a></div>
124
 
<hr /><hr />
125
 
<a NAME="Whitespace" ID="Whitespace"></a>
126
 
<h2><font color="#0000FF">Whitespace</font></h2>
127
 
<p>
128
 
    Class implementing the whitespace checker.
129
 
</p>
130
 
<h3><font color="#FF0000">Derived from</font></h3>
131
 
None
132
 
<h3><font color="#FF0000">Methods</font></h3>
133
 
<table>
134
 
<tr>
135
 
<td><a href="#Whitespace.__init__">Whitespace</a></td>
136
 
<td>Constructor</td>
137
 
</tr><tr>
138
 
<td><a href="#Whitespace.equal">equal</a></td>
139
 
<td>Method to compare the indentation levels of two Whitespace objects for equality.</td>
140
 
</tr><tr>
141
 
<td><a href="#Whitespace.indent_level">indent_level</a></td>
142
 
<td>Method to determine the indentation level.</td>
143
 
</tr><tr>
144
 
<td><a href="#Whitespace.less">less</a></td>
145
 
<td>Method to compare the indentation level against another Whitespace objects to be smaller.</td>
146
 
</tr><tr>
147
 
<td><a href="#Whitespace.longest_run_of_spaces">longest_run_of_spaces</a></td>
148
 
<td>Method to calculate the length of longest contiguous run of spaces.</td>
149
 
</tr><tr>
150
 
<td><a href="#Whitespace.not_equal_witness">not_equal_witness</a></td>
151
 
<td>Method to calculate a tuple of witnessing tab size.</td>
152
 
</tr><tr>
153
 
<td><a href="#Whitespace.not_less_witness">not_less_witness</a></td>
154
 
<td>Method to calculate a tuple of witnessing tab size.</td>
155
 
</tr>
156
 
</table>
157
 
<p><a NAME="Whitespace.__init__" ID="Whitespace__init__"></a>
158
 
<h3><font color="#0000FF">Whitespace (Constructor)</font></h3>
159
 
<b>Whitespace</b>(<i>ws</i>)
160
 
<p>
161
 
        Constructor
162
 
</p><dl>
163
 
<dt><i>ws</i></dt>
164
 
<dd>
165
 
The string to be checked.
166
 
</dd>
167
 
</dl><a NAME="Whitespace.equal" ID="Whitespaceequal"></a>
168
 
<h3><font color="#0000FF">Whitespace.equal</font></h3>
169
 
<b>equal</b>(<i>other</i>)
170
 
<p>
171
 
        Method to compare the indentation levels of two Whitespace objects for equality.
172
 
</p><dl>
173
 
<dt><i>other</i></dt>
174
 
<dd>
175
 
Whitespace object to compare against.
176
 
</dd>
177
 
</dl><dl>
178
 
<dt>Returns:</dt>
179
 
<dd>
180
 
True, if we compare equal against the other Whitespace object.
181
 
</dd>
182
 
</dl><a NAME="Whitespace.indent_level" ID="Whitespaceindent_level"></a>
183
 
<h3><font color="#0000FF">Whitespace.indent_level</font></h3>
184
 
<b>indent_level</b>(<i>tabsize</i>)
185
 
<p>
186
 
        Method to determine the indentation level.
187
 
</p><dl>
188
 
<dt><i>tabsize</i></dt>
189
 
<dd>
190
 
The length of a tab stop. (integer)
191
 
</dd>
192
 
</dl><dl>
193
 
<dt>Returns:</dt>
194
 
<dd>
195
 
indentation level (integer)
196
 
</dd>
197
 
</dl><a NAME="Whitespace.less" ID="Whitespaceless"></a>
198
 
<h3><font color="#0000FF">Whitespace.less</font></h3>
199
 
<b>less</b>(<i>other</i>)
200
 
<p>
201
 
        Method to compare the indentation level against another Whitespace objects to be smaller.
202
 
</p><dl>
203
 
<dt><i>other</i></dt>
204
 
<dd>
205
 
Whitespace object to compare against.
206
 
</dd>
207
 
</dl><dl>
208
 
<dt>Returns:</dt>
209
 
<dd>
210
 
True, if we compare less against the other Whitespace object.
211
 
</dd>
212
 
</dl><a NAME="Whitespace.longest_run_of_spaces" ID="Whitespacelongest_run_of_spaces"></a>
213
 
<h3><font color="#0000FF">Whitespace.longest_run_of_spaces</font></h3>
214
 
<b>longest_run_of_spaces</b>(<i></i>)
215
 
<p>
216
 
        Method to calculate the length of longest contiguous run of spaces.
217
 
</p><dl>
218
 
<dt>Returns:</dt>
219
 
<dd>
220
 
The length of longest contiguous run of spaces (whether or not
221
 
            preceding a tab)
222
 
</dd>
223
 
</dl><a NAME="Whitespace.not_equal_witness" ID="Whitespacenot_equal_witness"></a>
224
 
<h3><font color="#0000FF">Whitespace.not_equal_witness</font></h3>
225
 
<b>not_equal_witness</b>(<i>other</i>)
226
 
<p>
227
 
        Method to calculate a tuple of witnessing tab size.
228
 
</p><p>
229
 
        Intended to be used after not self.equal(other) is known, in which
230
 
        case it will return at least one witnessing tab size.
231
 
</p><dl>
232
 
<dt><i>other</i></dt>
233
 
<dd>
234
 
Whitespace object to calculate against.
235
 
</dd>
236
 
</dl><dl>
237
 
<dt>Returns:</dt>
238
 
<dd>
239
 
A list of tuples (ts, i1, i2) such that
240
 
            i1 == self.indent_level(ts) != other.indent_level(ts) == i2.
241
 
</dd>
242
 
</dl><a NAME="Whitespace.not_less_witness" ID="Whitespacenot_less_witness"></a>
243
 
<h3><font color="#0000FF">Whitespace.not_less_witness</font></h3>
244
 
<b>not_less_witness</b>(<i>other</i>)
245
 
<p>
246
 
        Method to calculate a tuple of witnessing tab size.
247
 
</p><p>
248
 
        Intended to be used after not self.less(other is known, in which
249
 
        case it will return at least one witnessing tab size.
250
 
</p><dl>
251
 
<dt><i>other</i></dt>
252
 
<dd>
253
 
Whitespace object to calculate against.
254
 
</dd>
255
 
</dl><dl>
256
 
<dt>Returns:</dt>
257
 
<dd>
258
 
A list of tuples (ts, i1, i2) such that
259
 
            i1 == self.indent_level(ts) >= other.indent_level(ts) == i2.
260
 
</dd>
261
 
</dl></p>
262
 
<div align="right"><a href="#top">Up</a></div>
263
 
<hr /><hr />
264
 
<a NAME="check" ID="check"></a>
265
 
<h2><font color="#0000FF">check</font></h2>
266
 
<b>check</b>(<i>file</i>)
267
 
<p>
268
 
    Private function to check one Python source file for whitespace related problems.
269
 
</p><dl>
270
 
<dt><i>file</i></dt>
271
 
<dd>
272
 
source filename (string)
273
 
</dd>
274
 
</dl><dl>
275
 
<dt>Returns:</dt>
276
 
<dd>
277
 
A tuple indicating status (1 = an error was found), the
278
 
        filename, the linenumber and the error message
279
 
        (boolean, string, string, string). The values are only
280
 
        valid, if the status equals 1.
281
 
</dd>
282
 
</dl>
283
 
<div align="right"><a href="#top">Up</a></div>
284
 
<hr /><hr />
285
 
<a NAME="format_witnesses" ID="format_witnesses"></a>
286
 
<h2><font color="#0000FF">format_witnesses</font></h2>
287
 
<b>format_witnesses</b>(<i>w</i>)
288
 
<p>
289
 
    Function to format the witnesses as a readable string.
290
 
</p><dl>
291
 
<dt><i>w</i></dt>
292
 
<dd>
293
 
A list of witnesses
294
 
</dd>
295
 
</dl><dl>
296
 
<dt>Returns:</dt>
297
 
<dd>
298
 
A formated string of the witnesses.
299
 
</dd>
300
 
</dl>
301
 
<div align="right"><a href="#top">Up</a></div>
302
 
<hr /><hr />
303
 
<a NAME="tokeneater" ID="tokeneater"></a>
304
 
<h2><font color="#0000FF">tokeneater</font></h2>
305
 
<b>tokeneater</b>(<i>type, token, start, end, line</i>)
306
 
<p>
307
 
    Function implementing the token eater.
308
 
</p><p>
309
 
    It is called by the tokenizer for every token encountered
310
 
    in the input stream.
311
 
</p><dl>
312
 
<dt><i>type</i></dt>
313
 
<dd>
314
 
The type of the token.
315
 
</dd><dt><i>token</i></dt>
316
 
<dd>
317
 
The token itself.
318
 
</dd><dt><i>start</i></dt>
319
 
<dd>
320
 
The start of the token.
321
 
</dd><dt><i>end</i></dt>
322
 
<dd>
323
 
The end of the token.
324
 
</dd><dt><i>line</i></dt>
325
 
<dd>
326
 
The line of code containing the token.
327
 
</dd>
328
 
</dl><dl>
329
 
<dt>Raises <b>NannyNag</b>:</dt>
330
 
<dd>
331
 
An indentation error has occured.
332
 
</dd>
333
 
</dl>
334
 
<div align="right"><a href="#top">Up</a></div>
335
 
<hr />
336
 
</body></html>
 
 
b'\\ No newline at end of file'