Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html

changeset 2868
8d30ec21e9c7
parent 2387
2d119e79ab54
child 2876
bfa39cf40277
equal deleted inserted replaced
2867:eb325d7f7335 2868:8d30ec21e9c7
30 <h3>Classes</h3> 30 <h3>Classes</h3>
31 <table> 31 <table>
32 <tr> 32 <tr>
33 <td><a href="#Pep8Fixer">Pep8Fixer</a></td> 33 <td><a href="#Pep8Fixer">Pep8Fixer</a></td>
34 <td>Class implementing a fixer for certain PEP 8 issues.</td> 34 <td>Class implementing a fixer for certain PEP 8 issues.</td>
35 </tr><tr>
36 <td><a href="#Pep8Reindenter">Pep8Reindenter</a></td>
37 <td>Class to reindent badly-indented code to uniformly use four-space indentation.</td>
35 </tr> 38 </tr>
36 </table> 39 </table>
37 <h3>Functions</h3> 40 <h3>Functions</h3>
38 <table> 41 <table>
39 <tr><td>None</td></tr> 42 <tr><td>None</td></tr>
61 <td>Constructor</td> 64 <td>Constructor</td>
62 </tr><tr> 65 </tr><tr>
63 <td><a href="#Pep8Fixer.__finalize">__finalize</a></td> 66 <td><a href="#Pep8Fixer.__finalize">__finalize</a></td>
64 <td>Private method to apply all deferred fixes.</td> 67 <td>Private method to apply all deferred fixes.</td>
65 </tr><tr> 68 </tr><tr>
66 <td><a href="#Pep8Fixer.__fixBlankLinesAfterDecorator">__fixBlankLinesAfterDecorator</a></td> 69 <td><a href="#Pep8Fixer.__fixE101">__fixE101</a></td>
67 <td>Private method to fix superfluous blank lines after a function decorator.</td> 70 <td>Private method to fix obsolete tab usage and indentation errors (E101, E111, W191).</td>
68 </tr><tr> 71 </tr><tr>
69 <td><a href="#Pep8Fixer.__fixMissingWhitespaceAfter">__fixMissingWhitespaceAfter</a></td> 72 <td><a href="#Pep8Fixer.__fixE201">__fixE201</a></td>
73 <td>Private method to fix extraneous whitespace (E201, E202, E203, E211).</td>
74 </tr><tr>
75 <td><a href="#Pep8Fixer.__fixE221">__fixE221</a></td>
76 <td>Private method to fix extraneous whitespace around operator or keyword (E221, E222, E223, E224, E225, E226, E227, E228, E241, E242, E271, E272, E273, E274).</td>
77 </tr><tr>
78 <td><a href="#Pep8Fixer.__fixE231">__fixE231</a></td>
70 <td>Private method to fix missing whitespace after ',;:'.</td> 79 <td>Private method to fix missing whitespace after ',;:'.</td>
71 </tr><tr> 80 </tr><tr>
72 <td><a href="#Pep8Fixer.__fixMissingWhitespaceAroundOperator">__fixMissingWhitespaceAroundOperator</a></td> 81 <td><a href="#Pep8Fixer.__fixE251">__fixE251</a></td>
73 <td>Private method to fix missing whitespace after ',;:'.</td> 82 <td>Private method to fix extraneous whitespace around keyword and default parameter equals (E251).</td>
74 </tr><tr> 83 </tr><tr>
75 <td><a href="#Pep8Fixer.__fixNewline">__fixNewline</a></td> 84 <td><a href="#Pep8Fixer.__fixE261">__fixE261</a></td>
76 <td>Private method to fix a missing newline at the end of file.</td> 85 <td>Private method to fix whitespace before or after inline comment (E261, E262).</td>
77 </tr><tr> 86 </tr><tr>
78 <td><a href="#Pep8Fixer.__fixNotEqual">__fixNotEqual</a></td> 87 <td><a href="#Pep8Fixer.__fixE301">__fixE301</a></td>
79 <td>Private method to fix the not equal notation.</td> 88 <td>Private method to fix the need for one blank line (E301).</td>
80 </tr><tr> 89 </tr><tr>
81 <td><a href="#Pep8Fixer.__fixOneBlankLine">__fixOneBlankLine</a></td> 90 <td><a href="#Pep8Fixer.__fixE302">__fixE302</a></td>
82 <td>Private method to fix the need for one blank line.</td> 91 <td>Private method to fix the need for two blank lines (E302).</td>
83 </tr><tr> 92 </tr><tr>
84 <td><a href="#Pep8Fixer.__fixTabs">__fixTabs</a></td> 93 <td><a href="#Pep8Fixer.__fixE303">__fixE303</a></td>
85 <td>Private method to fix obsolete tab usage.</td> 94 <td>Private method to fix superfluous blank lines (E303).</td>
86 </tr><tr> 95 </tr><tr>
87 <td><a href="#Pep8Fixer.__fixTooManyBlankLines">__fixTooManyBlankLines</a></td> 96 <td><a href="#Pep8Fixer.__fixE304">__fixE304</a></td>
88 <td>Private method to fix superfluous blank lines.</td> 97 <td>Private method to fix superfluous blank lines after a function decorator (E304).</td>
89 </tr><tr> 98 </tr><tr>
90 <td><a href="#Pep8Fixer.__fixTrailingBlankLines">__fixTrailingBlankLines</a></td> 99 <td><a href="#Pep8Fixer.__fixE401">__fixE401</a></td>
91 <td>Private method to fix trailing blank lines.</td> 100 <td>Private method to fix multiple imports on one line (E401).</td>
92 </tr><tr> 101 </tr><tr>
93 <td><a href="#Pep8Fixer.__fixTwoBlankLines">__fixTwoBlankLines</a></td> 102 <td><a href="#Pep8Fixer.__fixE502">__fixE502</a></td>
94 <td>Private method to fix the need for two blank lines.</td> 103 <td>Private method to fix redundant backslash within brackets (E502).</td>
104 </tr><tr>
105 <td><a href="#Pep8Fixer.__fixE701">__fixE701</a></td>
106 <td>Private method to fix colon-separated compund statements (E701).</td>
107 </tr><tr>
108 <td><a href="#Pep8Fixer.__fixE702">__fixE702</a></td>
109 <td>Private method to fix semicolon-separated compound statements (E702, E703).</td>
110 </tr><tr>
111 <td><a href="#Pep8Fixer.__fixE711">__fixE711</a></td>
112 <td>Private method to fix comparison with None (E711, E712).</td>
113 </tr><tr>
114 <td><a href="#Pep8Fixer.__fixW291">__fixW291</a></td>
115 <td>Private method to fix trailing whitespace (W291, W293).</td>
116 </tr><tr>
117 <td><a href="#Pep8Fixer.__fixW292">__fixW292</a></td>
118 <td>Private method to fix a missing newline at the end of file (W292).</td>
119 </tr><tr>
120 <td><a href="#Pep8Fixer.__fixW391">__fixW391</a></td>
121 <td>Private method to fix trailing blank lines (W391).</td>
122 </tr><tr>
123 <td><a href="#Pep8Fixer.__fixW603">__fixW603</a></td>
124 <td>Private method to fix the not equal notation (W603).</td>
95 </tr><tr> 125 </tr><tr>
96 <td><a href="#Pep8Fixer.__fixWhitespace">__fixWhitespace</a></td> 126 <td><a href="#Pep8Fixer.__fixWhitespace">__fixWhitespace</a></td>
97 <td>Private method to fix trailing whitespace.</td> 127 <td>Private method to correct whitespace at the given offset.</td>
98 </tr><tr>
99 <td><a href="#Pep8Fixer.__fixWhitespaceAfter">__fixWhitespaceAfter</a></td>
100 <td>Private method to fix superfluous whitespace after '([{'.</td>
101 </tr><tr>
102 <td><a href="#Pep8Fixer.__fixWhitespaceAfterInline">__fixWhitespaceAfterInline</a></td>
103 <td>Private method to fix whitespace after inline comment.</td>
104 </tr><tr>
105 <td><a href="#Pep8Fixer.__fixWhitespaceAroundEquals">__fixWhitespaceAroundEquals</a></td>
106 <td>Private method to fix extraneous whitespace around keyword and default parameter equals.</td>
107 </tr><tr>
108 <td><a href="#Pep8Fixer.__fixWhitespaceAroundOperator">__fixWhitespaceAroundOperator</a></td>
109 <td>Private method to fix extraneous whitespace around operator.</td>
110 </tr><tr>
111 <td><a href="#Pep8Fixer.__fixWhitespaceBefore">__fixWhitespaceBefore</a></td>
112 <td>Private method to fix superfluous whitespace before '}])', ',;:' and '(['.</td>
113 </tr><tr>
114 <td><a href="#Pep8Fixer.__fixWhitespaceBeforeInline">__fixWhitespaceBeforeInline</a></td>
115 <td>Private method to fix missing whitespace before inline comment.</td>
116 </tr><tr> 128 </tr><tr>
117 <td><a href="#Pep8Fixer.__getEol">__getEol</a></td> 129 <td><a href="#Pep8Fixer.__getEol">__getEol</a></td>
118 <td>Private method to get the applicable eol string.</td> 130 <td>Private method to get the applicable eol string.</td>
131 </tr><tr>
132 <td><a href="#Pep8Fixer.__getIndent">__getIndent</a></td>
133 <td>Private method to get the indentation string.</td>
134 </tr><tr>
135 <td><a href="#Pep8Fixer.__getIndentWord">__getIndentWord</a></td>
136 <td>Private method to determine the indentation type.</td>
119 </tr><tr> 137 </tr><tr>
120 <td><a href="#Pep8Fixer.fixIssue">fixIssue</a></td> 138 <td><a href="#Pep8Fixer.fixIssue">fixIssue</a></td>
121 <td>Public method to fix the fixable issues.</td> 139 <td>Public method to fix the fixable issues.</td>
122 </tr><tr> 140 </tr><tr>
123 <td><a href="#Pep8Fixer.saveFile">saveFile</a></td> 141 <td><a href="#Pep8Fixer.saveFile">saveFile</a></td>
155 </dl><a NAME="Pep8Fixer.__finalize" ID="Pep8Fixer.__finalize"></a> 173 </dl><a NAME="Pep8Fixer.__finalize" ID="Pep8Fixer.__finalize"></a>
156 <h4>Pep8Fixer.__finalize</h4> 174 <h4>Pep8Fixer.__finalize</h4>
157 <b>__finalize</b>(<i></i>) 175 <b>__finalize</b>(<i></i>)
158 <p> 176 <p>
159 Private method to apply all deferred fixes. 177 Private method to apply all deferred fixes.
160 </p><a NAME="Pep8Fixer.__fixBlankLinesAfterDecorator" ID="Pep8Fixer.__fixBlankLinesAfterDecorator"></a> 178 </p><a NAME="Pep8Fixer.__fixE101" ID="Pep8Fixer.__fixE101"></a>
161 <h4>Pep8Fixer.__fixBlankLinesAfterDecorator</h4> 179 <h4>Pep8Fixer.__fixE101</h4>
162 <b>__fixBlankLinesAfterDecorator</b>(<i>code, line, pos, apply=False</i>) 180 <b>__fixE101</b>(<i>code, line, pos</i>)
163 <p> 181 <p>
164 Private method to fix superfluous blank lines after a function 182 Private method to fix obsolete tab usage and indentation errors
165 decorator. 183 (E101, E111, W191).
184 </p><dl>
185 <dt><i>code</i></dt>
186 <dd>
187 code of the issue (string)
188 </dd><dt><i>line</i></dt>
189 <dd>
190 line number of the issue (integer)
191 </dd><dt><i>pos</i></dt>
192 <dd>
193 position inside line (integer)
194 </dd>
195 </dl><dl>
196 <dt>Returns:</dt>
197 <dd>
198 flag indicating an applied fix (boolean) and a message for
199 the fix (string)
200 </dd>
201 </dl><a NAME="Pep8Fixer.__fixE201" ID="Pep8Fixer.__fixE201"></a>
202 <h4>Pep8Fixer.__fixE201</h4>
203 <b>__fixE201</b>(<i>code, line, pos</i>)
204 <p>
205 Private method to fix extraneous whitespace (E201, E202,
206 E203, E211).
207 </p><dl>
208 <dt><i>code</i></dt>
209 <dd>
210 code of the issue (string)
211 </dd><dt><i>line</i></dt>
212 <dd>
213 line number of the issue (integer)
214 </dd><dt><i>pos</i></dt>
215 <dd>
216 position inside line (integer)
217 </dd>
218 </dl><dl>
219 <dt>Returns:</dt>
220 <dd>
221 flag indicating an applied fix (boolean) and a message for
222 the fix (string)
223 </dd>
224 </dl><a NAME="Pep8Fixer.__fixE221" ID="Pep8Fixer.__fixE221"></a>
225 <h4>Pep8Fixer.__fixE221</h4>
226 <b>__fixE221</b>(<i>code, line, pos</i>)
227 <p>
228 Private method to fix extraneous whitespace around operator or
229 keyword (E221, E222, E223, E224, E225, E226, E227, E228, E241,
230 E242, E271, E272, E273, E274).
231 </p><dl>
232 <dt><i>code</i></dt>
233 <dd>
234 code of the issue (string)
235 </dd><dt><i>line</i></dt>
236 <dd>
237 line number of the issue (integer)
238 </dd><dt><i>pos</i></dt>
239 <dd>
240 position inside line (integer)
241 </dd>
242 </dl><dl>
243 <dt>Returns:</dt>
244 <dd>
245 flag indicating an applied fix (boolean) and a message for
246 the fix (string)
247 </dd>
248 </dl><a NAME="Pep8Fixer.__fixE231" ID="Pep8Fixer.__fixE231"></a>
249 <h4>Pep8Fixer.__fixE231</h4>
250 <b>__fixE231</b>(<i>code, line, pos</i>)
251 <p>
252 Private method to fix missing whitespace after ',;:'.
253 </p><dl>
254 <dt><i>code</i></dt>
255 <dd>
256 code of the issue (string)
257 </dd><dt><i>line</i></dt>
258 <dd>
259 line number of the issue (integer)
260 </dd><dt><i>pos</i></dt>
261 <dd>
262 position inside line (integer)
263 </dd>
264 </dl><dl>
265 <dt>Returns:</dt>
266 <dd>
267 flag indicating an applied fix (boolean) and a message for
268 the fix (string)
269 </dd>
270 </dl><a NAME="Pep8Fixer.__fixE251" ID="Pep8Fixer.__fixE251"></a>
271 <h4>Pep8Fixer.__fixE251</h4>
272 <b>__fixE251</b>(<i>code, line, pos</i>)
273 <p>
274 Private method to fix extraneous whitespace around keyword and
275 default parameter equals (E251).
276 </p><dl>
277 <dt><i>code</i></dt>
278 <dd>
279 code of the issue (string)
280 </dd><dt><i>line</i></dt>
281 <dd>
282 line number of the issue (integer)
283 </dd><dt><i>pos</i></dt>
284 <dd>
285 position inside line (integer)
286 </dd>
287 </dl><dl>
288 <dt>Returns:</dt>
289 <dd>
290 flag indicating an applied fix (boolean) and a message for
291 the fix (string)
292 </dd>
293 </dl><a NAME="Pep8Fixer.__fixE261" ID="Pep8Fixer.__fixE261"></a>
294 <h4>Pep8Fixer.__fixE261</h4>
295 <b>__fixE261</b>(<i>code, line, pos</i>)
296 <p>
297 Private method to fix whitespace before or after inline comment
298 (E261, E262).
299 </p><dl>
300 <dt><i>code</i></dt>
301 <dd>
302 code of the issue (string)
303 </dd><dt><i>line</i></dt>
304 <dd>
305 line number of the issue (integer)
306 </dd><dt><i>pos</i></dt>
307 <dd>
308 position inside line (integer)
309 </dd>
310 </dl><dl>
311 <dt>Returns:</dt>
312 <dd>
313 flag indicating an applied fix (boolean) and a message for
314 the fix (string)
315 </dd>
316 </dl><a NAME="Pep8Fixer.__fixE301" ID="Pep8Fixer.__fixE301"></a>
317 <h4>Pep8Fixer.__fixE301</h4>
318 <b>__fixE301</b>(<i>code, line, pos, apply=False</i>)
319 <p>
320 Private method to fix the need for one blank line (E301).
166 </p><dl> 321 </p><dl>
167 <dt><i>code</i></dt> 322 <dt><i>code</i></dt>
168 <dd> 323 <dd>
169 code of the issue (string) 324 code of the issue (string)
170 </dd><dt><i>line</i></dt> 325 </dd><dt><i>line</i></dt>
182 <dt>Returns:</dt> 337 <dt>Returns:</dt>
183 <dd> 338 <dd>
184 flag indicating an applied fix (boolean) and a message for 339 flag indicating an applied fix (boolean) and a message for
185 the fix (string) 340 the fix (string)
186 </dd> 341 </dd>
187 </dl><a NAME="Pep8Fixer.__fixMissingWhitespaceAfter" ID="Pep8Fixer.__fixMissingWhitespaceAfter"></a> 342 </dl><a NAME="Pep8Fixer.__fixE302" ID="Pep8Fixer.__fixE302"></a>
188 <h4>Pep8Fixer.__fixMissingWhitespaceAfter</h4> 343 <h4>Pep8Fixer.__fixE302</h4>
189 <b>__fixMissingWhitespaceAfter</b>(<i>code, line, pos, apply=False</i>) 344 <b>__fixE302</b>(<i>code, line, pos, apply=False</i>)
190 <p> 345 <p>
191 Private method to fix missing whitespace after ',;:'. 346 Private method to fix the need for two blank lines (E302).
347 </p><a NAME="Pep8Fixer.__fixE303" ID="Pep8Fixer.__fixE303"></a>
348 <h4>Pep8Fixer.__fixE303</h4>
349 <b>__fixE303</b>(<i>code, line, pos, apply=False</i>)
350 <p>
351 Private method to fix superfluous blank lines (E303).
192 </p><dl> 352 </p><dl>
193 <dt><i>code</i></dt> 353 <dt><i>code</i></dt>
194 <dd> 354 <dd>
195 code of the issue (string) 355 code of the issue (string)
196 </dd><dt><i>line</i></dt> 356 </dd><dt><i>line</i></dt>
208 <dt>Returns:</dt> 368 <dt>Returns:</dt>
209 <dd> 369 <dd>
210 flag indicating an applied fix (boolean) and a message for 370 flag indicating an applied fix (boolean) and a message for
211 the fix (string) 371 the fix (string)
212 </dd> 372 </dd>
213 </dl><a NAME="Pep8Fixer.__fixMissingWhitespaceAroundOperator" ID="Pep8Fixer.__fixMissingWhitespaceAroundOperator"></a> 373 </dl><a NAME="Pep8Fixer.__fixE304" ID="Pep8Fixer.__fixE304"></a>
214 <h4>Pep8Fixer.__fixMissingWhitespaceAroundOperator</h4> 374 <h4>Pep8Fixer.__fixE304</h4>
215 <b>__fixMissingWhitespaceAroundOperator</b>(<i>code, line, pos, apply=False</i>) 375 <b>__fixE304</b>(<i>code, line, pos, apply=False</i>)
216 <p> 376 <p>
217 Private method to fix missing whitespace after ',;:'. 377 Private method to fix superfluous blank lines after a function
378 decorator (E304).
218 </p><dl> 379 </p><dl>
219 <dt><i>code</i></dt> 380 <dt><i>code</i></dt>
220 <dd> 381 <dd>
221 code of the issue (string) 382 code of the issue (string)
222 </dd><dt><i>line</i></dt> 383 </dd><dt><i>line</i></dt>
234 <dt>Returns:</dt> 395 <dt>Returns:</dt>
235 <dd> 396 <dd>
236 flag indicating an applied fix (boolean) and a message for 397 flag indicating an applied fix (boolean) and a message for
237 the fix (string) 398 the fix (string)
238 </dd> 399 </dd>
239 </dl><a NAME="Pep8Fixer.__fixNewline" ID="Pep8Fixer.__fixNewline"></a> 400 </dl><a NAME="Pep8Fixer.__fixE401" ID="Pep8Fixer.__fixE401"></a>
240 <h4>Pep8Fixer.__fixNewline</h4> 401 <h4>Pep8Fixer.__fixE401</h4>
241 <b>__fixNewline</b>(<i>code, line, pos</i>) 402 <b>__fixE401</b>(<i>code, line, pos, apply=False</i>)
242 <p> 403 <p>
243 Private method to fix a missing newline at the end of file. 404 Private method to fix multiple imports on one line (E401).
244 </p><dl>
245 <dt><i>code</i></dt>
246 <dd>
247 code of the issue (string)
248 </dd><dt><i>line</i></dt>
249 <dd>
250 line number of the issue (integer)
251 </dd><dt><i>pos</i></dt>
252 <dd>
253 position inside line (integer)
254 </dd>
255 </dl><dl>
256 <dt>Returns:</dt>
257 <dd>
258 flag indicating an applied fix (boolean) and a message for
259 the fix (string)
260 </dd>
261 </dl><a NAME="Pep8Fixer.__fixNotEqual" ID="Pep8Fixer.__fixNotEqual"></a>
262 <h4>Pep8Fixer.__fixNotEqual</h4>
263 <b>__fixNotEqual</b>(<i>code, line, pos</i>)
264 <p>
265 Private method to fix the not equal notation.
266 </p><dl>
267 <dt><i>code</i></dt>
268 <dd>
269 code of the issue (string)
270 </dd><dt><i>line</i></dt>
271 <dd>
272 line number of the issue (integer)
273 </dd><dt><i>pos</i></dt>
274 <dd>
275 position inside line (integer)
276 </dd>
277 </dl><dl>
278 <dt>Returns:</dt>
279 <dd>
280 flag indicating an applied fix (boolean) and a message for
281 the fix (string)
282 </dd>
283 </dl><a NAME="Pep8Fixer.__fixOneBlankLine" ID="Pep8Fixer.__fixOneBlankLine"></a>
284 <h4>Pep8Fixer.__fixOneBlankLine</h4>
285 <b>__fixOneBlankLine</b>(<i>code, line, pos, apply=False</i>)
286 <p>
287 Private method to fix the need for one blank line.
288 </p><dl> 405 </p><dl>
289 <dt><i>code</i></dt> 406 <dt><i>code</i></dt>
290 <dd> 407 <dd>
291 code of the issue (string) 408 code of the issue (string)
292 </dd><dt><i>line</i></dt> 409 </dd><dt><i>line</i></dt>
304 <dt>Returns:</dt> 421 <dt>Returns:</dt>
305 <dd> 422 <dd>
306 flag indicating an applied fix (boolean) and a message for 423 flag indicating an applied fix (boolean) and a message for
307 the fix (string) 424 the fix (string)
308 </dd> 425 </dd>
309 </dl><a NAME="Pep8Fixer.__fixTabs" ID="Pep8Fixer.__fixTabs"></a> 426 </dl><a NAME="Pep8Fixer.__fixE502" ID="Pep8Fixer.__fixE502"></a>
310 <h4>Pep8Fixer.__fixTabs</h4> 427 <h4>Pep8Fixer.__fixE502</h4>
311 <b>__fixTabs</b>(<i>code, line, pos</i>) 428 <b>__fixE502</b>(<i>code, line, pos</i>)
312 <p> 429 <p>
313 Private method to fix obsolete tab usage. 430 Private method to fix redundant backslash within brackets (E502).
314 </p><dl> 431 </p><dl>
315 <dt><i>code</i></dt> 432 <dt><i>code</i></dt>
316 <dd> 433 <dd>
317 code of the issue (string) 434 code of the issue (string)
318 </dd><dt><i>line</i></dt> 435 </dd><dt><i>line</i></dt>
319 <dd> 436 <dd>
320 line number of the issue (integer) 437 line number of the issue (integer)
321 </dd><dt><i>pos</i></dt> 438 </dd><dt><i>pos</i></dt>
322 <dd> 439 <dd>
323 position inside line (integer) 440 position inside line (integer)
324 </dd> 441 </dd>
325 </dl><dl> 442 </dl><dl>
326 <dt>Returns:</dt> 443 <dt>Returns:</dt>
327 <dd> 444 <dd>
328 flag indicating an applied fix (boolean) and a message for 445 flag indicating an applied fix (boolean) and a message for
329 the fix (string) 446 the fix (string)
330 </dd> 447 </dd>
331 </dl><a NAME="Pep8Fixer.__fixTooManyBlankLines" ID="Pep8Fixer.__fixTooManyBlankLines"></a> 448 </dl><a NAME="Pep8Fixer.__fixE701" ID="Pep8Fixer.__fixE701"></a>
332 <h4>Pep8Fixer.__fixTooManyBlankLines</h4> 449 <h4>Pep8Fixer.__fixE701</h4>
333 <b>__fixTooManyBlankLines</b>(<i>code, line, pos, apply=False</i>) 450 <b>__fixE701</b>(<i>code, line, pos, apply=False</i>)
334 <p> 451 <p>
335 Private method to fix superfluous blank lines. 452 Private method to fix colon-separated compund statements (E701).
336 </p><dl> 453 </p><dl>
337 <dt><i>code</i></dt> 454 <dt><i>code</i></dt>
338 <dd> 455 <dd>
339 code of the issue (string) 456 code of the issue (string)
340 </dd><dt><i>line</i></dt> 457 </dd><dt><i>line</i></dt>
352 <dt>Returns:</dt> 469 <dt>Returns:</dt>
353 <dd> 470 <dd>
354 flag indicating an applied fix (boolean) and a message for 471 flag indicating an applied fix (boolean) and a message for
355 the fix (string) 472 the fix (string)
356 </dd> 473 </dd>
357 </dl><a NAME="Pep8Fixer.__fixTrailingBlankLines" ID="Pep8Fixer.__fixTrailingBlankLines"></a> 474 </dl><a NAME="Pep8Fixer.__fixE702" ID="Pep8Fixer.__fixE702"></a>
358 <h4>Pep8Fixer.__fixTrailingBlankLines</h4> 475 <h4>Pep8Fixer.__fixE702</h4>
359 <b>__fixTrailingBlankLines</b>(<i>code, line, pos</i>) 476 <b>__fixE702</b>(<i>code, line, pos, apply=False</i>)
360 <p> 477 <p>
361 Private method to fix trailing blank lines. 478 Private method to fix semicolon-separated compound statements
362 </p><dl> 479 (E702, E703).
363 <dt><i>code</i></dt>
364 <dd>
365 code of the issue (string)
366 </dd><dt><i>line</i></dt>
367 <dd>
368 line number of the issue (integer)
369 </dd><dt><i>pos</i></dt>
370 <dd>
371 position inside line (integer)
372 </dd>
373 </dl><dl>
374 <dt>Returns:</dt>
375 <dd>
376 flag indicating an applied fix (boolean) and a message for
377 the fix (string)
378 </dd>
379 </dl><a NAME="Pep8Fixer.__fixTwoBlankLines" ID="Pep8Fixer.__fixTwoBlankLines"></a>
380 <h4>Pep8Fixer.__fixTwoBlankLines</h4>
381 <b>__fixTwoBlankLines</b>(<i>code, line, pos, apply=False</i>)
382 <p>
383 Private method to fix the need for two blank lines.
384 </p><a NAME="Pep8Fixer.__fixWhitespace" ID="Pep8Fixer.__fixWhitespace"></a>
385 <h4>Pep8Fixer.__fixWhitespace</h4>
386 <b>__fixWhitespace</b>(<i>code, line, pos</i>)
387 <p>
388 Private method to fix trailing whitespace.
389 </p><dl>
390 <dt><i>code</i></dt>
391 <dd>
392 code of the issue (string)
393 </dd><dt><i>line</i></dt>
394 <dd>
395 line number of the issue (integer)
396 </dd><dt><i>pos</i></dt>
397 <dd>
398 position inside line (integer)
399 </dd>
400 </dl><dl>
401 <dt>Returns:</dt>
402 <dd>
403 flag indicating an applied fix (boolean) and a message for
404 the fix (string)
405 </dd>
406 </dl><a NAME="Pep8Fixer.__fixWhitespaceAfter" ID="Pep8Fixer.__fixWhitespaceAfter"></a>
407 <h4>Pep8Fixer.__fixWhitespaceAfter</h4>
408 <b>__fixWhitespaceAfter</b>(<i>code, line, pos, apply=False</i>)
409 <p>
410 Private method to fix superfluous whitespace after '([{'.
411 </p><dl> 480 </p><dl>
412 <dt><i>code</i></dt> 481 <dt><i>code</i></dt>
413 <dd> 482 <dd>
414 code of the issue (string) 483 code of the issue (string)
415 </dd><dt><i>line</i></dt> 484 </dd><dt><i>line</i></dt>
427 <dt>Returns:</dt> 496 <dt>Returns:</dt>
428 <dd> 497 <dd>
429 flag indicating an applied fix (boolean) and a message for 498 flag indicating an applied fix (boolean) and a message for
430 the fix (string) 499 the fix (string)
431 </dd> 500 </dd>
432 </dl><a NAME="Pep8Fixer.__fixWhitespaceAfterInline" ID="Pep8Fixer.__fixWhitespaceAfterInline"></a> 501 </dl><a NAME="Pep8Fixer.__fixE711" ID="Pep8Fixer.__fixE711"></a>
433 <h4>Pep8Fixer.__fixWhitespaceAfterInline</h4> 502 <h4>Pep8Fixer.__fixE711</h4>
434 <b>__fixWhitespaceAfterInline</b>(<i>code, line, pos, apply=False</i>) 503 <b>__fixE711</b>(<i>code, line, pos</i>)
435 <p> 504 <p>
436 Private method to fix whitespace after inline comment. 505 Private method to fix comparison with None (E711, E712).
437 </p><dl> 506 </p><dl>
438 <dt><i>code</i></dt> 507 <dt><i>code</i></dt>
439 <dd> 508 <dd>
440 code of the issue (string) 509 code of the issue (string)
441 </dd><dt><i>line</i></dt> 510 </dd><dt><i>line</i></dt>
442 <dd> 511 <dd>
443 line number of the issue (integer) 512 line number of the issue (integer)
444 </dd><dt><i>pos</i></dt> 513 </dd><dt><i>pos</i></dt>
445 <dd> 514 <dd>
446 position inside line (integer) 515 position inside line (integer)
447 </dd><dt><i>apply=</i></dt> 516 </dd>
448 <dd> 517 </dl><dl>
449 flag indicating, that the fix should be applied 518 <dt>Returns:</dt>
450 (boolean) 519 <dd>
451 </dd> 520 flag indicating an applied fix (boolean) and a message for
452 </dl><dl> 521 the fix (string)
453 <dt>Returns:</dt> 522 </dd>
454 <dd> 523 </dl><a NAME="Pep8Fixer.__fixW291" ID="Pep8Fixer.__fixW291"></a>
455 flag indicating an applied fix (boolean) and a message for 524 <h4>Pep8Fixer.__fixW291</h4>
456 the fix (string) 525 <b>__fixW291</b>(<i>code, line, pos</i>)
457 </dd> 526 <p>
458 </dl><a NAME="Pep8Fixer.__fixWhitespaceAroundEquals" ID="Pep8Fixer.__fixWhitespaceAroundEquals"></a> 527 Private method to fix trailing whitespace (W291, W293).
459 <h4>Pep8Fixer.__fixWhitespaceAroundEquals</h4> 528 </p><dl>
460 <b>__fixWhitespaceAroundEquals</b>(<i>code, line, pos, apply=False</i>) 529 <dt><i>code</i></dt>
461 <p> 530 <dd>
462 Private method to fix extraneous whitespace around keyword and 531 code of the issue (string)
463 default parameter equals. 532 </dd><dt><i>line</i></dt>
464 </p><dl> 533 <dd>
465 <dt><i>code</i></dt> 534 line number of the issue (integer)
466 <dd> 535 </dd><dt><i>pos</i></dt>
467 code of the issue (string) 536 <dd>
468 </dd><dt><i>line</i></dt> 537 position inside line (integer)
469 <dd> 538 </dd>
470 line number of the issue (integer) 539 </dl><dl>
471 </dd><dt><i>pos</i></dt> 540 <dt>Returns:</dt>
472 <dd> 541 <dd>
473 position inside line (integer) 542 flag indicating an applied fix (boolean) and a message for
474 </dd><dt><i>apply=</i></dt> 543 the fix (string)
475 <dd> 544 </dd>
476 flag indicating, that the fix should be applied 545 </dl><a NAME="Pep8Fixer.__fixW292" ID="Pep8Fixer.__fixW292"></a>
477 (boolean) 546 <h4>Pep8Fixer.__fixW292</h4>
478 </dd> 547 <b>__fixW292</b>(<i>code, line, pos</i>)
479 </dl><dl> 548 <p>
480 <dt>Returns:</dt> 549 Private method to fix a missing newline at the end of file (W292).
481 <dd> 550 </p><dl>
482 flag indicating an applied fix (boolean) and a message for 551 <dt><i>code</i></dt>
483 the fix (string) 552 <dd>
484 </dd> 553 code of the issue (string)
485 </dl><a NAME="Pep8Fixer.__fixWhitespaceAroundOperator" ID="Pep8Fixer.__fixWhitespaceAroundOperator"></a> 554 </dd><dt><i>line</i></dt>
486 <h4>Pep8Fixer.__fixWhitespaceAroundOperator</h4> 555 <dd>
487 <b>__fixWhitespaceAroundOperator</b>(<i>code, line, pos, apply=False</i>) 556 line number of the issue (integer)
488 <p> 557 </dd><dt><i>pos</i></dt>
489 Private method to fix extraneous whitespace around operator. 558 <dd>
490 </p><dl> 559 position inside line (integer)
491 <dt><i>code</i></dt> 560 </dd>
492 <dd> 561 </dl><dl>
493 code of the issue (string) 562 <dt>Returns:</dt>
494 </dd><dt><i>line</i></dt> 563 <dd>
495 <dd> 564 flag indicating an applied fix (boolean) and a message for
496 line number of the issue (integer) 565 the fix (string)
497 </dd><dt><i>pos</i></dt> 566 </dd>
498 <dd> 567 </dl><a NAME="Pep8Fixer.__fixW391" ID="Pep8Fixer.__fixW391"></a>
499 position inside line (integer) 568 <h4>Pep8Fixer.__fixW391</h4>
500 </dd><dt><i>apply=</i></dt> 569 <b>__fixW391</b>(<i>code, line, pos</i>)
501 <dd> 570 <p>
502 flag indicating, that the fix should be applied 571 Private method to fix trailing blank lines (W391).
503 (boolean) 572 </p><dl>
504 </dd> 573 <dt><i>code</i></dt>
505 </dl><dl> 574 <dd>
506 <dt>Returns:</dt> 575 code of the issue (string)
507 <dd> 576 </dd><dt><i>line</i></dt>
508 flag indicating an applied fix (boolean) and a message for 577 <dd>
509 the fix (string) 578 line number of the issue (integer)
510 </dd> 579 </dd><dt><i>pos</i></dt>
511 </dl><a NAME="Pep8Fixer.__fixWhitespaceBefore" ID="Pep8Fixer.__fixWhitespaceBefore"></a> 580 <dd>
512 <h4>Pep8Fixer.__fixWhitespaceBefore</h4> 581 position inside line (integer)
513 <b>__fixWhitespaceBefore</b>(<i>code, line, pos, apply=False</i>) 582 </dd>
514 <p> 583 </dl><dl>
515 Private method to fix superfluous whitespace before '}])', 584 <dt>Returns:</dt>
516 ',;:' and '(['. 585 <dd>
517 </p><dl> 586 flag indicating an applied fix (boolean) and a message for
518 <dt><i>code</i></dt> 587 the fix (string)
519 <dd> 588 </dd>
520 code of the issue (string) 589 </dl><a NAME="Pep8Fixer.__fixW603" ID="Pep8Fixer.__fixW603"></a>
521 </dd><dt><i>line</i></dt> 590 <h4>Pep8Fixer.__fixW603</h4>
522 <dd> 591 <b>__fixW603</b>(<i>code, line, pos</i>)
523 line number of the issue (integer) 592 <p>
524 </dd><dt><i>pos</i></dt> 593 Private method to fix the not equal notation (W603).
525 <dd> 594 </p><dl>
526 position inside line (integer) 595 <dt><i>code</i></dt>
527 </dd><dt><i>apply=</i></dt> 596 <dd>
528 <dd> 597 code of the issue (string)
529 flag indicating, that the fix should be applied 598 </dd><dt><i>line</i></dt>
530 (boolean) 599 <dd>
531 </dd> 600 line number of the issue (integer)
532 </dl><dl> 601 </dd><dt><i>pos</i></dt>
533 <dt>Returns:</dt> 602 <dd>
534 <dd> 603 position inside line (integer)
535 flag indicating an applied fix (boolean) and a message for 604 </dd>
536 the fix (string) 605 </dl><dl>
537 </dd> 606 <dt>Returns:</dt>
538 </dl><a NAME="Pep8Fixer.__fixWhitespaceBeforeInline" ID="Pep8Fixer.__fixWhitespaceBeforeInline"></a> 607 <dd>
539 <h4>Pep8Fixer.__fixWhitespaceBeforeInline</h4> 608 flag indicating an applied fix (boolean) and a message for
540 <b>__fixWhitespaceBeforeInline</b>(<i>code, line, pos, apply=False</i>) 609 the fix (string)
541 <p> 610 </dd>
542 Private method to fix missing whitespace before inline comment. 611 </dl><a NAME="Pep8Fixer.__fixWhitespace" ID="Pep8Fixer.__fixWhitespace"></a>
543 </p><dl> 612 <h4>Pep8Fixer.__fixWhitespace</h4>
544 <dt><i>code</i></dt> 613 <b>__fixWhitespace</b>(<i>line, offset, replacement</i>)
545 <dd> 614 <p>
546 code of the issue (string) 615 Private method to correct whitespace at the given offset.
547 </dd><dt><i>line</i></dt> 616 </p><dl>
548 <dd> 617 <dt><i>line</i></dt>
549 line number of the issue (integer) 618 <dd>
550 </dd><dt><i>pos</i></dt> 619 line to be corrected (string)
551 <dd> 620 </dd><dt><i>offset</i></dt>
552 position inside line (integer) 621 <dd>
553 </dd><dt><i>apply=</i></dt> 622 offset within line (integer)
554 <dd> 623 </dd><dt><i>replacement</i></dt>
555 flag indicating, that the fix should be applied 624 <dd>
556 (boolean) 625 replacement string (string)
557 </dd> 626 </dd>
558 </dl><dl> 627 </dl><dl>
559 <dt>Returns:</dt> 628 <dt>Returns:</dt>
560 <dd> 629 <dd>
561 flag indicating an applied fix (boolean) and a message for 630 corrected line
562 the fix (string)
563 </dd> 631 </dd>
564 </dl><a NAME="Pep8Fixer.__getEol" ID="Pep8Fixer.__getEol"></a> 632 </dl><a NAME="Pep8Fixer.__getEol" ID="Pep8Fixer.__getEol"></a>
565 <h4>Pep8Fixer.__getEol</h4> 633 <h4>Pep8Fixer.__getEol</h4>
566 <b>__getEol</b>(<i></i>) 634 <b>__getEol</b>(<i></i>)
567 <p> 635 <p>
569 </p><dl> 637 </p><dl>
570 <dt>Returns:</dt> 638 <dt>Returns:</dt>
571 <dd> 639 <dd>
572 eol string (string) 640 eol string (string)
573 </dd> 641 </dd>
642 </dl><a NAME="Pep8Fixer.__getIndent" ID="Pep8Fixer.__getIndent"></a>
643 <h4>Pep8Fixer.__getIndent</h4>
644 <b>__getIndent</b>(<i>line</i>)
645 <p>
646 Private method to get the indentation string.
647 </p><dl>
648 <dt><i>line</i></dt>
649 <dd>
650 line to determine the indentation string from (string)
651 </dd>
652 </dl><dl>
653 <dt>Returns:</dt>
654 <dd>
655 indentation string (string)
656 </dd>
657 </dl><a NAME="Pep8Fixer.__getIndentWord" ID="Pep8Fixer.__getIndentWord"></a>
658 <h4>Pep8Fixer.__getIndentWord</h4>
659 <b>__getIndentWord</b>(<i></i>)
660 <p>
661 Private method to determine the indentation type.
662 </p><dl>
663 <dt>Returns:</dt>
664 <dd>
665 string to be used for an indentation (string)
666 </dd>
574 </dl><a NAME="Pep8Fixer.fixIssue" ID="Pep8Fixer.fixIssue"></a> 667 </dl><a NAME="Pep8Fixer.fixIssue" ID="Pep8Fixer.fixIssue"></a>
575 <h4>Pep8Fixer.fixIssue</h4> 668 <h4>Pep8Fixer.fixIssue</h4>
576 <b>fixIssue</b>(<i>line, pos, message</i>) 669 <b>fixIssue</b>(<i>line, pos, message</i>)
577 <p> 670 <p>
578 Public method to fix the fixable issues. 671 Public method to fix the fixable issues.
608 <dd> 701 <dd>
609 flag indicating success (boolean) 702 flag indicating success (boolean)
610 </dd> 703 </dd>
611 </dl> 704 </dl>
612 <div align="right"><a href="#top">Up</a></div> 705 <div align="right"><a href="#top">Up</a></div>
706 <hr /><hr />
707 <a NAME="Pep8Reindenter" ID="Pep8Reindenter"></a>
708 <h2>Pep8Reindenter</h2>
709 <p>
710 Class to reindent badly-indented code to uniformly use four-space indentation.
711 </p><p>
712 Released to the public domain, by Tim Peters, 03 October 2000.
713 </p>
714 <h3>Derived from</h3>
715 object
716 <h3>Class Attributes</h3>
717 <table>
718 <tr><td>None</td></tr>
719 </table>
720 <h3>Class Methods</h3>
721 <table>
722 <tr><td>None</td></tr>
723 </table>
724 <h3>Methods</h3>
725 <table>
726 <tr>
727 <td><a href="#Pep8Reindenter.__init__">Pep8Reindenter</a></td>
728 <td>Constructor</td>
729 </tr><tr>
730 <td><a href="#Pep8Reindenter.__genStats">__genStats</a></td>
731 <td>Private method to generate the re-indent statistics.</td>
732 </tr><tr>
733 <td><a href="#Pep8Reindenter.__getlspace">__getlspace</a></td>
734 <td>Private method to count number of leading blanks.</td>
735 </tr><tr>
736 <td><a href="#Pep8Reindenter.fixedLine">fixedLine</a></td>
737 <td>Public method to get a fixed line.</td>
738 </tr><tr>
739 <td><a href="#Pep8Reindenter.getline">getline</a></td>
740 <td>Public method to get a line of text for tokenize.</td>
741 </tr><tr>
742 <td><a href="#Pep8Reindenter.run">run</a></td>
743 <td>Public method to run the re-indenter.</td>
744 </tr>
745 </table>
746 <h3>Static Methods</h3>
747 <table>
748 <tr><td>None</td></tr>
749 </table>
750 <a NAME="Pep8Reindenter.__init__" ID="Pep8Reindenter.__init__"></a>
751 <h4>Pep8Reindenter (Constructor)</h4>
752 <b>Pep8Reindenter</b>(<i>sourceLines</i>)
753 <p>
754 Constructor
755 </p><dl>
756 <dt><i>sourceLines</i></dt>
757 <dd>
758 list of source lines including eol marker
759 (list of string)
760 </dd>
761 </dl><a NAME="Pep8Reindenter.__genStats" ID="Pep8Reindenter.__genStats"></a>
762 <h4>Pep8Reindenter.__genStats</h4>
763 <b>__genStats</b>(<i>tokens</i>)
764 <p>
765 Private method to generate the re-indent statistics.
766 </p><dl>
767 <dt><i>tokens</i></dt>
768 <dd>
769 tokens generator (tokenize._tokenize)
770 </dd>
771 </dl><a NAME="Pep8Reindenter.__getlspace" ID="Pep8Reindenter.__getlspace"></a>
772 <h4>Pep8Reindenter.__getlspace</h4>
773 <b>__getlspace</b>(<i>line</i>)
774 <p>
775 Private method to count number of leading blanks.
776 </p><dl>
777 <dt><i>line</i></dt>
778 <dd>
779 line to check (string)
780 </dd>
781 </dl><dl>
782 <dt>Returns:</dt>
783 <dd>
784 number of leading blanks (integer)
785 </dd>
786 </dl><a NAME="Pep8Reindenter.fixedLine" ID="Pep8Reindenter.fixedLine"></a>
787 <h4>Pep8Reindenter.fixedLine</h4>
788 <b>fixedLine</b>(<i>line</i>)
789 <p>
790 Public method to get a fixed line.
791 </p><dl>
792 <dt><i>line</i></dt>
793 <dd>
794 number of the line to retrieve (integer)
795 </dd>
796 </dl><dl>
797 <dt>Returns:</dt>
798 <dd>
799 fixed line (string)
800 </dd>
801 </dl><a NAME="Pep8Reindenter.getline" ID="Pep8Reindenter.getline"></a>
802 <h4>Pep8Reindenter.getline</h4>
803 <b>getline</b>(<i></i>)
804 <p>
805 Public method to get a line of text for tokenize.
806 </p><dl>
807 <dt>Returns:</dt>
808 <dd>
809 line of text (string)
810 </dd>
811 </dl><a NAME="Pep8Reindenter.run" ID="Pep8Reindenter.run"></a>
812 <h4>Pep8Reindenter.run</h4>
813 <b>run</b>(<i></i>)
814 <p>
815 Public method to run the re-indenter.
816 </p>
817 <div align="right"><a href="#top">Up</a></div>
613 <hr /> 818 <hr />
614 </body></html> 819 </body></html>

eric ide

mercurial