73 <td>Private method to check, if the code should be fixed.</td> |
73 <td>Private method to check, if the code should be fixed.</td> |
74 </tr><tr> |
74 </tr><tr> |
75 <td><a href="#CodeStyleFixer.__findLogical">__findLogical</a></td> |
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> |
76 <td>Private method to extract the index of all the starts and ends of lines.</td> |
77 </tr><tr> |
77 </tr><tr> |
|
78 <td><a href="#CodeStyleFixer.__fixBlankLinesBefore">__fixBlankLinesBefore</a></td> |
|
79 <td>Private method to fix the need for blank lines before class, function and method definitions.</td> |
|
80 </tr><tr> |
78 <td><a href="#CodeStyleFixer.__fixD111">__fixD111</a></td> |
81 <td><a href="#CodeStyleFixer.__fixD111">__fixD111</a></td> |
79 <td>Private method to fix docstring enclosed in wrong quotes.</td> |
82 <td>Private method to fix docstring enclosed in wrong quotes.</td> |
80 </tr><tr> |
83 </tr><tr> |
81 <td><a href="#CodeStyleFixer.__fixD112">__fixD112</a></td> |
84 <td><a href="#CodeStyleFixer.__fixD112">__fixD112</a></td> |
82 <td>Private method to fix docstring 'r' or 'u' in leading quotes.</td> |
85 <td>Private method to fix docstring 'r' or 'u' in leading quotes.</td> |
147 <td><a href="#CodeStyleFixer.__fixE251">__fixE251</a></td> |
150 <td><a href="#CodeStyleFixer.__fixE251">__fixE251</a></td> |
148 <td>Private method to fix extraneous whitespace around keyword and default parameter equals.</td> |
151 <td>Private method to fix extraneous whitespace around keyword and default parameter equals.</td> |
149 </tr><tr> |
152 </tr><tr> |
150 <td><a href="#CodeStyleFixer.__fixE261">__fixE261</a></td> |
153 <td><a href="#CodeStyleFixer.__fixE261">__fixE261</a></td> |
151 <td>Private method to fix whitespace before or after inline comment.</td> |
154 <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> |
155 </tr><tr> |
162 <td><a href="#CodeStyleFixer.__fixE304">__fixE304</a></td> |
156 <td><a href="#CodeStyleFixer.__fixE304">__fixE304</a></td> |
163 <td>Private method to fix superfluous blank lines after a function decorator.</td> |
157 <td>Private method to fix superfluous blank lines after a function decorator.</td> |
164 </tr><tr> |
158 </tr><tr> |
165 <td><a href="#CodeStyleFixer.__fixE401">__fixE401</a></td> |
159 <td><a href="#CodeStyleFixer.__fixE401">__fixE401</a></td> |
236 <table> |
230 <table> |
237 <tr><td>None</td></tr> |
231 <tr><td>None</td></tr> |
238 </table> |
232 </table> |
239 <a NAME="CodeStyleFixer.__init__" ID="CodeStyleFixer.__init__"></a> |
233 <a NAME="CodeStyleFixer.__init__" ID="CodeStyleFixer.__init__"></a> |
240 <h4>CodeStyleFixer (Constructor)</h4> |
234 <h4>CodeStyleFixer (Constructor)</h4> |
241 <b>CodeStyleFixer</b>(<i>filename, sourceLines, fixCodes, noFixCodes, maxLineLength, inPlace, eol, backup=False</i>) |
235 <b>CodeStyleFixer</b>(<i>filename, sourceLines, fixCodes, noFixCodes, maxLineLength, blankLines, inPlace, eol, backup=False</i>) |
242 <p> |
236 <p> |
243 Constructor |
237 Constructor |
244 </p><dl> |
238 </p><dl> |
245 <dt><i>filename</i></dt> |
239 <dt><i>filename</i> (str)</dt> |
246 <dd> |
240 <dd> |
247 name of the file to be fixed (string) |
241 name of the file to be fixed |
248 </dd><dt><i>sourceLines</i></dt> |
242 </dd><dt><i>sourceLines</i> (list of str)</dt> |
249 <dd> |
243 <dd> |
250 list of source lines including eol marker |
244 list of source lines including eol marker |
251 (list of string) |
245 </dd><dt><i>fixCodes</i> (str)</dt> |
252 </dd><dt><i>fixCodes</i></dt> |
|
253 <dd> |
246 <dd> |
254 list of codes to be fixed as a comma separated |
247 list of codes to be fixed as a comma separated |
255 string (string) |
248 string |
256 </dd><dt><i>noFixCodes</i></dt> |
249 </dd><dt><i>noFixCodes</i> (str)</dt> |
257 <dd> |
250 <dd> |
258 list of codes not to be fixed as a comma |
251 list of codes not to be fixed as a comma |
259 separated string (string) |
252 separated string |
260 </dd><dt><i>maxLineLength</i></dt> |
253 </dd><dt><i>maxLineLength</i> (int)</dt> |
261 <dd> |
254 <dd> |
262 maximum allowed line length (integer) |
255 maximum allowed line length |
263 </dd><dt><i>inPlace</i></dt> |
256 </dd><dt><i>blanklines</i> (tuple of (int, int))</dt> |
264 <dd> |
257 <dd> |
265 flag indicating to modify the file in place (boolean) |
258 tuple containg the number of blank lines before |
266 </dd><dt><i>eol</i></dt> |
259 a top level class or function and before a method or nested class |
267 <dd> |
260 or function |
268 end of line character(s) (string) |
261 </dd><dt><i>inPlace</i> (bool)</dt> |
269 </dd><dt><i>backup</i></dt> |
262 <dd> |
|
263 flag indicating to modify the file in place |
|
264 </dd><dt><i>eol</i> (str)</dt> |
|
265 <dd> |
|
266 end of line character(s) |
|
267 </dd><dt><i>backup</i> (bool)</dt> |
270 <dd> |
268 <dd> |
271 flag indicating to create a backup before fixing |
269 flag indicating to create a backup before fixing |
272 anything (boolean) |
270 anything |
273 </dd> |
271 </dd> |
274 </dl><a NAME="CodeStyleFixer.__codeMatch" ID="CodeStyleFixer.__codeMatch"></a> |
272 </dl><a NAME="CodeStyleFixer.__codeMatch" ID="CodeStyleFixer.__codeMatch"></a> |
275 <h4>CodeStyleFixer.__codeMatch</h4> |
273 <h4>CodeStyleFixer.__codeMatch</h4> |
276 <b>__codeMatch</b>(<i>code</i>) |
274 <b>__codeMatch</b>(<i>code</i>) |
277 <p> |
275 <p> |
296 <dt>Returns:</dt> |
294 <dt>Returns:</dt> |
297 <dd> |
295 <dd> |
298 tuple containing two lists of integer with start and end tuples |
296 tuple containing two lists of integer with start and end tuples |
299 of lines |
297 of lines |
300 </dd> |
298 </dd> |
|
299 </dl><a NAME="CodeStyleFixer.__fixBlankLinesBefore" ID="CodeStyleFixer.__fixBlankLinesBefore"></a> |
|
300 <h4>CodeStyleFixer.__fixBlankLinesBefore</h4> |
|
301 <b>__fixBlankLinesBefore</b>(<i>code, line, pos, apply=False</i>) |
|
302 <p> |
|
303 Private method to fix the need for blank lines before class, function |
|
304 and method definitions. |
|
305 </p><p> |
|
306 Codes: E301, E302, E303, E305, E306, E307, E308 |
|
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><dt><i>apply=</i></dt> |
|
318 <dd> |
|
319 flag indicating, that the fix should be applied |
|
320 (boolean) |
|
321 </dd> |
|
322 </dl><dl> |
|
323 <dt>Returns:</dt> |
|
324 <dd> |
|
325 value indicating an applied/deferred fix (-1, 0, 1), |
|
326 a message for the fix (string) and an ID for a deferred |
|
327 fix (integer) |
|
328 </dd> |
301 </dl><a NAME="CodeStyleFixer.__fixD111" ID="CodeStyleFixer.__fixD111"></a> |
329 </dl><a NAME="CodeStyleFixer.__fixD111" ID="CodeStyleFixer.__fixD111"></a> |
302 <h4>CodeStyleFixer.__fixD111</h4> |
330 <h4>CodeStyleFixer.__fixD111</h4> |
303 <b>__fixD111</b>(<i>code, line, pos</i>) |
331 <b>__fixD111</b>(<i>code, line, pos</i>) |
304 <p> |
332 <p> |
305 Private method to fix docstring enclosed in wrong quotes. |
333 Private method to fix docstring enclosed in wrong quotes. |
988 <dd> |
1016 <dd> |
989 line number of the issue (integer) |
1017 line number of the issue (integer) |
990 </dd><dt><i>pos</i></dt> |
1018 </dd><dt><i>pos</i></dt> |
991 <dd> |
1019 <dd> |
992 position inside line (integer) |
1020 position inside line (integer) |
993 </dd> |
|
994 </dl><dl> |
|
995 <dt>Returns:</dt> |
|
996 <dd> |
|
997 value indicating an applied/deferred fix (-1, 0, 1), |
|
998 a message for the fix (string) and an ID for a deferred |
|
999 fix (integer) |
|
1000 </dd> |
|
1001 </dl><a NAME="CodeStyleFixer.__fixE301" ID="CodeStyleFixer.__fixE301"></a> |
|
1002 <h4>CodeStyleFixer.__fixE301</h4> |
|
1003 <b>__fixE301</b>(<i>code, line, pos, apply=False</i>) |
|
1004 <p> |
|
1005 Private method to fix the need for one blank line. |
|
1006 </p><p> |
|
1007 Codes: E301 |
|
1008 </p><dl> |
|
1009 <dt><i>code</i></dt> |
|
1010 <dd> |
|
1011 code of the issue (string) |
|
1012 </dd><dt><i>line</i></dt> |
|
1013 <dd> |
|
1014 line number of the issue (integer) |
|
1015 </dd><dt><i>pos</i></dt> |
|
1016 <dd> |
|
1017 position inside line (integer) |
|
1018 </dd><dt><i>apply=</i></dt> |
|
1019 <dd> |
|
1020 flag indicating, that the fix should be applied |
|
1021 (boolean) |
|
1022 </dd> |
|
1023 </dl><dl> |
|
1024 <dt>Returns:</dt> |
|
1025 <dd> |
|
1026 value indicating an applied/deferred fix (-1, 0, 1), |
|
1027 a message for the fix (string) and an ID for a deferred |
|
1028 fix (integer) |
|
1029 </dd> |
|
1030 </dl><a NAME="CodeStyleFixer.__fixE302" ID="CodeStyleFixer.__fixE302"></a> |
|
1031 <h4>CodeStyleFixer.__fixE302</h4> |
|
1032 <b>__fixE302</b>(<i>code, line, pos, apply=False</i>) |
|
1033 <p> |
|
1034 Private method to fix the need for two blank lines. |
|
1035 </p><p> |
|
1036 Codes: E302 |
|
1037 </p><dl> |
|
1038 <dt><i>code</i></dt> |
|
1039 <dd> |
|
1040 code of the issue (string) |
|
1041 </dd><dt><i>line</i></dt> |
|
1042 <dd> |
|
1043 line number of the issue (integer) |
|
1044 </dd><dt><i>pos</i></dt> |
|
1045 <dd> |
|
1046 position inside line (integer) |
|
1047 </dd><dt><i>apply=</i></dt> |
|
1048 <dd> |
|
1049 flag indicating, that the fix should be applied |
|
1050 (boolean) |
|
1051 </dd> |
|
1052 </dl><dl> |
|
1053 <dt>Returns:</dt> |
|
1054 <dd> |
|
1055 value indicating an applied/deferred fix (-1, 0, 1), |
|
1056 a message for the fix (string) and an ID for a deferred |
|
1057 fix (integer) |
|
1058 </dd> |
|
1059 </dl><a NAME="CodeStyleFixer.__fixE303" ID="CodeStyleFixer.__fixE303"></a> |
|
1060 <h4>CodeStyleFixer.__fixE303</h4> |
|
1061 <b>__fixE303</b>(<i>code, line, pos, apply=False</i>) |
|
1062 <p> |
|
1063 Private method to fix superfluous blank lines. |
|
1064 </p><p> |
|
1065 Codes: E303 |
|
1066 </p><dl> |
|
1067 <dt><i>code</i></dt> |
|
1068 <dd> |
|
1069 code of the issue (string) |
|
1070 </dd><dt><i>line</i></dt> |
|
1071 <dd> |
|
1072 line number of the issue (integer) |
|
1073 </dd><dt><i>pos</i></dt> |
|
1074 <dd> |
|
1075 position inside line (integer) |
|
1076 </dd><dt><i>apply=</i></dt> |
|
1077 <dd> |
|
1078 flag indicating, that the fix should be applied |
|
1079 (boolean) |
|
1080 </dd> |
1021 </dd> |
1081 </dl><dl> |
1022 </dl><dl> |
1082 <dt>Returns:</dt> |
1023 <dt>Returns:</dt> |
1083 <dd> |
1024 <dd> |
1084 value indicating an applied/deferred fix (-1, 0, 1), |
1025 value indicating an applied/deferred fix (-1, 0, 1), |