Documentation/Source/eric5.Plugins.CheckerPlugins.CodeStyleChecker.CodeStyleFixer.html

changeset 2985
177b1858245f
child 3209
c5432abceb25
equal deleted inserted replaced
2984:031cceaa8b01 2985:177b1858245f
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric5.Plugins.CheckerPlugins.CodeStyleChecker.CodeStyleFixer</title>
4 <meta charset="UTF-8">
5 <style>
6 body {
7 background: #EDECE6;
8 margin: 0em 1em 10em 1em;
9 color: black;
10 }
11
12 h1 { color: white; background: #85774A; }
13 h2 { color: white; background: #85774A; }
14 h3 { color: white; background: #9D936E; }
15 h4 { color: white; background: #9D936E; }
16
17 a { color: #BA6D36; }
18
19 </style>
20 </head>
21 <body><a NAME="top" ID="top"></a>
22 <h1>eric5.Plugins.CheckerPlugins.CodeStyleChecker.CodeStyleFixer</h1>
23 <p>
24 Module implementing a class to fix certain code style issues.
25 </p>
26 <h3>Global Attributes</h3>
27 <table>
28 <tr><td>FixableCodeStyleIssues</td></tr>
29 </table>
30 <h3>Classes</h3>
31 <table>
32 <tr>
33 <td><a href="#CodeStyleFixer">CodeStyleFixer</a></td>
34 <td>Class implementing a fixer for certain code style issues.</td>
35 </tr><tr>
36 <td><a href="#IndentationWrapper">IndentationWrapper</a></td>
37 <td>Class used by fixers dealing with indentation.</td>
38 </tr><tr>
39 <td><a href="#LineShortener">LineShortener</a></td>
40 <td>Class used to shorten lines to a given maximum of characters.</td>
41 </tr><tr>
42 <td><a href="#Reindenter">Reindenter</a></td>
43 <td>Class to reindent badly-indented code to uniformly use four-space indentation.</td>
44 </tr>
45 </table>
46 <h3>Functions</h3>
47 <table>
48 <tr><td>None</td></tr>
49 </table>
50 <hr /><hr />
51 <a NAME="CodeStyleFixer" ID="CodeStyleFixer"></a>
52 <h2>CodeStyleFixer</h2>
53 <p>
54 Class implementing a fixer for certain code style issues.
55 </p>
56 <h3>Derived from</h3>
57 QObject
58 <h3>Class Attributes</h3>
59 <table>
60 <tr><td>None</td></tr>
61 </table>
62 <h3>Class Methods</h3>
63 <table>
64 <tr><td>None</td></tr>
65 </table>
66 <h3>Methods</h3>
67 <table>
68 <tr>
69 <td><a href="#CodeStyleFixer.__init__">CodeStyleFixer</a></td>
70 <td>Constructor</td>
71 </tr><tr>
72 <td><a href="#CodeStyleFixer.__codeMatch">__codeMatch</a></td>
73 <td>Private method to check, if the code should be fixed.</td>
74 </tr><tr>
75 <td><a href="#CodeStyleFixer.__findLogical">__findLogical</a></td>
76 <td>Private method to extract the index of all the starts and ends of lines.</td>
77 </tr><tr>
78 <td><a href="#CodeStyleFixer.__fixD111">__fixD111</a></td>
79 <td>Private method to fix docstring enclosed in wrong quotes.</td>
80 </tr><tr>
81 <td><a href="#CodeStyleFixer.__fixD112">__fixD112</a></td>
82 <td>Private method to fix docstring 'r' or 'u' in leading quotes.</td>
83 </tr><tr>
84 <td><a href="#CodeStyleFixer.__fixD121">__fixD121</a></td>
85 <td>Private method to fix a single line docstring on multiple lines.</td>
86 </tr><tr>
87 <td><a href="#CodeStyleFixer.__fixD131">__fixD131</a></td>
88 <td>Private method to fix a docstring summary not ending with a period.</td>
89 </tr><tr>
90 <td><a href="#CodeStyleFixer.__fixD141">__fixD141</a></td>
91 <td>Private method to fix a function/method docstring preceded by a blank line.</td>
92 </tr><tr>
93 <td><a href="#CodeStyleFixer.__fixD142">__fixD142</a></td>
94 <td>Private method to fix a class docstring not preceded by a blank line.</td>
95 </tr><tr>
96 <td><a href="#CodeStyleFixer.__fixD143">__fixD143</a></td>
97 <td>Private method to fix a class docstring not followed by a blank line.</td>
98 </tr><tr>
99 <td><a href="#CodeStyleFixer.__fixD144">__fixD144</a></td>
100 <td>Private method to fix a docstring summary not followed by a blank line.</td>
101 </tr><tr>
102 <td><a href="#CodeStyleFixer.__fixD145">__fixD145</a></td>
103 <td>Private method to fix the last paragraph of a multi-line docstring not followed by a blank line.</td>
104 </tr><tr>
105 <td><a href="#CodeStyleFixer.__fixD221">__fixD221</a></td>
106 <td>Private method to fix leading and trailing quotes of docstring not on separate lines.</td>
107 </tr><tr>
108 <td><a href="#CodeStyleFixer.__fixD242">__fixD242</a></td>
109 <td>Private method to fix a class or function/method docstring preceded by a blank line.</td>
110 </tr><tr>
111 <td><a href="#CodeStyleFixer.__fixD243">__fixD243</a></td>
112 <td>Private method to fix a class or function/method docstring followed by a blank line.</td>
113 </tr><tr>
114 <td><a href="#CodeStyleFixer.__fixD247">__fixD247</a></td>
115 <td>Private method to fix a last paragraph of a docstring followed by a blank line.</td>
116 </tr><tr>
117 <td><a href="#CodeStyleFixer.__fixE101">__fixE101</a></td>
118 <td>Private method to fix obsolete tab usage and indentation errors.</td>
119 </tr><tr>
120 <td><a href="#CodeStyleFixer.__fixE121">__fixE121</a></td>
121 <td>Private method to fix the indentation of continuation lines and closing brackets.</td>
122 </tr><tr>
123 <td><a href="#CodeStyleFixer.__fixE122">__fixE122</a></td>
124 <td>Private method to fix a missing indentation of continuation lines.</td>
125 </tr><tr>
126 <td><a href="#CodeStyleFixer.__fixE123">__fixE123</a></td>
127 <td>Private method to fix the indentation of a closing bracket lines.</td>
128 </tr><tr>
129 <td><a href="#CodeStyleFixer.__fixE125">__fixE125</a></td>
130 <td>Private method to fix the indentation of continuation lines not distinguishable from next logical line.</td>
131 </tr><tr>
132 <td><a href="#CodeStyleFixer.__fixE126">__fixE126</a></td>
133 <td>Private method to fix over-indented/under-indented hanging indentation.</td>
134 </tr><tr>
135 <td><a href="#CodeStyleFixer.__fixE127">__fixE127</a></td>
136 <td>Private method to fix over/under indented lines.</td>
137 </tr><tr>
138 <td><a href="#CodeStyleFixer.__fixE201">__fixE201</a></td>
139 <td>Private method to fix extraneous whitespace.</td>
140 </tr><tr>
141 <td><a href="#CodeStyleFixer.__fixE221">__fixE221</a></td>
142 <td>Private method to fix extraneous whitespace around operator or keyword.</td>
143 </tr><tr>
144 <td><a href="#CodeStyleFixer.__fixE231">__fixE231</a></td>
145 <td>Private method to fix missing whitespace after ',;:'.</td>
146 </tr><tr>
147 <td><a href="#CodeStyleFixer.__fixE251">__fixE251</a></td>
148 <td>Private method to fix extraneous whitespace around keyword and default parameter equals.</td>
149 </tr><tr>
150 <td><a href="#CodeStyleFixer.__fixE261">__fixE261</a></td>
151 <td>Private method to fix whitespace before or after inline comment.</td>
152 </tr><tr>
153 <td><a href="#CodeStyleFixer.__fixE301">__fixE301</a></td>
154 <td>Private method to fix the need for one blank line.</td>
155 </tr><tr>
156 <td><a href="#CodeStyleFixer.__fixE302">__fixE302</a></td>
157 <td>Private method to fix the need for two blank lines.</td>
158 </tr><tr>
159 <td><a href="#CodeStyleFixer.__fixE303">__fixE303</a></td>
160 <td>Private method to fix superfluous blank lines.</td>
161 </tr><tr>
162 <td><a href="#CodeStyleFixer.__fixE304">__fixE304</a></td>
163 <td>Private method to fix superfluous blank lines after a function decorator.</td>
164 </tr><tr>
165 <td><a href="#CodeStyleFixer.__fixE401">__fixE401</a></td>
166 <td>Private method to fix multiple imports on one line.</td>
167 </tr><tr>
168 <td><a href="#CodeStyleFixer.__fixE501">__fixE501</a></td>
169 <td>Private method to fix the long lines by breaking them.</td>
170 </tr><tr>
171 <td><a href="#CodeStyleFixer.__fixE502">__fixE502</a></td>
172 <td>Private method to fix redundant backslash within brackets.</td>
173 </tr><tr>
174 <td><a href="#CodeStyleFixer.__fixE701">__fixE701</a></td>
175 <td>Private method to fix colon-separated compound statements.</td>
176 </tr><tr>
177 <td><a href="#CodeStyleFixer.__fixE702">__fixE702</a></td>
178 <td>Private method to fix semicolon-separated compound statements.</td>
179 </tr><tr>
180 <td><a href="#CodeStyleFixer.__fixE711">__fixE711</a></td>
181 <td>Private method to fix comparison with None.</td>
182 </tr><tr>
183 <td><a href="#CodeStyleFixer.__fixN804">__fixN804</a></td>
184 <td>Private method to fix a wrong first argument of normal and class methods.</td>
185 </tr><tr>
186 <td><a href="#CodeStyleFixer.__fixN806">__fixN806</a></td>
187 <td>Private method to fix a wrong first argument of static methods.</td>
188 </tr><tr>
189 <td><a href="#CodeStyleFixer.__fixReindent">__fixReindent</a></td>
190 <td>Private method to fix a badly indented line.</td>
191 </tr><tr>
192 <td><a href="#CodeStyleFixer.__fixW291">__fixW291</a></td>
193 <td>Private method to fix trailing whitespace.</td>
194 </tr><tr>
195 <td><a href="#CodeStyleFixer.__fixW292">__fixW292</a></td>
196 <td>Private method to fix a missing newline at the end of file.</td>
197 </tr><tr>
198 <td><a href="#CodeStyleFixer.__fixW391">__fixW391</a></td>
199 <td>Private method to fix trailing blank lines.</td>
200 </tr><tr>
201 <td><a href="#CodeStyleFixer.__fixW603">__fixW603</a></td>
202 <td>Private method to fix the not equal notation.</td>
203 </tr><tr>
204 <td><a href="#CodeStyleFixer.__fixWhitespace">__fixWhitespace</a></td>
205 <td>Private method to correct whitespace at the given offset.</td>
206 </tr><tr>
207 <td><a href="#CodeStyleFixer.__getEol">__getEol</a></td>
208 <td>Private method to get the applicable eol string.</td>
209 </tr><tr>
210 <td><a href="#CodeStyleFixer.__getID">__getID</a></td>
211 <td>Private method to get the ID for a deferred fix.</td>
212 </tr><tr>
213 <td><a href="#CodeStyleFixer.__getIndent">__getIndent</a></td>
214 <td>Private method to get the indentation string.</td>
215 </tr><tr>
216 <td><a href="#CodeStyleFixer.__getIndentWord">__getIndentWord</a></td>
217 <td>Private method to determine the indentation type.</td>
218 </tr><tr>
219 <td><a href="#CodeStyleFixer.__getLogical">__getLogical</a></td>
220 <td>Private method to get the logical line corresponding to the given position.</td>
221 </tr><tr>
222 <td><a href="#CodeStyleFixer.__multilineStringLines">__multilineStringLines</a></td>
223 <td>Private method to determine the line numbers that are within multi line strings and these which are part of a documentation string.</td>
224 </tr><tr>
225 <td><a href="#CodeStyleFixer.finalize">finalize</a></td>
226 <td>Public method to apply all deferred fixes.</td>
227 </tr><tr>
228 <td><a href="#CodeStyleFixer.fixIssue">fixIssue</a></td>
229 <td>Public method to fix the fixable issues.</td>
230 </tr><tr>
231 <td><a href="#CodeStyleFixer.mutualStartswith">mutualStartswith</a></td>
232 <td>Local helper method to compare the beginnings of two strings against each other.</td>
233 </tr><tr>
234 <td><a href="#CodeStyleFixer.saveFile">saveFile</a></td>
235 <td>Public method to save the modified file.</td>
236 </tr>
237 </table>
238 <h3>Static Methods</h3>
239 <table>
240 <tr><td>None</td></tr>
241 </table>
242 <a NAME="CodeStyleFixer.__init__" ID="CodeStyleFixer.__init__"></a>
243 <h4>CodeStyleFixer (Constructor)</h4>
244 <b>CodeStyleFixer</b>(<i>project, filename, sourceLines, fixCodes, noFixCodes, maxLineLength, inPlace</i>)
245 <p>
246 Constructor
247 </p><dl>
248 <dt><i>project</i></dt>
249 <dd>
250 reference to the project object (Project)
251 </dd><dt><i>filename</i></dt>
252 <dd>
253 name of the file to be fixed (string)
254 </dd><dt><i>sourceLines</i></dt>
255 <dd>
256 list of source lines including eol marker
257 (list of string)
258 </dd><dt><i>fixCodes</i></dt>
259 <dd>
260 list of codes to be fixed as a comma separated
261 string (string)
262 </dd><dt><i>noFixCodes</i></dt>
263 <dd>
264 list of codes not to be fixed as a comma
265 separated string (string)
266 </dd><dt><i>maxLineLength</i></dt>
267 <dd>
268 maximum allowed line length (integer)
269 </dd><dt><i>inPlace</i></dt>
270 <dd>
271 flag indicating to modify the file in place (boolean)
272 </dd>
273 </dl><a NAME="CodeStyleFixer.__codeMatch" ID="CodeStyleFixer.__codeMatch"></a>
274 <h4>CodeStyleFixer.__codeMatch</h4>
275 <b>__codeMatch</b>(<i>code</i>)
276 <p>
277 Private method to check, if the code should be fixed.
278 </p><dl>
279 <dt><i>code</i></dt>
280 <dd>
281 to check (string)
282 </dd>
283 </dl><dl>
284 <dt>Returns:</dt>
285 <dd>
286 flag indicating it should be fixed (boolean)
287 </dd>
288 </dl><a NAME="CodeStyleFixer.__findLogical" ID="CodeStyleFixer.__findLogical"></a>
289 <h4>CodeStyleFixer.__findLogical</h4>
290 <b>__findLogical</b>(<i></i>)
291 <p>
292 Private method to extract the index of all the starts and ends of
293 lines.
294 </p><dl>
295 <dt>Returns:</dt>
296 <dd>
297 tuple containing two lists of integer with start and end tuples
298 of lines
299 </dd>
300 </dl><a NAME="CodeStyleFixer.__fixD111" ID="CodeStyleFixer.__fixD111"></a>
301 <h4>CodeStyleFixer.__fixD111</h4>
302 <b>__fixD111</b>(<i>code, line, pos</i>)
303 <p>
304 Private method to fix docstring enclosed in wrong quotes.
305 </p><p>
306 Codes: D111
307 </p><dl>
308 <dt><i>code</i></dt>
309 <dd>
310 code of the issue (string)
311 </dd><dt><i>line</i></dt>
312 <dd>
313 line number of the issue (integer)
314 </dd><dt><i>pos</i></dt>
315 <dd>
316 position inside line (integer)
317 </dd>
318 </dl><dl>
319 <dt>Returns:</dt>
320 <dd>
321 value indicating an applied/deferred fix (-1, 0, 1),
322 a message for the fix (string) and an ID for a deferred
323 fix (integer)
324 </dd>
325 </dl><a NAME="CodeStyleFixer.__fixD112" ID="CodeStyleFixer.__fixD112"></a>
326 <h4>CodeStyleFixer.__fixD112</h4>
327 <b>__fixD112</b>(<i>code, line, pos</i>)
328 <p>
329 Private method to fix docstring 'r' or 'u' in leading quotes.
330 </p><p>
331 Codes: D112, D113
332 </p><dl>
333 <dt><i>code</i></dt>
334 <dd>
335 code of the issue (string)
336 </dd><dt><i>line</i></dt>
337 <dd>
338 line number of the issue (integer)
339 </dd><dt><i>pos</i></dt>
340 <dd>
341 position inside line (integer)
342 </dd>
343 </dl><dl>
344 <dt>Returns:</dt>
345 <dd>
346 value indicating an applied/deferred fix (-1, 0, 1),
347 a message for the fix (string) and an ID for a deferred
348 fix (integer)
349 </dd>
350 </dl><a NAME="CodeStyleFixer.__fixD121" ID="CodeStyleFixer.__fixD121"></a>
351 <h4>CodeStyleFixer.__fixD121</h4>
352 <b>__fixD121</b>(<i>code, line, pos, apply=False</i>)
353 <p>
354 Private method to fix a single line docstring on multiple lines.
355 </p><p>
356 Codes: D121
357 </p><dl>
358 <dt><i>code</i></dt>
359 <dd>
360 code of the issue (string)
361 </dd><dt><i>line</i></dt>
362 <dd>
363 line number of the issue (integer)
364 </dd><dt><i>pos</i></dt>
365 <dd>
366 position inside line (integer)
367 </dd><dt><i>apply=</i></dt>
368 <dd>
369 flag indicating, that the fix should be applied
370 (boolean)
371 </dd>
372 </dl><dl>
373 <dt>Returns:</dt>
374 <dd>
375 value indicating an applied/deferred fix (-1, 0, 1),
376 a message for the fix (string) and an ID for a deferred
377 fix (integer)
378 </dd>
379 </dl><a NAME="CodeStyleFixer.__fixD131" ID="CodeStyleFixer.__fixD131"></a>
380 <h4>CodeStyleFixer.__fixD131</h4>
381 <b>__fixD131</b>(<i>code, line, pos</i>)
382 <p>
383 Private method to fix a docstring summary not ending with a
384 period.
385 </p><p>
386 Codes: D131
387 </p><dl>
388 <dt><i>code</i></dt>
389 <dd>
390 code of the issue (string)
391 </dd><dt><i>line</i></dt>
392 <dd>
393 line number of the issue (integer)
394 </dd><dt><i>pos</i></dt>
395 <dd>
396 position inside line (integer)
397 </dd>
398 </dl><dl>
399 <dt>Returns:</dt>
400 <dd>
401 value indicating an applied/deferred fix (-1, 0, 1),
402 a message for the fix (string) and an ID for a deferred
403 fix (integer)
404 </dd>
405 </dl><a NAME="CodeStyleFixer.__fixD141" ID="CodeStyleFixer.__fixD141"></a>
406 <h4>CodeStyleFixer.__fixD141</h4>
407 <b>__fixD141</b>(<i>code, line, pos, apply=False</i>)
408 <p>
409 Private method to fix a function/method docstring preceded by a
410 blank line.
411 </p><p>
412 Codes: D141
413 </p><dl>
414 <dt><i>code</i></dt>
415 <dd>
416 code of the issue (string)
417 </dd><dt><i>line</i></dt>
418 <dd>
419 line number of the issue (integer)
420 </dd><dt><i>pos</i></dt>
421 <dd>
422 position inside line (integer)
423 </dd><dt><i>apply=</i></dt>
424 <dd>
425 flag indicating, that the fix should be applied
426 (boolean)
427 </dd>
428 </dl><dl>
429 <dt>Returns:</dt>
430 <dd>
431 value indicating an applied/deferred fix (-1, 0, 1),
432 a message for the fix (string) and an ID for a deferred
433 fix (integer)
434 </dd>
435 </dl><a NAME="CodeStyleFixer.__fixD142" ID="CodeStyleFixer.__fixD142"></a>
436 <h4>CodeStyleFixer.__fixD142</h4>
437 <b>__fixD142</b>(<i>code, line, pos, apply=False</i>)
438 <p>
439 Private method to fix a class docstring not preceded by a
440 blank line.
441 </p><p>
442 Codes: D142
443 </p><dl>
444 <dt><i>code</i></dt>
445 <dd>
446 code of the issue (string)
447 </dd><dt><i>line</i></dt>
448 <dd>
449 line number of the issue (integer)
450 </dd><dt><i>pos</i></dt>
451 <dd>
452 position inside line (integer)
453 </dd><dt><i>apply=</i></dt>
454 <dd>
455 flag indicating, that the fix should be applied
456 (boolean)
457 </dd>
458 </dl><dl>
459 <dt>Returns:</dt>
460 <dd>
461 value indicating an applied/deferred fix (-1, 0, 1),
462 a message for the fix (string) and an ID for a deferred
463 fix (integer)
464 </dd>
465 </dl><a NAME="CodeStyleFixer.__fixD143" ID="CodeStyleFixer.__fixD143"></a>
466 <h4>CodeStyleFixer.__fixD143</h4>
467 <b>__fixD143</b>(<i>code, line, pos, apply=False</i>)
468 <p>
469 Private method to fix a class docstring not followed by a
470 blank line.
471 </p><p>
472 Codes: D143
473 </p><dl>
474 <dt><i>code</i></dt>
475 <dd>
476 code of the issue (string)
477 </dd><dt><i>line</i></dt>
478 <dd>
479 line number of the issue (integer)
480 </dd><dt><i>pos</i></dt>
481 <dd>
482 position inside line (integer)
483 </dd><dt><i>apply=</i></dt>
484 <dd>
485 flag indicating, that the fix should be applied
486 (boolean)
487 </dd>
488 </dl><dl>
489 <dt>Returns:</dt>
490 <dd>
491 value indicating an applied/deferred fix (-1, 0, 1),
492 a message for the fix (string) and an ID for a deferred
493 fix (integer)
494 </dd>
495 </dl><a NAME="CodeStyleFixer.__fixD144" ID="CodeStyleFixer.__fixD144"></a>
496 <h4>CodeStyleFixer.__fixD144</h4>
497 <b>__fixD144</b>(<i>code, line, pos, apply=False</i>)
498 <p>
499 Private method to fix a docstring summary not followed by a
500 blank line.
501 </p><p>
502 Codes: D144
503 </p><dl>
504 <dt><i>code</i></dt>
505 <dd>
506 code of the issue (string)
507 </dd><dt><i>line</i></dt>
508 <dd>
509 line number of the issue (integer)
510 </dd><dt><i>pos</i></dt>
511 <dd>
512 position inside line (integer)
513 </dd><dt><i>apply=</i></dt>
514 <dd>
515 flag indicating, that the fix should be applied
516 (boolean)
517 </dd>
518 </dl><dl>
519 <dt>Returns:</dt>
520 <dd>
521 value indicating an applied/deferred fix (-1, 0, 1),
522 a message for the fix (string) and an ID for a deferred
523 fix (integer)
524 </dd>
525 </dl><a NAME="CodeStyleFixer.__fixD145" ID="CodeStyleFixer.__fixD145"></a>
526 <h4>CodeStyleFixer.__fixD145</h4>
527 <b>__fixD145</b>(<i>code, line, pos, apply=False</i>)
528 <p>
529 Private method to fix the last paragraph of a multi-line docstring
530 not followed by a blank line.
531 </p><p>
532 Codes: D143
533 </p><dl>
534 <dt><i>code</i></dt>
535 <dd>
536 code of the issue (string)
537 </dd><dt><i>line</i></dt>
538 <dd>
539 line number of the issue (integer)
540 </dd><dt><i>pos</i></dt>
541 <dd>
542 position inside line (integer)
543 </dd><dt><i>apply=</i></dt>
544 <dd>
545 flag indicating, that the fix should be applied
546 (boolean)
547 </dd>
548 </dl><dl>
549 <dt>Returns:</dt>
550 <dd>
551 value indicating an applied/deferred fix (-1, 0, 1),
552 a message for the fix (string) and an ID for a deferred
553 fix (integer)
554 </dd>
555 </dl><a NAME="CodeStyleFixer.__fixD221" ID="CodeStyleFixer.__fixD221"></a>
556 <h4>CodeStyleFixer.__fixD221</h4>
557 <b>__fixD221</b>(<i>code, line, pos, apply=False</i>)
558 <p>
559 Private method to fix leading and trailing quotes of docstring
560 not on separate lines.
561 </p><p>
562 Codes: D221, D222
563 </p><dl>
564 <dt><i>code</i></dt>
565 <dd>
566 code of the issue (string)
567 </dd><dt><i>line</i></dt>
568 <dd>
569 line number of the issue (integer)
570 </dd><dt><i>pos</i></dt>
571 <dd>
572 position inside line (integer)
573 </dd><dt><i>apply=</i></dt>
574 <dd>
575 flag indicating, that the fix should be applied
576 (boolean)
577 </dd>
578 </dl><dl>
579 <dt>Returns:</dt>
580 <dd>
581 value indicating an applied/deferred fix (-1, 0, 1),
582 a message for the fix (string) and an ID for a deferred
583 fix (integer)
584 </dd>
585 </dl><a NAME="CodeStyleFixer.__fixD242" ID="CodeStyleFixer.__fixD242"></a>
586 <h4>CodeStyleFixer.__fixD242</h4>
587 <b>__fixD242</b>(<i>code, line, pos, apply=False</i>)
588 <p>
589 Private method to fix a class or function/method docstring preceded
590 by a blank line.
591 </p><p>
592 Codes: D242, D244
593 </p><dl>
594 <dt><i>code</i></dt>
595 <dd>
596 code of the issue (string)
597 </dd><dt><i>line</i></dt>
598 <dd>
599 line number of the issue (integer)
600 </dd><dt><i>pos</i></dt>
601 <dd>
602 position inside line (integer)
603 </dd><dt><i>apply=</i></dt>
604 <dd>
605 flag indicating, that the fix should be applied
606 (boolean)
607 </dd>
608 </dl><dl>
609 <dt>Returns:</dt>
610 <dd>
611 value indicating an applied/deferred fix (-1, 0, 1),
612 a message for the fix (string) and an ID for a deferred
613 fix (integer)
614 </dd>
615 </dl><a NAME="CodeStyleFixer.__fixD243" ID="CodeStyleFixer.__fixD243"></a>
616 <h4>CodeStyleFixer.__fixD243</h4>
617 <b>__fixD243</b>(<i>code, line, pos, apply=False</i>)
618 <p>
619 Private method to fix a class or function/method docstring followed
620 by a blank line.
621 </p><p>
622 Codes: D243, D245
623 </p><dl>
624 <dt><i>code</i></dt>
625 <dd>
626 code of the issue (string)
627 </dd><dt><i>line</i></dt>
628 <dd>
629 line number of the issue (integer)
630 </dd><dt><i>pos</i></dt>
631 <dd>
632 position inside line (integer)
633 </dd><dt><i>apply=</i></dt>
634 <dd>
635 flag indicating, that the fix should be applied
636 (boolean)
637 </dd>
638 </dl><dl>
639 <dt>Returns:</dt>
640 <dd>
641 value indicating an applied/deferred fix (-1, 0, 1),
642 a message for the fix (string) and an ID for a deferred
643 fix (integer)
644 </dd>
645 </dl><a NAME="CodeStyleFixer.__fixD247" ID="CodeStyleFixer.__fixD247"></a>
646 <h4>CodeStyleFixer.__fixD247</h4>
647 <b>__fixD247</b>(<i>code, line, pos, apply=False</i>)
648 <p>
649 Private method to fix a last paragraph of a docstring followed
650 by a blank line.
651 </p><p>
652 Codes: D247
653 </p><dl>
654 <dt><i>code</i></dt>
655 <dd>
656 code of the issue (string)
657 </dd><dt><i>line</i></dt>
658 <dd>
659 line number of the issue (integer)
660 </dd><dt><i>pos</i></dt>
661 <dd>
662 position inside line (integer)
663 </dd><dt><i>apply=</i></dt>
664 <dd>
665 flag indicating, that the fix should be applied
666 (boolean)
667 </dd>
668 </dl><dl>
669 <dt>Returns:</dt>
670 <dd>
671 value indicating an applied/deferred fix (-1, 0, 1),
672 a message for the fix (string) and an ID for a deferred
673 fix (integer)
674 </dd>
675 </dl><a NAME="CodeStyleFixer.__fixE101" ID="CodeStyleFixer.__fixE101"></a>
676 <h4>CodeStyleFixer.__fixE101</h4>
677 <b>__fixE101</b>(<i>code, line, pos</i>)
678 <p>
679 Private method to fix obsolete tab usage and indentation errors.
680 </p><p>
681 Codes: E101, E111, W191
682 </p><dl>
683 <dt><i>code</i></dt>
684 <dd>
685 code of the issue (string)
686 </dd><dt><i>line</i></dt>
687 <dd>
688 line number of the issue (integer)
689 </dd><dt><i>pos</i></dt>
690 <dd>
691 position inside line (integer)
692 </dd>
693 </dl><dl>
694 <dt>Returns:</dt>
695 <dd>
696 value indicating an applied/deferred fix (-1, 0, 1),
697 a message for the fix (string) and an ID for a deferred
698 fix (integer)
699 </dd>
700 </dl><a NAME="CodeStyleFixer.__fixE121" ID="CodeStyleFixer.__fixE121"></a>
701 <h4>CodeStyleFixer.__fixE121</h4>
702 <b>__fixE121</b>(<i>code, line, pos, apply=False</i>)
703 <p>
704 Private method to fix the indentation of continuation lines and
705 closing brackets.
706 </p><p>
707 Codes: E121, E124
708 </p><dl>
709 <dt><i>code</i></dt>
710 <dd>
711 code of the issue (string)
712 </dd><dt><i>line</i></dt>
713 <dd>
714 line number of the issue (integer)
715 </dd><dt><i>pos</i></dt>
716 <dd>
717 position inside line (integer)
718 </dd><dt><i>apply=</i></dt>
719 <dd>
720 flag indicating, that the fix should be applied
721 (boolean)
722 </dd>
723 </dl><dl>
724 <dt>Returns:</dt>
725 <dd>
726 value indicating an applied/deferred fix (-1, 0, 1),
727 a message for the fix (string) and an ID for a deferred
728 fix (integer)
729 </dd>
730 </dl><a NAME="CodeStyleFixer.__fixE122" ID="CodeStyleFixer.__fixE122"></a>
731 <h4>CodeStyleFixer.__fixE122</h4>
732 <b>__fixE122</b>(<i>code, line, pos, apply=False</i>)
733 <p>
734 Private method to fix a missing indentation of continuation lines.
735 </p><p>
736 Codes: E122
737 </p><dl>
738 <dt><i>code</i></dt>
739 <dd>
740 code of the issue (string)
741 </dd><dt><i>line</i></dt>
742 <dd>
743 line number of the issue (integer)
744 </dd><dt><i>pos</i></dt>
745 <dd>
746 position inside line (integer)
747 </dd><dt><i>apply=</i></dt>
748 <dd>
749 flag indicating, that the fix should be applied
750 (boolean)
751 </dd>
752 </dl><dl>
753 <dt>Returns:</dt>
754 <dd>
755 value indicating an applied/deferred fix (-1, 0, 1),
756 a message for the fix (string) and an ID for a deferred
757 fix (integer)
758 </dd>
759 </dl><a NAME="CodeStyleFixer.__fixE123" ID="CodeStyleFixer.__fixE123"></a>
760 <h4>CodeStyleFixer.__fixE123</h4>
761 <b>__fixE123</b>(<i>code, line, pos, apply=False</i>)
762 <p>
763 Private method to fix the indentation of a closing bracket lines.
764 </p><p>
765 Codes: E123
766 </p><dl>
767 <dt><i>code</i></dt>
768 <dd>
769 code of the issue (string)
770 </dd><dt><i>line</i></dt>
771 <dd>
772 line number of the issue (integer)
773 </dd><dt><i>pos</i></dt>
774 <dd>
775 position inside line (integer)
776 </dd><dt><i>apply=</i></dt>
777 <dd>
778 flag indicating, that the fix should be applied
779 (boolean)
780 </dd>
781 </dl><dl>
782 <dt>Returns:</dt>
783 <dd>
784 value indicating an applied/deferred fix (-1, 0, 1),
785 a message for the fix (string) and an ID for a deferred
786 fix (integer)
787 </dd>
788 </dl><a NAME="CodeStyleFixer.__fixE125" ID="CodeStyleFixer.__fixE125"></a>
789 <h4>CodeStyleFixer.__fixE125</h4>
790 <b>__fixE125</b>(<i>code, line, pos, apply=False</i>)
791 <p>
792 Private method to fix the indentation of continuation lines not
793 distinguishable from next logical line.
794 </p><p>
795 Codes: E125
796 </p><dl>
797 <dt><i>code</i></dt>
798 <dd>
799 code of the issue (string)
800 </dd><dt><i>line</i></dt>
801 <dd>
802 line number of the issue (integer)
803 </dd><dt><i>pos</i></dt>
804 <dd>
805 position inside line (integer)
806 </dd><dt><i>apply=</i></dt>
807 <dd>
808 flag indicating, that the fix should be applied
809 (boolean)
810 </dd>
811 </dl><dl>
812 <dt>Returns:</dt>
813 <dd>
814 value indicating an applied/deferred fix (-1, 0, 1),
815 a message for the fix (string) and an ID for a deferred
816 fix (integer)
817 </dd>
818 </dl><a NAME="CodeStyleFixer.__fixE126" ID="CodeStyleFixer.__fixE126"></a>
819 <h4>CodeStyleFixer.__fixE126</h4>
820 <b>__fixE126</b>(<i>code, line, pos, apply=False</i>)
821 <p>
822 Private method to fix over-indented/under-indented hanging
823 indentation.
824 </p><p>
825 Codes: E126, E133
826 </p><dl>
827 <dt><i>code</i></dt>
828 <dd>
829 code of the issue (string)
830 </dd><dt><i>line</i></dt>
831 <dd>
832 line number of the issue (integer)
833 </dd><dt><i>pos</i></dt>
834 <dd>
835 position inside line (integer)
836 </dd><dt><i>apply=</i></dt>
837 <dd>
838 flag indicating, that the fix should be applied
839 (boolean)
840 </dd>
841 </dl><dl>
842 <dt>Returns:</dt>
843 <dd>
844 value indicating an applied/deferred fix (-1, 0, 1),
845 a message for the fix (string) and an ID for a deferred
846 fix (integer)
847 </dd>
848 </dl><a NAME="CodeStyleFixer.__fixE127" ID="CodeStyleFixer.__fixE127"></a>
849 <h4>CodeStyleFixer.__fixE127</h4>
850 <b>__fixE127</b>(<i>code, line, pos, apply=False</i>)
851 <p>
852 Private method to fix over/under indented lines.
853 </p><p>
854 Codes: E127, E128
855 </p><dl>
856 <dt><i>code</i></dt>
857 <dd>
858 code of the issue (string)
859 </dd><dt><i>line</i></dt>
860 <dd>
861 line number of the issue (integer)
862 </dd><dt><i>pos</i></dt>
863 <dd>
864 position inside line (integer)
865 </dd><dt><i>apply=</i></dt>
866 <dd>
867 flag indicating, that the fix should be applied
868 (boolean)
869 </dd>
870 </dl><dl>
871 <dt>Returns:</dt>
872 <dd>
873 value indicating an applied/deferred fix (-1, 0, 1),
874 a message for the fix (string) and an ID for a deferred
875 fix (integer)
876 </dd>
877 </dl><a NAME="CodeStyleFixer.__fixE201" ID="CodeStyleFixer.__fixE201"></a>
878 <h4>CodeStyleFixer.__fixE201</h4>
879 <b>__fixE201</b>(<i>code, line, pos</i>)
880 <p>
881 Private method to fix extraneous whitespace.
882 </p><p>
883 Codes: E201, E202, E203, E211
884 </p><dl>
885 <dt><i>code</i></dt>
886 <dd>
887 code of the issue (string)
888 </dd><dt><i>line</i></dt>
889 <dd>
890 line number of the issue (integer)
891 </dd><dt><i>pos</i></dt>
892 <dd>
893 position inside line (integer)
894 </dd>
895 </dl><dl>
896 <dt>Returns:</dt>
897 <dd>
898 value indicating an applied/deferred fix (-1, 0, 1),
899 a message for the fix (string) and an ID for a deferred
900 fix (integer)
901 </dd>
902 </dl><a NAME="CodeStyleFixer.__fixE221" ID="CodeStyleFixer.__fixE221"></a>
903 <h4>CodeStyleFixer.__fixE221</h4>
904 <b>__fixE221</b>(<i>code, line, pos</i>)
905 <p>
906 Private method to fix extraneous whitespace around operator or
907 keyword.
908 </p><p>
909 Codes: E221, E222, E223, E224, E225, E226, E227, E228, E241,
910 E242, E271, E272, E273, E274).
911 </p><dl>
912 <dt><i>code</i></dt>
913 <dd>
914 code of the issue (string)
915 </dd><dt><i>line</i></dt>
916 <dd>
917 line number of the issue (integer)
918 </dd><dt><i>pos</i></dt>
919 <dd>
920 position inside line (integer)
921 </dd>
922 </dl><dl>
923 <dt>Returns:</dt>
924 <dd>
925 value indicating an applied/deferred fix (-1, 0, 1),
926 a message for the fix (string) and an ID for a deferred
927 fix (integer)
928 </dd>
929 </dl><a NAME="CodeStyleFixer.__fixE231" ID="CodeStyleFixer.__fixE231"></a>
930 <h4>CodeStyleFixer.__fixE231</h4>
931 <b>__fixE231</b>(<i>code, line, pos</i>)
932 <p>
933 Private method to fix missing whitespace after ',;:'.
934 </p><p>
935 Codes: E231
936 </p><dl>
937 <dt><i>code</i></dt>
938 <dd>
939 code of the issue (string)
940 </dd><dt><i>line</i></dt>
941 <dd>
942 line number of the issue (integer)
943 </dd><dt><i>pos</i></dt>
944 <dd>
945 position inside line (integer)
946 </dd>
947 </dl><dl>
948 <dt>Returns:</dt>
949 <dd>
950 value indicating an applied/deferred fix (-1, 0, 1),
951 a message for the fix (string) and an ID for a deferred
952 fix (integer)
953 </dd>
954 </dl><a NAME="CodeStyleFixer.__fixE251" ID="CodeStyleFixer.__fixE251"></a>
955 <h4>CodeStyleFixer.__fixE251</h4>
956 <b>__fixE251</b>(<i>code, line, pos</i>)
957 <p>
958 Private method to fix extraneous whitespace around keyword and
959 default parameter equals.
960 </p><p>
961 Codes: E251
962 </p><dl>
963 <dt><i>code</i></dt>
964 <dd>
965 code of the issue (string)
966 </dd><dt><i>line</i></dt>
967 <dd>
968 line number of the issue (integer)
969 </dd><dt><i>pos</i></dt>
970 <dd>
971 position inside line (integer)
972 </dd>
973 </dl><dl>
974 <dt>Returns:</dt>
975 <dd>
976 value indicating an applied/deferred fix (-1, 0, 1),
977 a message for the fix (string) and an ID for a deferred
978 fix (integer)
979 </dd>
980 </dl><a NAME="CodeStyleFixer.__fixE261" ID="CodeStyleFixer.__fixE261"></a>
981 <h4>CodeStyleFixer.__fixE261</h4>
982 <b>__fixE261</b>(<i>code, line, pos</i>)
983 <p>
984 Private method to fix whitespace before or after inline comment.
985 </p><p>
986 Codes: E261, E262
987 </p><dl>
988 <dt><i>code</i></dt>
989 <dd>
990 code of the issue (string)
991 </dd><dt><i>line</i></dt>
992 <dd>
993 line number of the issue (integer)
994 </dd><dt><i>pos</i></dt>
995 <dd>
996 position inside line (integer)
997 </dd>
998 </dl><dl>
999 <dt>Returns:</dt>
1000 <dd>
1001 value indicating an applied/deferred fix (-1, 0, 1),
1002 a message for the fix (string) and an ID for a deferred
1003 fix (integer)
1004 </dd>
1005 </dl><a NAME="CodeStyleFixer.__fixE301" ID="CodeStyleFixer.__fixE301"></a>
1006 <h4>CodeStyleFixer.__fixE301</h4>
1007 <b>__fixE301</b>(<i>code, line, pos, apply=False</i>)
1008 <p>
1009 Private method to fix the need for one blank line.
1010 </p><p>
1011 Codes: E301
1012 </p><dl>
1013 <dt><i>code</i></dt>
1014 <dd>
1015 code of the issue (string)
1016 </dd><dt><i>line</i></dt>
1017 <dd>
1018 line number of the issue (integer)
1019 </dd><dt><i>pos</i></dt>
1020 <dd>
1021 position inside line (integer)
1022 </dd><dt><i>apply=</i></dt>
1023 <dd>
1024 flag indicating, that the fix should be applied
1025 (boolean)
1026 </dd>
1027 </dl><dl>
1028 <dt>Returns:</dt>
1029 <dd>
1030 value indicating an applied/deferred fix (-1, 0, 1),
1031 a message for the fix (string) and an ID for a deferred
1032 fix (integer)
1033 </dd>
1034 </dl><a NAME="CodeStyleFixer.__fixE302" ID="CodeStyleFixer.__fixE302"></a>
1035 <h4>CodeStyleFixer.__fixE302</h4>
1036 <b>__fixE302</b>(<i>code, line, pos, apply=False</i>)
1037 <p>
1038 Private method to fix the need for two blank lines.
1039 </p><p>
1040 Codes: E302
1041 </p><dl>
1042 <dt><i>code</i></dt>
1043 <dd>
1044 code of the issue (string)
1045 </dd><dt><i>line</i></dt>
1046 <dd>
1047 line number of the issue (integer)
1048 </dd><dt><i>pos</i></dt>
1049 <dd>
1050 position inside line (integer)
1051 </dd><dt><i>apply=</i></dt>
1052 <dd>
1053 flag indicating, that the fix should be applied
1054 (boolean)
1055 </dd>
1056 </dl><dl>
1057 <dt>Returns:</dt>
1058 <dd>
1059 value indicating an applied/deferred fix (-1, 0, 1),
1060 a message for the fix (string) and an ID for a deferred
1061 fix (integer)
1062 </dd>
1063 </dl><a NAME="CodeStyleFixer.__fixE303" ID="CodeStyleFixer.__fixE303"></a>
1064 <h4>CodeStyleFixer.__fixE303</h4>
1065 <b>__fixE303</b>(<i>code, line, pos, apply=False</i>)
1066 <p>
1067 Private method to fix superfluous blank lines.
1068 </p><p>
1069 Codes: E303
1070 </p><dl>
1071 <dt><i>code</i></dt>
1072 <dd>
1073 code of the issue (string)
1074 </dd><dt><i>line</i></dt>
1075 <dd>
1076 line number of the issue (integer)
1077 </dd><dt><i>pos</i></dt>
1078 <dd>
1079 position inside line (integer)
1080 </dd><dt><i>apply=</i></dt>
1081 <dd>
1082 flag indicating, that the fix should be applied
1083 (boolean)
1084 </dd>
1085 </dl><dl>
1086 <dt>Returns:</dt>
1087 <dd>
1088 value indicating an applied/deferred fix (-1, 0, 1),
1089 a message for the fix (string) and an ID for a deferred
1090 fix (integer)
1091 </dd>
1092 </dl><a NAME="CodeStyleFixer.__fixE304" ID="CodeStyleFixer.__fixE304"></a>
1093 <h4>CodeStyleFixer.__fixE304</h4>
1094 <b>__fixE304</b>(<i>code, line, pos, apply=False</i>)
1095 <p>
1096 Private method to fix superfluous blank lines after a function
1097 decorator.
1098 </p><p>
1099 Codes: E304
1100 </p><dl>
1101 <dt><i>code</i></dt>
1102 <dd>
1103 code of the issue (string)
1104 </dd><dt><i>line</i></dt>
1105 <dd>
1106 line number of the issue (integer)
1107 </dd><dt><i>pos</i></dt>
1108 <dd>
1109 position inside line (integer)
1110 </dd><dt><i>apply=</i></dt>
1111 <dd>
1112 flag indicating, that the fix should be applied
1113 (boolean)
1114 </dd>
1115 </dl><dl>
1116 <dt>Returns:</dt>
1117 <dd>
1118 value indicating an applied/deferred fix (-1, 0, 1),
1119 a message for the fix (string) and an ID for a deferred
1120 fix (integer)
1121 </dd>
1122 </dl><a NAME="CodeStyleFixer.__fixE401" ID="CodeStyleFixer.__fixE401"></a>
1123 <h4>CodeStyleFixer.__fixE401</h4>
1124 <b>__fixE401</b>(<i>code, line, pos, apply=False</i>)
1125 <p>
1126 Private method to fix multiple imports on one line.
1127 </p><p>
1128 Codes: E401
1129 </p><dl>
1130 <dt><i>code</i></dt>
1131 <dd>
1132 code of the issue (string)
1133 </dd><dt><i>line</i></dt>
1134 <dd>
1135 line number of the issue (integer)
1136 </dd><dt><i>pos</i></dt>
1137 <dd>
1138 position inside line (integer)
1139 </dd><dt><i>apply=</i></dt>
1140 <dd>
1141 flag indicating, that the fix should be applied
1142 (boolean)
1143 </dd>
1144 </dl><dl>
1145 <dt>Returns:</dt>
1146 <dd>
1147 value indicating an applied/deferred fix (-1, 0, 1),
1148 a message for the fix (string) and an ID for a deferred
1149 fix (integer)
1150 </dd>
1151 </dl><a NAME="CodeStyleFixer.__fixE501" ID="CodeStyleFixer.__fixE501"></a>
1152 <h4>CodeStyleFixer.__fixE501</h4>
1153 <b>__fixE501</b>(<i>code, line, pos, apply=False</i>)
1154 <p>
1155 Private method to fix the long lines by breaking them.
1156 </p><p>
1157 Codes: E501
1158 </p><dl>
1159 <dt><i>code</i></dt>
1160 <dd>
1161 code of the issue (string)
1162 </dd><dt><i>line</i></dt>
1163 <dd>
1164 line number of the issue (integer)
1165 </dd><dt><i>pos</i></dt>
1166 <dd>
1167 position inside line (integer)
1168 </dd><dt><i>apply=</i></dt>
1169 <dd>
1170 flag indicating, that the fix should be applied
1171 (boolean)
1172 </dd>
1173 </dl><dl>
1174 <dt>Returns:</dt>
1175 <dd>
1176 value indicating an applied/deferred fix (-1, 0, 1),
1177 a message for the fix (string) and an ID for a deferred
1178 fix (integer)
1179 </dd>
1180 </dl><a NAME="CodeStyleFixer.__fixE502" ID="CodeStyleFixer.__fixE502"></a>
1181 <h4>CodeStyleFixer.__fixE502</h4>
1182 <b>__fixE502</b>(<i>code, line, pos</i>)
1183 <p>
1184 Private method to fix redundant backslash within brackets.
1185 </p><p>
1186 Codes: E502
1187 </p><dl>
1188 <dt><i>code</i></dt>
1189 <dd>
1190 code of the issue (string)
1191 </dd><dt><i>line</i></dt>
1192 <dd>
1193 line number of the issue (integer)
1194 </dd><dt><i>pos</i></dt>
1195 <dd>
1196 position inside line (integer)
1197 </dd>
1198 </dl><dl>
1199 <dt>Returns:</dt>
1200 <dd>
1201 value indicating an applied/deferred fix (-1, 0, 1),
1202 a message for the fix (string) and an ID for a deferred
1203 fix (integer)
1204 </dd>
1205 </dl><a NAME="CodeStyleFixer.__fixE701" ID="CodeStyleFixer.__fixE701"></a>
1206 <h4>CodeStyleFixer.__fixE701</h4>
1207 <b>__fixE701</b>(<i>code, line, pos, apply=False</i>)
1208 <p>
1209 Private method to fix colon-separated compound statements.
1210 </p><p>
1211 Codes: E701
1212 </p><dl>
1213 <dt><i>code</i></dt>
1214 <dd>
1215 code of the issue (string)
1216 </dd><dt><i>line</i></dt>
1217 <dd>
1218 line number of the issue (integer)
1219 </dd><dt><i>pos</i></dt>
1220 <dd>
1221 position inside line (integer)
1222 </dd><dt><i>apply=</i></dt>
1223 <dd>
1224 flag indicating, that the fix should be applied
1225 (boolean)
1226 </dd>
1227 </dl><dl>
1228 <dt>Returns:</dt>
1229 <dd>
1230 value indicating an applied/deferred fix (-1, 0, 1),
1231 a message for the fix (string) and an ID for a deferred
1232 fix (integer)
1233 </dd>
1234 </dl><a NAME="CodeStyleFixer.__fixE702" ID="CodeStyleFixer.__fixE702"></a>
1235 <h4>CodeStyleFixer.__fixE702</h4>
1236 <b>__fixE702</b>(<i>code, line, pos, apply=False</i>)
1237 <p>
1238 Private method to fix semicolon-separated compound statements.
1239 </p><p>
1240 Codes: E702, E703
1241 </p><dl>
1242 <dt><i>code</i></dt>
1243 <dd>
1244 code of the issue (string)
1245 </dd><dt><i>line</i></dt>
1246 <dd>
1247 line number of the issue (integer)
1248 </dd><dt><i>pos</i></dt>
1249 <dd>
1250 position inside line (integer)
1251 </dd><dt><i>apply=</i></dt>
1252 <dd>
1253 flag indicating, that the fix should be applied
1254 (boolean)
1255 </dd>
1256 </dl><dl>
1257 <dt>Returns:</dt>
1258 <dd>
1259 value indicating an applied/deferred fix (-1, 0, 1),
1260 a message for the fix (string) and an ID for a deferred
1261 fix (integer)
1262 </dd>
1263 </dl><a NAME="CodeStyleFixer.__fixE711" ID="CodeStyleFixer.__fixE711"></a>
1264 <h4>CodeStyleFixer.__fixE711</h4>
1265 <b>__fixE711</b>(<i>code, line, pos</i>)
1266 <p>
1267 Private method to fix comparison with None.
1268 </p><p>
1269 Codes: E711, E712
1270 </p><dl>
1271 <dt><i>code</i></dt>
1272 <dd>
1273 code of the issue (string)
1274 </dd><dt><i>line</i></dt>
1275 <dd>
1276 line number of the issue (integer)
1277 </dd><dt><i>pos</i></dt>
1278 <dd>
1279 position inside line (integer)
1280 </dd>
1281 </dl><dl>
1282 <dt>Returns:</dt>
1283 <dd>
1284 value indicating an applied/deferred fix (-1, 0, 1),
1285 a message for the fix (string) and an ID for a deferred
1286 fix (integer)
1287 </dd>
1288 </dl><a NAME="CodeStyleFixer.__fixN804" ID="CodeStyleFixer.__fixN804"></a>
1289 <h4>CodeStyleFixer.__fixN804</h4>
1290 <b>__fixN804</b>(<i>code, line, pos, apply=False</i>)
1291 <p>
1292 Private method to fix a wrong first argument of normal and
1293 class methods.
1294 </p><p>
1295 Codes: N804, N805
1296 </p><dl>
1297 <dt><i>code</i></dt>
1298 <dd>
1299 code of the issue (string)
1300 </dd><dt><i>line</i></dt>
1301 <dd>
1302 line number of the issue (integer)
1303 </dd><dt><i>pos</i></dt>
1304 <dd>
1305 position inside line (integer)
1306 </dd><dt><i>apply=</i></dt>
1307 <dd>
1308 flag indicating, that the fix should be applied
1309 (boolean)
1310 </dd>
1311 </dl><dl>
1312 <dt>Returns:</dt>
1313 <dd>
1314 value indicating an applied/deferred fix (-1, 0, 1),
1315 a message for the fix (string) and an ID for a deferred
1316 fix (integer)
1317 </dd>
1318 </dl><a NAME="CodeStyleFixer.__fixN806" ID="CodeStyleFixer.__fixN806"></a>
1319 <h4>CodeStyleFixer.__fixN806</h4>
1320 <b>__fixN806</b>(<i>code, line, pos, apply=False</i>)
1321 <p>
1322 Private method to fix a wrong first argument of static methods.
1323 </p><p>
1324 Codes: N806
1325 </p><dl>
1326 <dt><i>code</i></dt>
1327 <dd>
1328 code of the issue (string)
1329 </dd><dt><i>line</i></dt>
1330 <dd>
1331 line number of the issue (integer)
1332 </dd><dt><i>pos</i></dt>
1333 <dd>
1334 position inside line (integer)
1335 </dd><dt><i>apply=</i></dt>
1336 <dd>
1337 flag indicating, that the fix should be applied
1338 (boolean)
1339 </dd>
1340 </dl><dl>
1341 <dt>Returns:</dt>
1342 <dd>
1343 value indicating an applied/deferred fix (-1, 0, 1),
1344 a message for the fix (string) and an ID for a deferred
1345 fix (integer)
1346 </dd>
1347 </dl><a NAME="CodeStyleFixer.__fixReindent" ID="CodeStyleFixer.__fixReindent"></a>
1348 <h4>CodeStyleFixer.__fixReindent</h4>
1349 <b>__fixReindent</b>(<i>line, pos, logical</i>)
1350 <p>
1351 Private method to fix a badly indented line.
1352 </p><p>
1353 This is done by adding or removing from its initial indent only.
1354 </p><dl>
1355 <dt><i>line</i></dt>
1356 <dd>
1357 line number of the issue (integer)
1358 </dd><dt><i>pos</i></dt>
1359 <dd>
1360 position inside line (integer)
1361 </dd><dt><i>logical</i></dt>
1362 <dd>
1363 logical line structure
1364 </dd>
1365 </dl><dl>
1366 <dt>Returns:</dt>
1367 <dd>
1368 flag indicating a change was done (boolean)
1369 </dd>
1370 </dl><a NAME="CodeStyleFixer.__fixW291" ID="CodeStyleFixer.__fixW291"></a>
1371 <h4>CodeStyleFixer.__fixW291</h4>
1372 <b>__fixW291</b>(<i>code, line, pos</i>)
1373 <p>
1374 Private method to fix trailing whitespace.
1375 </p><p>
1376 Codes: W291, W293
1377 </p><dl>
1378 <dt><i>code</i></dt>
1379 <dd>
1380 code of the issue (string)
1381 </dd><dt><i>line</i></dt>
1382 <dd>
1383 line number of the issue (integer)
1384 </dd><dt><i>pos</i></dt>
1385 <dd>
1386 position inside line (integer)
1387 </dd>
1388 </dl><dl>
1389 <dt>Returns:</dt>
1390 <dd>
1391 value indicating an applied/deferred fix (-1, 0, 1),
1392 a message for the fix (string) and an ID for a deferred
1393 fix (integer)
1394 </dd>
1395 </dl><a NAME="CodeStyleFixer.__fixW292" ID="CodeStyleFixer.__fixW292"></a>
1396 <h4>CodeStyleFixer.__fixW292</h4>
1397 <b>__fixW292</b>(<i>code, line, pos</i>)
1398 <p>
1399 Private method to fix a missing newline at the end of file.
1400 </p><p>
1401 Codes: W292
1402 </p><dl>
1403 <dt><i>code</i></dt>
1404 <dd>
1405 code of the issue (string)
1406 </dd><dt><i>line</i></dt>
1407 <dd>
1408 line number of the issue (integer)
1409 </dd><dt><i>pos</i></dt>
1410 <dd>
1411 position inside line (integer)
1412 </dd>
1413 </dl><dl>
1414 <dt>Returns:</dt>
1415 <dd>
1416 value indicating an applied/deferred fix (-1, 0, 1),
1417 a message for the fix (string) and an ID for a deferred
1418 fix (integer)
1419 </dd>
1420 </dl><a NAME="CodeStyleFixer.__fixW391" ID="CodeStyleFixer.__fixW391"></a>
1421 <h4>CodeStyleFixer.__fixW391</h4>
1422 <b>__fixW391</b>(<i>code, line, pos</i>)
1423 <p>
1424 Private method to fix trailing blank lines.
1425 </p><p>
1426 Codes: W391
1427 </p><dl>
1428 <dt><i>code</i></dt>
1429 <dd>
1430 code of the issue (string)
1431 </dd><dt><i>line</i></dt>
1432 <dd>
1433 line number of the issue (integer)
1434 </dd><dt><i>pos</i></dt>
1435 <dd>
1436 position inside line (integer)
1437 </dd>
1438 </dl><dl>
1439 <dt>Returns:</dt>
1440 <dd>
1441 value indicating an applied/deferred fix (-1, 0, 1),
1442 a message for the fix (string) and an ID for a deferred
1443 fix (integer)
1444 </dd>
1445 </dl><a NAME="CodeStyleFixer.__fixW603" ID="CodeStyleFixer.__fixW603"></a>
1446 <h4>CodeStyleFixer.__fixW603</h4>
1447 <b>__fixW603</b>(<i>code, line, pos</i>)
1448 <p>
1449 Private method to fix the not equal notation.
1450 </p><p>
1451 Codes: W603
1452 </p><dl>
1453 <dt><i>code</i></dt>
1454 <dd>
1455 code of the issue (string)
1456 </dd><dt><i>line</i></dt>
1457 <dd>
1458 line number of the issue (integer)
1459 </dd><dt><i>pos</i></dt>
1460 <dd>
1461 position inside line (integer)
1462 </dd>
1463 </dl><dl>
1464 <dt>Returns:</dt>
1465 <dd>
1466 value indicating an applied/deferred fix (-1, 0, 1),
1467 a message for the fix (string) and an ID for a deferred
1468 fix (integer)
1469 </dd>
1470 </dl><a NAME="CodeStyleFixer.__fixWhitespace" ID="CodeStyleFixer.__fixWhitespace"></a>
1471 <h4>CodeStyleFixer.__fixWhitespace</h4>
1472 <b>__fixWhitespace</b>(<i>line, offset, replacement</i>)
1473 <p>
1474 Private method to correct whitespace at the given offset.
1475 </p><dl>
1476 <dt><i>line</i></dt>
1477 <dd>
1478 line to be corrected (string)
1479 </dd><dt><i>offset</i></dt>
1480 <dd>
1481 offset within line (integer)
1482 </dd><dt><i>replacement</i></dt>
1483 <dd>
1484 replacement string (string)
1485 </dd>
1486 </dl><dl>
1487 <dt>Returns:</dt>
1488 <dd>
1489 corrected line
1490 </dd>
1491 </dl><a NAME="CodeStyleFixer.__getEol" ID="CodeStyleFixer.__getEol"></a>
1492 <h4>CodeStyleFixer.__getEol</h4>
1493 <b>__getEol</b>(<i></i>)
1494 <p>
1495 Private method to get the applicable eol string.
1496 </p><dl>
1497 <dt>Returns:</dt>
1498 <dd>
1499 eol string (string)
1500 </dd>
1501 </dl><a NAME="CodeStyleFixer.__getID" ID="CodeStyleFixer.__getID"></a>
1502 <h4>CodeStyleFixer.__getID</h4>
1503 <b>__getID</b>(<i></i>)
1504 <p>
1505 Private method to get the ID for a deferred fix.
1506 </p><dl>
1507 <dt>Returns:</dt>
1508 <dd>
1509 ID for a deferred fix (integer)
1510 </dd>
1511 </dl><a NAME="CodeStyleFixer.__getIndent" ID="CodeStyleFixer.__getIndent"></a>
1512 <h4>CodeStyleFixer.__getIndent</h4>
1513 <b>__getIndent</b>(<i>line</i>)
1514 <p>
1515 Private method to get the indentation string.
1516 </p><dl>
1517 <dt><i>line</i></dt>
1518 <dd>
1519 line to determine the indentation string from (string)
1520 </dd>
1521 </dl><dl>
1522 <dt>Returns:</dt>
1523 <dd>
1524 indentation string (string)
1525 </dd>
1526 </dl><a NAME="CodeStyleFixer.__getIndentWord" ID="CodeStyleFixer.__getIndentWord"></a>
1527 <h4>CodeStyleFixer.__getIndentWord</h4>
1528 <b>__getIndentWord</b>(<i></i>)
1529 <p>
1530 Private method to determine the indentation type.
1531 </p><dl>
1532 <dt>Returns:</dt>
1533 <dd>
1534 string to be used for an indentation (string)
1535 </dd>
1536 </dl><a NAME="CodeStyleFixer.__getLogical" ID="CodeStyleFixer.__getLogical"></a>
1537 <h4>CodeStyleFixer.__getLogical</h4>
1538 <b>__getLogical</b>(<i>line, pos</i>)
1539 <p>
1540 Private method to get the logical line corresponding to the given
1541 position.
1542 </p><dl>
1543 <dt><i>line</i></dt>
1544 <dd>
1545 line number of the issue (integer)
1546 </dd><dt><i>pos</i></dt>
1547 <dd>
1548 position inside line (integer)
1549 </dd>
1550 </dl><dl>
1551 <dt>Returns:</dt>
1552 <dd>
1553 tuple of a tuple of two integers giving the start of the
1554 logical line, another tuple of two integers giving the end
1555 of the logical line and a list of strings with the original
1556 source lines
1557 </dd>
1558 </dl><a NAME="CodeStyleFixer.__multilineStringLines" ID="CodeStyleFixer.__multilineStringLines"></a>
1559 <h4>CodeStyleFixer.__multilineStringLines</h4>
1560 <b>__multilineStringLines</b>(<i></i>)
1561 <p>
1562 Private method to determine the line numbers that are within multi line
1563 strings and these which are part of a documentation string.
1564 </p><dl>
1565 <dt>Returns:</dt>
1566 <dd>
1567 tuple of a set of line numbers belonging to a multi line
1568 string and a set of line numbers belonging to a multi line
1569 documentation string (tuple of two set of integer)
1570 </dd>
1571 </dl><a NAME="CodeStyleFixer.finalize" ID="CodeStyleFixer.finalize"></a>
1572 <h4>CodeStyleFixer.finalize</h4>
1573 <b>finalize</b>(<i></i>)
1574 <p>
1575 Public method to apply all deferred fixes.
1576 </p><dl>
1577 <dt>Returns:</dt>
1578 <dd>
1579 dictionary containing the fix results
1580 </dd>
1581 </dl><a NAME="CodeStyleFixer.fixIssue" ID="CodeStyleFixer.fixIssue"></a>
1582 <h4>CodeStyleFixer.fixIssue</h4>
1583 <b>fixIssue</b>(<i>line, pos, message</i>)
1584 <p>
1585 Public method to fix the fixable issues.
1586 </p><dl>
1587 <dt><i>line</i></dt>
1588 <dd>
1589 line number of issue (integer)
1590 </dd><dt><i>pos</i></dt>
1591 <dd>
1592 character position of issue (integer)
1593 </dd><dt><i>message</i></dt>
1594 <dd>
1595 message text (string)
1596 </dd>
1597 </dl><dl>
1598 <dt>Returns:</dt>
1599 <dd>
1600 value indicating an applied/deferred fix (-1, 0, 1),
1601 a message for the fix (string) and an ID for a deferred
1602 fix (integer)
1603 </dd>
1604 </dl><a NAME="CodeStyleFixer.mutualStartswith" ID="CodeStyleFixer.mutualStartswith"></a>
1605 <h4>CodeStyleFixer.mutualStartswith</h4>
1606 <b>mutualStartswith</b>(<i>b</i>)
1607 <p>
1608 Local helper method to compare the beginnings of two strings
1609 against each other.
1610 </p><dl>
1611 <dt>Returns:</dt>
1612 <dd>
1613 flag indicating that one string starts with the other
1614 (boolean)
1615 </dd>
1616 </dl><a NAME="CodeStyleFixer.saveFile" ID="CodeStyleFixer.saveFile"></a>
1617 <h4>CodeStyleFixer.saveFile</h4>
1618 <b>saveFile</b>(<i>encoding</i>)
1619 <p>
1620 Public method to save the modified file.
1621 </p><dl>
1622 <dt><i>encoding</i></dt>
1623 <dd>
1624 encoding of the source file (string)
1625 </dd>
1626 </dl><dl>
1627 <dt>Returns:</dt>
1628 <dd>
1629 flag indicating success (boolean)
1630 </dd>
1631 </dl>
1632 <div align="right"><a href="#top">Up</a></div>
1633 <hr /><hr />
1634 <a NAME="IndentationWrapper" ID="IndentationWrapper"></a>
1635 <h2>IndentationWrapper</h2>
1636 <p>
1637 Class used by fixers dealing with indentation.
1638 </p><p>
1639 Each instance operates on a single logical line.
1640 </p>
1641 <h3>Derived from</h3>
1642 object
1643 <h3>Class Attributes</h3>
1644 <table>
1645 <tr><td>SKIP_TOKENS</td></tr>
1646 </table>
1647 <h3>Class Methods</h3>
1648 <table>
1649 <tr><td>None</td></tr>
1650 </table>
1651 <h3>Methods</h3>
1652 <table>
1653 <tr>
1654 <td><a href="#IndentationWrapper.__init__">IndentationWrapper</a></td>
1655 <td>Constructor</td>
1656 </tr><tr>
1657 <td><a href="#IndentationWrapper.__buildTokensLogical">__buildTokensLogical</a></td>
1658 <td>Private method to build a logical line from a list of tokens.</td>
1659 </tr><tr>
1660 <td><a href="#IndentationWrapper.pep8Expected">pep8Expected</a></td>
1661 <td>Public method to replicate logic in pep8.py, to know what level to indent things to.</td>
1662 </tr>
1663 </table>
1664 <h3>Static Methods</h3>
1665 <table>
1666 <tr><td>None</td></tr>
1667 </table>
1668 <a NAME="IndentationWrapper.__init__" ID="IndentationWrapper.__init__"></a>
1669 <h4>IndentationWrapper (Constructor)</h4>
1670 <b>IndentationWrapper</b>(<i>physical_lines</i>)
1671 <p>
1672 Constructor
1673 </p><dl>
1674 <dt><i>physical_lines</i></dt>
1675 <dd>
1676 list of physical lines to operate on
1677 (list of strings)
1678 </dd>
1679 </dl><a NAME="IndentationWrapper.__buildTokensLogical" ID="IndentationWrapper.__buildTokensLogical"></a>
1680 <h4>IndentationWrapper.__buildTokensLogical</h4>
1681 <b>__buildTokensLogical</b>(<i>tokens</i>)
1682 <p>
1683 Private method to build a logical line from a list of tokens.
1684 </p><dl>
1685 <dt><i>tokens</i></dt>
1686 <dd>
1687 list of tokens as generated by tokenize.generate_tokens
1688 </dd>
1689 </dl><dl>
1690 <dt>Returns:</dt>
1691 <dd>
1692 logical line (string)
1693 </dd>
1694 </dl><a NAME="IndentationWrapper.pep8Expected" ID="IndentationWrapper.pep8Expected"></a>
1695 <h4>IndentationWrapper.pep8Expected</h4>
1696 <b>pep8Expected</b>(<i></i>)
1697 <p>
1698 Public method to replicate logic in pep8.py, to know what level to
1699 indent things to.
1700 </p><dl>
1701 <dt>Returns:</dt>
1702 <dd>
1703 list of lists, where each list represents valid indent levels
1704 for the line in question, relative from the initial indent. However,
1705 the first entry is the indent level which was expected.
1706 </dd>
1707 </dl>
1708 <div align="right"><a href="#top">Up</a></div>
1709 <hr /><hr />
1710 <a NAME="LineShortener" ID="LineShortener"></a>
1711 <h2>LineShortener</h2>
1712 <p>
1713 Class used to shorten lines to a given maximum of characters.
1714 </p>
1715 <h3>Derived from</h3>
1716 object
1717 <h3>Class Attributes</h3>
1718 <table>
1719 <tr><td>None</td></tr>
1720 </table>
1721 <h3>Class Methods</h3>
1722 <table>
1723 <tr><td>None</td></tr>
1724 </table>
1725 <h3>Methods</h3>
1726 <table>
1727 <tr>
1728 <td><a href="#LineShortener.__init__">LineShortener</a></td>
1729 <td>Constructor</td>
1730 </tr><tr>
1731 <td><a href="#LineShortener.__breakMultiline">__breakMultiline</a></td>
1732 <td>Private method to break multi line strings.</td>
1733 </tr><tr>
1734 <td><a href="#LineShortener.__checkSyntax">__checkSyntax</a></td>
1735 <td>Private method to check the syntax of the given code fragment.</td>
1736 </tr><tr>
1737 <td><a href="#LineShortener.__countUnbalancedBrackets">__countUnbalancedBrackets</a></td>
1738 <td>Private method to determine the number of unmatched open/close brackets.</td>
1739 </tr><tr>
1740 <td><a href="#LineShortener.__getIndent">__getIndent</a></td>
1741 <td>Private method to get the indentation string.</td>
1742 </tr><tr>
1743 <td><a href="#LineShortener.__isProbablyInsideStringOrComment">__isProbablyInsideStringOrComment</a></td>
1744 <td>Private method to check, if the given string might be inside a string or comment.</td>
1745 </tr><tr>
1746 <td><a href="#LineShortener.__lineShorteningRank">__lineShorteningRank</a></td>
1747 <td>Private method to rank a candidate.</td>
1748 </tr><tr>
1749 <td><a href="#LineShortener.__normalizeMultiline">__normalizeMultiline</a></td>
1750 <td>Private method to remove multiline-related code that will cause syntax error.</td>
1751 </tr><tr>
1752 <td><a href="#LineShortener.__shortenComment">__shortenComment</a></td>
1753 <td>Private method to shorten a comment line.</td>
1754 </tr><tr>
1755 <td><a href="#LineShortener.__shortenLine">__shortenLine</a></td>
1756 <td>Private method to shorten a line of code at an operator.</td>
1757 </tr><tr>
1758 <td><a href="#LineShortener.shorten">shorten</a></td>
1759 <td>Public method to shorten the line wrapped by the class instance.</td>
1760 </tr>
1761 </table>
1762 <h3>Static Methods</h3>
1763 <table>
1764 <tr><td>None</td></tr>
1765 </table>
1766 <a NAME="LineShortener.__init__" ID="LineShortener.__init__"></a>
1767 <h4>LineShortener (Constructor)</h4>
1768 <b>LineShortener</b>(<i>curLine, prevLine, nextLine, maxLength=79, eol="\n", indentWord=" ", isDocString=False</i>)
1769 <p>
1770 Constructor
1771 </p><dl>
1772 <dt><i>curLine</i></dt>
1773 <dd>
1774 text to work on (string)
1775 </dd><dt><i>prevLine</i></dt>
1776 <dd>
1777 line before the text to work on (string)
1778 </dd><dt><i>nextLine</i></dt>
1779 <dd>
1780 line after the text to work on (string)
1781 </dd><dt><i>maxLength=</i></dt>
1782 <dd>
1783 maximum allowed line length (integer)
1784 </dd><dt><i>eol=</i></dt>
1785 <dd>
1786 eond-of-line marker (string)
1787 </dd><dt><i>indentWord=</i></dt>
1788 <dd>
1789 string used for indentation (string)
1790 </dd><dt><i>isDocString=</i></dt>
1791 <dd>
1792 flag indicating that the line belongs to
1793 a documentation string (boolean)
1794 </dd>
1795 </dl><a NAME="LineShortener.__breakMultiline" ID="LineShortener.__breakMultiline"></a>
1796 <h4>LineShortener.__breakMultiline</h4>
1797 <b>__breakMultiline</b>(<i></i>)
1798 <p>
1799 Private method to break multi line strings.
1800 </p><dl>
1801 <dt>Returns:</dt>
1802 <dd>
1803 tuple of the shortened line and the changed next line
1804 (string, string)
1805 </dd>
1806 </dl><a NAME="LineShortener.__checkSyntax" ID="LineShortener.__checkSyntax"></a>
1807 <h4>LineShortener.__checkSyntax</h4>
1808 <b>__checkSyntax</b>(<i>code</i>)
1809 <p>
1810 Private method to check the syntax of the given code fragment.
1811 </p><dl>
1812 <dt><i>code</i></dt>
1813 <dd>
1814 code fragment to check (string)
1815 </dd>
1816 </dl><dl>
1817 <dt>Returns:</dt>
1818 <dd>
1819 flag indicating syntax is ok (boolean)
1820 </dd>
1821 </dl><a NAME="LineShortener.__countUnbalancedBrackets" ID="LineShortener.__countUnbalancedBrackets"></a>
1822 <h4>LineShortener.__countUnbalancedBrackets</h4>
1823 <b>__countUnbalancedBrackets</b>(<i>line</i>)
1824 <p>
1825 Private method to determine the number of unmatched open/close
1826 brackets.
1827 </p><dl>
1828 <dt><i>line</i></dt>
1829 <dd>
1830 line to work at (string)
1831 </dd>
1832 </dl><dl>
1833 <dt>Returns:</dt>
1834 <dd>
1835 number of unmatched open/close brackets (integer)
1836 </dd>
1837 </dl><a NAME="LineShortener.__getIndent" ID="LineShortener.__getIndent"></a>
1838 <h4>LineShortener.__getIndent</h4>
1839 <b>__getIndent</b>(<i>line</i>)
1840 <p>
1841 Private method to get the indentation string.
1842 </p><dl>
1843 <dt><i>line</i></dt>
1844 <dd>
1845 line to determine the indentation string from (string)
1846 </dd>
1847 </dl><dl>
1848 <dt>Returns:</dt>
1849 <dd>
1850 indentation string (string)
1851 </dd>
1852 </dl><a NAME="LineShortener.__isProbablyInsideStringOrComment" ID="LineShortener.__isProbablyInsideStringOrComment"></a>
1853 <h4>LineShortener.__isProbablyInsideStringOrComment</h4>
1854 <b>__isProbablyInsideStringOrComment</b>(<i>line, index</i>)
1855 <p>
1856 Private method to check, if the given string might be inside a string
1857 or comment.
1858 </p><dl>
1859 <dt><i>line</i></dt>
1860 <dd>
1861 line to check (string)
1862 </dd><dt><i>index</i></dt>
1863 <dd>
1864 position inside line to check (integer)
1865 </dd>
1866 </dl><dl>
1867 <dt>Returns:</dt>
1868 <dd>
1869 flag indicating the possibility of being inside a string
1870 or comment
1871 </dd>
1872 </dl><a NAME="LineShortener.__lineShorteningRank" ID="LineShortener.__lineShorteningRank"></a>
1873 <h4>LineShortener.__lineShorteningRank</h4>
1874 <b>__lineShorteningRank</b>(<i>candidate</i>)
1875 <p>
1876 Private method to rank a candidate.
1877 </p><dl>
1878 <dt><i>candidate</i></dt>
1879 <dd>
1880 candidate line to rank (string)
1881 </dd>
1882 </dl><dl>
1883 <dt>Returns:</dt>
1884 <dd>
1885 rank of the candidate (integer)
1886 </dd>
1887 </dl><a NAME="LineShortener.__normalizeMultiline" ID="LineShortener.__normalizeMultiline"></a>
1888 <h4>LineShortener.__normalizeMultiline</h4>
1889 <b>__normalizeMultiline</b>(<i>text</i>)
1890 <p>
1891 Private method to remove multiline-related code that will cause syntax
1892 error.
1893 </p><dl>
1894 <dt><i>text</i></dt>
1895 <dd>
1896 code line to work on (string)
1897 </dd>
1898 </dl><dl>
1899 <dt>Returns:</dt>
1900 <dd>
1901 normalized code line (string)
1902 </dd>
1903 </dl><a NAME="LineShortener.__shortenComment" ID="LineShortener.__shortenComment"></a>
1904 <h4>LineShortener.__shortenComment</h4>
1905 <b>__shortenComment</b>(<i>isLast</i>)
1906 <p>
1907 Private method to shorten a comment line.
1908 </p><dl>
1909 <dt><i>isLast</i></dt>
1910 <dd>
1911 flag indicating, that the line is the last comment line
1912 (boolean)
1913 </dd>
1914 </dl><dl>
1915 <dt>Returns:</dt>
1916 <dd>
1917 shortened comment line (string)
1918 </dd>
1919 </dl><a NAME="LineShortener.__shortenLine" ID="LineShortener.__shortenLine"></a>
1920 <h4>LineShortener.__shortenLine</h4>
1921 <b>__shortenLine</b>(<i>tokens, source, indent</i>)
1922 <p>
1923 Private method to shorten a line of code at an operator.
1924 </p><dl>
1925 <dt><i>tokens</i></dt>
1926 <dd>
1927 tokens of the line as generated by tokenize
1928 (list of token)
1929 </dd><dt><i>source</i></dt>
1930 <dd>
1931 code string to work at (string)
1932 </dd><dt><i>indent</i></dt>
1933 <dd>
1934 indentation string of the code line (string)
1935 </dd>
1936 </dl><dl>
1937 <dt>Returns:</dt>
1938 <dd>
1939 list of candidates (list of string)
1940 </dd>
1941 </dl><a NAME="LineShortener.shorten" ID="LineShortener.shorten"></a>
1942 <h4>LineShortener.shorten</h4>
1943 <b>shorten</b>(<i></i>)
1944 <p>
1945 Public method to shorten the line wrapped by the class instance.
1946 </p><dl>
1947 <dt>Returns:</dt>
1948 <dd>
1949 tuple of a flag indicating successful shortening, the
1950 shortened line and the changed next line (boolean, string, string)
1951 </dd>
1952 </dl>
1953 <div align="right"><a href="#top">Up</a></div>
1954 <hr /><hr />
1955 <a NAME="Reindenter" ID="Reindenter"></a>
1956 <h2>Reindenter</h2>
1957 <p>
1958 Class to reindent badly-indented code to uniformly use four-space
1959 indentation.
1960 </p><p>
1961 Released to the public domain, by Tim Peters, 03 October 2000.
1962 </p>
1963 <h3>Derived from</h3>
1964 object
1965 <h3>Class Attributes</h3>
1966 <table>
1967 <tr><td>None</td></tr>
1968 </table>
1969 <h3>Class Methods</h3>
1970 <table>
1971 <tr><td>None</td></tr>
1972 </table>
1973 <h3>Methods</h3>
1974 <table>
1975 <tr>
1976 <td><a href="#Reindenter.__init__">Reindenter</a></td>
1977 <td>Constructor</td>
1978 </tr><tr>
1979 <td><a href="#Reindenter.__genStats">__genStats</a></td>
1980 <td>Private method to generate the re-indent statistics.</td>
1981 </tr><tr>
1982 <td><a href="#Reindenter.__getlspace">__getlspace</a></td>
1983 <td>Private method to count number of leading blanks.</td>
1984 </tr><tr>
1985 <td><a href="#Reindenter.fixedLine">fixedLine</a></td>
1986 <td>Public method to get a fixed line.</td>
1987 </tr><tr>
1988 <td><a href="#Reindenter.getline">getline</a></td>
1989 <td>Public method to get a line of text for tokenize.</td>
1990 </tr><tr>
1991 <td><a href="#Reindenter.run">run</a></td>
1992 <td>Public method to run the re-indenter.</td>
1993 </tr>
1994 </table>
1995 <h3>Static Methods</h3>
1996 <table>
1997 <tr><td>None</td></tr>
1998 </table>
1999 <a NAME="Reindenter.__init__" ID="Reindenter.__init__"></a>
2000 <h4>Reindenter (Constructor)</h4>
2001 <b>Reindenter</b>(<i>sourceLines</i>)
2002 <p>
2003 Constructor
2004 </p><dl>
2005 <dt><i>sourceLines</i></dt>
2006 <dd>
2007 list of source lines including eol marker
2008 (list of string)
2009 </dd>
2010 </dl><a NAME="Reindenter.__genStats" ID="Reindenter.__genStats"></a>
2011 <h4>Reindenter.__genStats</h4>
2012 <b>__genStats</b>(<i>tokens</i>)
2013 <p>
2014 Private method to generate the re-indent statistics.
2015 </p><dl>
2016 <dt><i>tokens</i></dt>
2017 <dd>
2018 tokens generator (tokenize._tokenize)
2019 </dd>
2020 </dl><dl>
2021 <dt>Returns:</dt>
2022 <dd>
2023 reference to the generated statistics
2024 </dd>
2025 </dl><a NAME="Reindenter.__getlspace" ID="Reindenter.__getlspace"></a>
2026 <h4>Reindenter.__getlspace</h4>
2027 <b>__getlspace</b>(<i>line</i>)
2028 <p>
2029 Private method to count number of leading blanks.
2030 </p><dl>
2031 <dt><i>line</i></dt>
2032 <dd>
2033 line to check (string)
2034 </dd>
2035 </dl><dl>
2036 <dt>Returns:</dt>
2037 <dd>
2038 number of leading blanks (integer)
2039 </dd>
2040 </dl><a NAME="Reindenter.fixedLine" ID="Reindenter.fixedLine"></a>
2041 <h4>Reindenter.fixedLine</h4>
2042 <b>fixedLine</b>(<i>line</i>)
2043 <p>
2044 Public method to get a fixed line.
2045 </p><dl>
2046 <dt><i>line</i></dt>
2047 <dd>
2048 number of the line to retrieve (integer)
2049 </dd>
2050 </dl><dl>
2051 <dt>Returns:</dt>
2052 <dd>
2053 fixed line (string)
2054 </dd>
2055 </dl><a NAME="Reindenter.getline" ID="Reindenter.getline"></a>
2056 <h4>Reindenter.getline</h4>
2057 <b>getline</b>(<i></i>)
2058 <p>
2059 Public method to get a line of text for tokenize.
2060 </p><dl>
2061 <dt>Returns:</dt>
2062 <dd>
2063 line of text (string)
2064 </dd>
2065 </dl><a NAME="Reindenter.run" ID="Reindenter.run"></a>
2066 <h4>Reindenter.run</h4>
2067 <b>run</b>(<i></i>)
2068 <p>
2069 Public method to run the re-indenter.
2070 </p><dl>
2071 <dt>Returns:</dt>
2072 <dd>
2073 flag indicating that a change was done (boolean)
2074 </dd>
2075 </dl>
2076 <div align="right"><a href="#top">Up</a></div>
2077 <hr />
2078 </body></html>

eric ide

mercurial