src/eric7/Documentation/Source/eric7.Plugins.CheckerPlugins.CodeStyleChecker.NameOrder.NameOrderChecker.html

branch
eric7
changeset 10479
856476537696
parent 10054
d7a47f0cff2b
child 11144
8c40c5e1ebe0
equal deleted inserted replaced
10478:de9106c55c3d 10479:856476537696
5 <link rel="stylesheet" href="styles.css"> 5 <link rel="stylesheet" href="styles.css">
6 </head> 6 </head>
7 <body> 7 <body>
8 <a NAME="top" ID="top"></a> 8 <a NAME="top" ID="top"></a>
9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.NameOrder.NameOrderChecker</h1> 9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.NameOrder.NameOrderChecker</h1>
10
11 <p> 10 <p>
12 Module implementing a checker for import statements. 11 Module implementing a checker for import statements.
13 </p> 12 </p>
13
14 <h3>Global Attributes</h3> 14 <h3>Global Attributes</h3>
15
16 <table> 15 <table>
17 <tr><td>None</td></tr> 16 <tr><td>None</td></tr>
18 </table> 17 </table>
18
19 <h3>Classes</h3> 19 <h3>Classes</h3>
20 20 <table>
21 <table>
22
23 <tr> 21 <tr>
24 <td><a href="#NameOrderChecker">NameOrderChecker</a></td> 22 <td><a href="#NameOrderChecker">NameOrderChecker</a></td>
25 <td>Class implementing a checker for name ordering.</td> 23 <td>Class implementing a checker for name ordering.</td>
26 </tr> 24 </tr>
27 </table> 25 </table>
26
28 <h3>Functions</h3> 27 <h3>Functions</h3>
29
30 <table> 28 <table>
31 <tr><td>None</td></tr> 29 <tr><td>None</td></tr>
32 </table> 30 </table>
31
33 <hr /> 32 <hr />
34 <hr /> 33 <hr />
35 <a NAME="NameOrderChecker" ID="NameOrderChecker"></a> 34 <a NAME="NameOrderChecker" ID="NameOrderChecker"></a>
36 <h2>NameOrderChecker</h2> 35 <h2>NameOrderChecker</h2>
37
38 <p> 36 <p>
39 Class implementing a checker for name ordering. 37 Class implementing a checker for name ordering.
40 </p> 38 </p>
41 <p> 39 <p>
42 Note: Name ordering is checked for import statements, the '__all__' statement 40 Note: Name ordering is checked for import statements, the '__all__' statement
43 and exception names of exception handlers. 41 and exception names of exception handlers.
44 </p> 42 </p>
43
45 <h3>Derived from</h3> 44 <h3>Derived from</h3>
46 None 45 None
47 <h3>Class Attributes</h3> 46 <h3>Class Attributes</h3>
48
49 <table> 47 <table>
50 <tr><td>Codes</td></tr> 48 <tr><td>Codes</td></tr>
51 </table> 49 </table>
50
52 <h3>Class Methods</h3> 51 <h3>Class Methods</h3>
53
54 <table> 52 <table>
55 <tr><td>None</td></tr> 53 <tr><td>None</td></tr>
56 </table> 54 </table>
55
57 <h3>Methods</h3> 56 <h3>Methods</h3>
58 57 <table>
59 <table>
60
61 <tr> 58 <tr>
62 <td><a href="#NameOrderChecker.__init__">NameOrderChecker</a></td> 59 <td><a href="#NameOrderChecker.__init__">NameOrderChecker</a></td>
63 <td>Constructor</td> 60 <td>Constructor</td>
64 </tr> 61 </tr>
65 <tr> 62 <tr>
121 <tr> 118 <tr>
122 <td><a href="#NameOrderChecker.sorted">sorted</a></td> 119 <td><a href="#NameOrderChecker.sorted">sorted</a></td>
123 <td>Public method to sort the given list of names.</td> 120 <td>Public method to sort the given list of names.</td>
124 </tr> 121 </tr>
125 </table> 122 </table>
123
126 <h3>Static Methods</h3> 124 <h3>Static Methods</h3>
127
128 <table> 125 <table>
129 <tr><td>None</td></tr> 126 <tr><td>None</td></tr>
130 </table> 127 </table>
128
131 129
132 <a NAME="NameOrderChecker.__init__" ID="NameOrderChecker.__init__"></a> 130 <a NAME="NameOrderChecker.__init__" ID="NameOrderChecker.__init__"></a>
133 <h4>NameOrderChecker (Constructor)</h4> 131 <h4>NameOrderChecker (Constructor)</h4>
134 <b>NameOrderChecker</b>(<i>source, filename, tree, select, ignore, expected, repeat, args</i>) 132 <b>NameOrderChecker</b>(<i>source, filename, tree, select, ignore, expected, repeat, args</i>)
135
136 <p> 133 <p>
137 Constructor 134 Constructor
138 </p> 135 </p>
136
139 <dl> 137 <dl>
140 138
141 <dt><i>source</i> (list of str)</dt> 139 <dt><i>source</i> (list of str)</dt>
142 <dd> 140 <dd>
143 source code to be checked 141 source code to be checked
172 </dd> 170 </dd>
173 </dl> 171 </dl>
174 <a NAME="NameOrderChecker.__atoi" ID="NameOrderChecker.__atoi"></a> 172 <a NAME="NameOrderChecker.__atoi" ID="NameOrderChecker.__atoi"></a>
175 <h4>NameOrderChecker.__atoi</h4> 173 <h4>NameOrderChecker.__atoi</h4>
176 <b>__atoi</b>(<i>text</i>) 174 <b>__atoi</b>(<i>text</i>)
177
178 <p> 175 <p>
179 Private method to convert the given text to an integer number. 176 Private method to convert the given text to an integer number.
180 </p> 177 </p>
178
181 <dl> 179 <dl>
182 180
183 <dt><i>text</i> (str)</dt> 181 <dt><i>text</i> (str)</dt>
184 <dd> 182 <dd>
185 text to be converted 183 text to be converted
198 </dd> 196 </dd>
199 </dl> 197 </dl>
200 <a NAME="NameOrderChecker.__checkNameOrder" ID="NameOrderChecker.__checkNameOrder"></a> 198 <a NAME="NameOrderChecker.__checkNameOrder" ID="NameOrderChecker.__checkNameOrder"></a>
201 <h4>NameOrderChecker.__checkNameOrder</h4> 199 <h4>NameOrderChecker.__checkNameOrder</h4>
202 <b>__checkNameOrder</b>(<i></i>) 200 <b>__checkNameOrder</b>(<i></i>)
203
204 <p> 201 <p>
205 Private method to check the order of import statements and handled exceptions. 202 Private method to check the order of import statements and handled exceptions.
206 </p> 203 </p>
204
207 <a NAME="NameOrderChecker.__error" ID="NameOrderChecker.__error"></a> 205 <a NAME="NameOrderChecker.__error" ID="NameOrderChecker.__error"></a>
208 <h4>NameOrderChecker.__error</h4> 206 <h4>NameOrderChecker.__error</h4>
209 <b>__error</b>(<i>lineNumber, offset, code, *args</i>) 207 <b>__error</b>(<i>lineNumber, offset, code, *args</i>)
210
211 <p> 208 <p>
212 Private method to record an issue. 209 Private method to record an issue.
213 </p> 210 </p>
211
214 <dl> 212 <dl>
215 213
216 <dt><i>lineNumber</i> (int)</dt> 214 <dt><i>lineNumber</i> (int)</dt>
217 <dd> 215 <dd>
218 line number of the issue 216 line number of the issue
231 </dd> 229 </dd>
232 </dl> 230 </dl>
233 <a NAME="NameOrderChecker.__findErrorInAll" ID="NameOrderChecker.__findErrorInAll"></a> 231 <a NAME="NameOrderChecker.__findErrorInAll" ID="NameOrderChecker.__findErrorInAll"></a>
234 <h4>NameOrderChecker.__findErrorInAll</h4> 232 <h4>NameOrderChecker.__findErrorInAll</h4>
235 <b>__findErrorInAll</b>(<i>node</i>) 233 <b>__findErrorInAll</b>(<i>node</i>)
236
237 <p> 234 <p>
238 Private method to check the '__all__' node for errors. 235 Private method to check the '__all__' node for errors.
239 </p> 236 </p>
237
240 <dl> 238 <dl>
241 239
242 <dt><i>node</i> (ast.List or ast.Tuple)</dt> 240 <dt><i>node</i> (ast.List or ast.Tuple)</dt>
243 <dd> 241 <dd>
244 reference to the '__all__' node 242 reference to the '__all__' node
258 </dd> 256 </dd>
259 </dl> 257 </dl>
260 <a NAME="NameOrderChecker.__findExceptionListErrors" ID="NameOrderChecker.__findExceptionListErrors"></a> 258 <a NAME="NameOrderChecker.__findExceptionListErrors" ID="NameOrderChecker.__findExceptionListErrors"></a>
261 <h4>NameOrderChecker.__findExceptionListErrors</h4> 259 <h4>NameOrderChecker.__findExceptionListErrors</h4>
262 <b>__findExceptionListErrors</b>(<i>nodes</i>) 260 <b>__findExceptionListErrors</b>(<i>nodes</i>)
263
264 <p> 261 <p>
265 Private method to check the exception node for errors. 262 Private method to check the exception node for errors.
266 </p> 263 </p>
264
267 <dl> 265 <dl>
268 266
269 <dt><i>nodes</i> (list of ast.List or ast.Tuple)</dt> 267 <dt><i>nodes</i> (list of ast.List or ast.Tuple)</dt>
270 <dd> 268 <dd>
271 list of exception nodes 269 list of exception nodes
284 </dd> 282 </dd>
285 </dl> 283 </dl>
286 <a NAME="NameOrderChecker.__findExceptionListNodes" ID="NameOrderChecker.__findExceptionListNodes"></a> 284 <a NAME="NameOrderChecker.__findExceptionListNodes" ID="NameOrderChecker.__findExceptionListNodes"></a>
287 <h4>NameOrderChecker.__findExceptionListNodes</h4> 285 <h4>NameOrderChecker.__findExceptionListNodes</h4>
288 <b>__findExceptionListNodes</b>(<i>tree</i>) 286 <b>__findExceptionListNodes</b>(<i>tree</i>)
289
290 <p> 287 <p>
291 Private method to find all exception types handled by given tree. 288 Private method to find all exception types handled by given tree.
292 </p> 289 </p>
290
293 <dl> 291 <dl>
294 292
295 <dt><i>tree</i> (ast.AST)</dt> 293 <dt><i>tree</i> (ast.AST)</dt>
296 <dd> 294 <dd>
297 reference to the ast node tree to be parsed 295 reference to the ast node tree to be parsed
310 </dd> 308 </dd>
311 </dl> 309 </dl>
312 <a NAME="NameOrderChecker.__findExceptionListStr" ID="NameOrderChecker.__findExceptionListStr"></a> 310 <a NAME="NameOrderChecker.__findExceptionListStr" ID="NameOrderChecker.__findExceptionListStr"></a>
313 <h4>NameOrderChecker.__findExceptionListStr</h4> 311 <h4>NameOrderChecker.__findExceptionListStr</h4>
314 <b>__findExceptionListStr</b>(<i>node</i>) 312 <b>__findExceptionListStr</b>(<i>node</i>)
315
316 <p> 313 <p>
317 Private method to get the exception name out of an exception handler type node. 314 Private method to get the exception name out of an exception handler type node.
318 </p> 315 </p>
316
319 <dl> 317 <dl>
320 318
321 <dt><i>node</i> (ast.Name or ast.Attribute)</dt> 319 <dt><i>node</i> (ast.Name or ast.Attribute)</dt>
322 <dd> 320 <dd>
323 node to be treated 321 node to be treated
336 </dd> 334 </dd>
337 </dl> 335 </dl>
338 <a NAME="NameOrderChecker.__findNodes" ID="NameOrderChecker.__findNodes"></a> 336 <a NAME="NameOrderChecker.__findNodes" ID="NameOrderChecker.__findNodes"></a>
339 <h4>NameOrderChecker.__findNodes</h4> 337 <h4>NameOrderChecker.__findNodes</h4>
340 <b>__findNodes</b>(<i>tree</i>) 338 <b>__findNodes</b>(<i>tree</i>)
341
342 <p> 339 <p>
343 Private method to find all import and import from nodes of the given 340 Private method to find all import and import from nodes of the given
344 tree. 341 tree.
345 </p> 342 </p>
343
346 <dl> 344 <dl>
347 345
348 <dt><i>tree</i> (ast.AST)</dt> 346 <dt><i>tree</i> (ast.AST)</dt>
349 <dd> 347 <dd>
350 reference to the ast node tree to be parsed 348 reference to the ast node tree to be parsed
365 </dd> 363 </dd>
366 </dl> 364 </dl>
367 <a NAME="NameOrderChecker.__ignoreCode" ID="NameOrderChecker.__ignoreCode"></a> 365 <a NAME="NameOrderChecker.__ignoreCode" ID="NameOrderChecker.__ignoreCode"></a>
368 <h4>NameOrderChecker.__ignoreCode</h4> 366 <h4>NameOrderChecker.__ignoreCode</h4>
369 <b>__ignoreCode</b>(<i>code</i>) 367 <b>__ignoreCode</b>(<i>code</i>)
370
371 <p> 368 <p>
372 Private method to check if the message code should be ignored. 369 Private method to check if the message code should be ignored.
373 </p> 370 </p>
371
374 <dl> 372 <dl>
375 373
376 <dt><i>code</i> (str)</dt> 374 <dt><i>code</i> (str)</dt>
377 <dd> 375 <dd>
378 message code to check for 376 message code to check for
391 </dd> 389 </dd>
392 </dl> 390 </dl>
393 <a NAME="NameOrderChecker.__naturalKeys" ID="NameOrderChecker.__naturalKeys"></a> 391 <a NAME="NameOrderChecker.__naturalKeys" ID="NameOrderChecker.__naturalKeys"></a>
394 <h4>NameOrderChecker.__naturalKeys</h4> 392 <h4>NameOrderChecker.__naturalKeys</h4>
395 <b>__naturalKeys</b>(<i>text</i>) 393 <b>__naturalKeys</b>(<i>text</i>)
396
397 <p> 394 <p>
398 Private method to generate keys for natural sorting. 395 Private method to generate keys for natural sorting.
399 </p> 396 </p>
397
400 <dl> 398 <dl>
401 399
402 <dt><i>text</i> (str)</dt> 400 <dt><i>text</i> (str)</dt>
403 <dd> 401 <dd>
404 text to generate a key for 402 text to generate a key for
417 </dd> 415 </dd>
418 </dl> 416 </dl>
419 <a NAME="NameOrderChecker.__naturally" ID="NameOrderChecker.__naturally"></a> 417 <a NAME="NameOrderChecker.__naturally" ID="NameOrderChecker.__naturally"></a>
420 <h4>NameOrderChecker.__naturally</h4> 418 <h4>NameOrderChecker.__naturally</h4>
421 <b>__naturally</b>(<i>toSort, key=None, reverse=False</i>) 419 <b>__naturally</b>(<i>toSort, key=None, reverse=False</i>)
422
423 <p> 420 <p>
424 Private method to sort the given list of names naturally. 421 Private method to sort the given list of names naturally.
425 </p> 422 </p>
426 <p> 423 <p>
427 Note: Natural sorting maintains the sort order of numbers (i.e. 424 Note: Natural sorting maintains the sort order of numbers (i.e.
428 [Q1, Q10, Q2] is sorted as [Q1, Q2, Q10] while the Python 425 [Q1, Q10, Q2] is sorted as [Q1, Q2, Q10] while the Python
429 standard sort would yield [Q1, Q10, Q2]. 426 standard sort would yield [Q1, Q10, Q2].
430 </p> 427 </p>
428
431 <dl> 429 <dl>
432 430
433 <dt><i>toSort</i> (list of str)</dt> 431 <dt><i>toSort</i> (list of str)</dt>
434 <dd> 432 <dd>
435 list of names to be sorted 433 list of names to be sorted
460 <b>keyCallback</b>(<i></i>) 458 <b>keyCallback</b>(<i></i>)
461 459
462 <a NAME="NameOrderChecker.moduleKey" ID="NameOrderChecker.moduleKey"></a> 460 <a NAME="NameOrderChecker.moduleKey" ID="NameOrderChecker.moduleKey"></a>
463 <h4>NameOrderChecker.moduleKey</h4> 461 <h4>NameOrderChecker.moduleKey</h4>
464 <b>moduleKey</b>(<i>moduleName, subImports=False</i>) 462 <b>moduleKey</b>(<i>moduleName, subImports=False</i>)
465
466 <p> 463 <p>
467 Public method to generate a key for the given module name. 464 Public method to generate a key for the given module name.
468 </p> 465 </p>
466
469 <dl> 467 <dl>
470 468
471 <dt><i>moduleName</i> (str)</dt> 469 <dt><i>moduleName</i> (str)</dt>
472 <dd> 470 <dd>
473 module name 471 module name
491 </dd> 489 </dd>
492 </dl> 490 </dl>
493 <a NAME="NameOrderChecker.run" ID="NameOrderChecker.run"></a> 491 <a NAME="NameOrderChecker.run" ID="NameOrderChecker.run"></a>
494 <h4>NameOrderChecker.run</h4> 492 <h4>NameOrderChecker.run</h4>
495 <b>run</b>(<i></i>) 493 <b>run</b>(<i></i>)
496
497 <p> 494 <p>
498 Public method to check the given source against miscellaneous 495 Public method to check the given source against miscellaneous
499 conditions. 496 conditions.
500 </p> 497 </p>
498
501 <a NAME="NameOrderChecker.sorted" ID="NameOrderChecker.sorted"></a> 499 <a NAME="NameOrderChecker.sorted" ID="NameOrderChecker.sorted"></a>
502 <h4>NameOrderChecker.sorted</h4> 500 <h4>NameOrderChecker.sorted</h4>
503 <b>sorted</b>(<i>toSort, key=None, reverse=False</i>) 501 <b>sorted</b>(<i>toSort, key=None, reverse=False</i>)
504
505 <p> 502 <p>
506 Public method to sort the given list of names. 503 Public method to sort the given list of names.
507 </p> 504 </p>
505
508 <dl> 506 <dl>
509 507
510 <dt><i>toSort</i> (list of str)</dt> 508 <dt><i>toSort</i> (list of str)</dt>
511 <dd> 509 <dd>
512 list of names to be sorted 510 list of names to be sorted

eric ide

mercurial