eric7/Documentation/Source/eric7.Utilities.ClassBrowsers.pyclbr.html

branch
eric7
changeset 8372
e0227a7c850e
child 8596
d64760b2da50
equal deleted inserted replaced
8371:d6062691d424 8372:e0227a7c850e
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric7.Utilities.ClassBrowsers.pyclbr</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>
22 <a NAME="top" ID="top"></a>
23 <h1>eric7.Utilities.ClassBrowsers.pyclbr</h1>
24
25 <p>
26 Parse a Python file and retrieve classes, functions/methods and attributes.
27 </p>
28 <p>
29 Parse enough of a Python file to recognize class and method definitions and
30 to find out the superclasses of a class as well as its attributes.
31 </p>
32 <h3>Global Attributes</h3>
33
34 <table>
35 <tr><td>SUPPORTED_TYPES</td></tr><tr><td>TABWIDTH</td></tr><tr><td>_commentsub</td></tr><tr><td>_getnext</td></tr><tr><td>_modules</td></tr>
36 </table>
37 <h3>Classes</h3>
38
39 <table>
40
41 <tr>
42 <td><a href="#Attribute">Attribute</a></td>
43 <td>Class to represent a class attribute.</td>
44 </tr>
45 <tr>
46 <td><a href="#Class">Class</a></td>
47 <td>Class to represent a Python class.</td>
48 </tr>
49 <tr>
50 <td><a href="#Function">Function</a></td>
51 <td>Class to represent a Python function.</td>
52 </tr>
53 <tr>
54 <td><a href="#ImportedModule">ImportedModule</a></td>
55 <td>Class to represent an imported module.</td>
56 </tr>
57 <tr>
58 <td><a href="#Imports">Imports</a></td>
59 <td>Class to represent the list of imported modules.</td>
60 </tr>
61 <tr>
62 <td><a href="#Publics">Publics</a></td>
63 <td>Class to represent the list of public identifiers.</td>
64 </tr>
65 <tr>
66 <td><a href="#VisibilityMixin">VisibilityMixin</a></td>
67 <td>Mixin class implementing the notion of visibility.</td>
68 </tr>
69 </table>
70 <h3>Functions</h3>
71
72 <table>
73
74 <tr>
75 <td><a href="#_indent">_indent</a></td>
76 <td>Module function to return the indentation depth.</td>
77 </tr>
78 <tr>
79 <td><a href="#calculateEndline">calculateEndline</a></td>
80 <td>Function to calculate the end line of a class or method/function.</td>
81 </tr>
82 <tr>
83 <td><a href="#readmodule_ex">readmodule_ex</a></td>
84 <td>Read a module file and return a dictionary of classes.</td>
85 </tr>
86 <tr>
87 <td><a href="#scan">scan</a></td>
88 <td>Public method to scan the given source text.</td>
89 </tr>
90 </table>
91 <hr />
92 <hr />
93 <a NAME="Attribute" ID="Attribute"></a>
94 <h2>Attribute</h2>
95
96 <p>
97 Class to represent a class attribute.
98 </p>
99 <h3>Derived from</h3>
100 ClbrBaseClasses.Attribute, VisibilityMixin
101 <h3>Class Attributes</h3>
102
103 <table>
104 <tr><td>None</td></tr>
105 </table>
106 <h3>Class Methods</h3>
107
108 <table>
109 <tr><td>None</td></tr>
110 </table>
111 <h3>Methods</h3>
112
113 <table>
114
115 <tr>
116 <td><a href="#Attribute.__init__">Attribute</a></td>
117 <td>Constructor</td>
118 </tr>
119 </table>
120 <h3>Static Methods</h3>
121
122 <table>
123 <tr><td>None</td></tr>
124 </table>
125
126 <a NAME="Attribute.__init__" ID="Attribute.__init__"></a>
127 <h4>Attribute (Constructor)</h4>
128 <b>Attribute</b>(<i>module, name, file, lineno</i>)
129
130 <p>
131 Constructor
132 </p>
133 <dl>
134
135 <dt><i>module</i></dt>
136 <dd>
137 name of the module containing this class
138 </dd>
139 <dt><i>name</i></dt>
140 <dd>
141 name of this class
142 </dd>
143 <dt><i>file</i></dt>
144 <dd>
145 filename containing this attribute
146 </dd>
147 <dt><i>lineno</i></dt>
148 <dd>
149 linenumber of the class definition
150 </dd>
151 </dl>
152 <div align="right"><a href="#top">Up</a></div>
153 <hr />
154 <hr />
155 <a NAME="Class" ID="Class"></a>
156 <h2>Class</h2>
157
158 <p>
159 Class to represent a Python class.
160 </p>
161 <h3>Derived from</h3>
162 ClbrBaseClasses.Class, VisibilityMixin
163 <h3>Class Attributes</h3>
164
165 <table>
166 <tr><td>None</td></tr>
167 </table>
168 <h3>Class Methods</h3>
169
170 <table>
171 <tr><td>None</td></tr>
172 </table>
173 <h3>Methods</h3>
174
175 <table>
176
177 <tr>
178 <td><a href="#Class.__init__">Class</a></td>
179 <td>Constructor</td>
180 </tr>
181 </table>
182 <h3>Static Methods</h3>
183
184 <table>
185 <tr><td>None</td></tr>
186 </table>
187
188 <a NAME="Class.__init__" ID="Class.__init__"></a>
189 <h4>Class (Constructor)</h4>
190 <b>Class</b>(<i>module, name, superClasses, file, lineno</i>)
191
192 <p>
193 Constructor
194 </p>
195 <dl>
196
197 <dt><i>module</i></dt>
198 <dd>
199 name of the module containing this class
200 </dd>
201 <dt><i>name</i></dt>
202 <dd>
203 name of this class
204 </dd>
205 <dt><i>superClasses</i></dt>
206 <dd>
207 list of class names this class is inherited from
208 </dd>
209 <dt><i>file</i></dt>
210 <dd>
211 filename containing this class
212 </dd>
213 <dt><i>lineno</i></dt>
214 <dd>
215 linenumber of the class definition
216 </dd>
217 </dl>
218 <div align="right"><a href="#top">Up</a></div>
219 <hr />
220 <hr />
221 <a NAME="Function" ID="Function"></a>
222 <h2>Function</h2>
223
224 <p>
225 Class to represent a Python function.
226 </p>
227 <h3>Derived from</h3>
228 ClbrBaseClasses.Function, VisibilityMixin
229 <h3>Class Attributes</h3>
230
231 <table>
232 <tr><td>None</td></tr>
233 </table>
234 <h3>Class Methods</h3>
235
236 <table>
237 <tr><td>None</td></tr>
238 </table>
239 <h3>Methods</h3>
240
241 <table>
242
243 <tr>
244 <td><a href="#Function.__init__">Function</a></td>
245 <td>Constructor</td>
246 </tr>
247 </table>
248 <h3>Static Methods</h3>
249
250 <table>
251 <tr><td>None</td></tr>
252 </table>
253
254 <a NAME="Function.__init__" ID="Function.__init__"></a>
255 <h4>Function (Constructor)</h4>
256 <b>Function</b>(<i>module, name, file, lineno, signature='', separator=', ', modifierType=ClbrBaseClasses.Function.General, annotation=""</i>)
257
258 <p>
259 Constructor
260 </p>
261 <dl>
262
263 <dt><i>module</i></dt>
264 <dd>
265 name of the module containing this function
266 </dd>
267 <dt><i>name</i></dt>
268 <dd>
269 name of this function
270 </dd>
271 <dt><i>file</i></dt>
272 <dd>
273 filename containing this class
274 </dd>
275 <dt><i>lineno</i></dt>
276 <dd>
277 linenumber of the class definition
278 </dd>
279 <dt><i>signature</i></dt>
280 <dd>
281 parameterlist of the method
282 </dd>
283 <dt><i>separator</i></dt>
284 <dd>
285 string separating the parameters
286 </dd>
287 <dt><i>modifierType</i></dt>
288 <dd>
289 type of the function
290 </dd>
291 <dt><i>annotation</i></dt>
292 <dd>
293 return annotation
294 </dd>
295 </dl>
296 <div align="right"><a href="#top">Up</a></div>
297 <hr />
298 <hr />
299 <a NAME="ImportedModule" ID="ImportedModule"></a>
300 <h2>ImportedModule</h2>
301
302 <p>
303 Class to represent an imported module.
304 </p>
305 <h3>Derived from</h3>
306 None
307 <h3>Class Attributes</h3>
308
309 <table>
310 <tr><td>None</td></tr>
311 </table>
312 <h3>Class Methods</h3>
313
314 <table>
315 <tr><td>None</td></tr>
316 </table>
317 <h3>Methods</h3>
318
319 <table>
320
321 <tr>
322 <td><a href="#ImportedModule.__init__">ImportedModule</a></td>
323 <td>Constructor</td>
324 </tr>
325 <tr>
326 <td><a href="#ImportedModule.addImport">addImport</a></td>
327 <td>Public method to add a list of imported names.</td>
328 </tr>
329 </table>
330 <h3>Static Methods</h3>
331
332 <table>
333 <tr><td>None</td></tr>
334 </table>
335
336 <a NAME="ImportedModule.__init__" ID="ImportedModule.__init__"></a>
337 <h4>ImportedModule (Constructor)</h4>
338 <b>ImportedModule</b>(<i>module, file, importedModule</i>)
339
340 <p>
341 Constructor
342 </p>
343 <dl>
344
345 <dt><i>module</i></dt>
346 <dd>
347 name of the module containing the import (string)
348 </dd>
349 <dt><i>file</i></dt>
350 <dd>
351 file name containing the import (string)
352 </dd>
353 <dt><i>importedModule</i></dt>
354 <dd>
355 name of the imported module (string)
356 </dd>
357 </dl>
358 <a NAME="ImportedModule.addImport" ID="ImportedModule.addImport"></a>
359 <h4>ImportedModule.addImport</h4>
360 <b>addImport</b>(<i>lineno, importedNames</i>)
361
362 <p>
363 Public method to add a list of imported names.
364 </p>
365 <dl>
366
367 <dt><i>lineno</i></dt>
368 <dd>
369 line number of the import
370 </dd>
371 <dt><i>importedNames</i></dt>
372 <dd>
373 list of imported names (list of strings)
374 </dd>
375 </dl>
376 <div align="right"><a href="#top">Up</a></div>
377 <hr />
378 <hr />
379 <a NAME="Imports" ID="Imports"></a>
380 <h2>Imports</h2>
381
382 <p>
383 Class to represent the list of imported modules.
384 </p>
385 <h3>Derived from</h3>
386 None
387 <h3>Class Attributes</h3>
388
389 <table>
390 <tr><td>None</td></tr>
391 </table>
392 <h3>Class Methods</h3>
393
394 <table>
395 <tr><td>None</td></tr>
396 </table>
397 <h3>Methods</h3>
398
399 <table>
400
401 <tr>
402 <td><a href="#Imports.__init__">Imports</a></td>
403 <td>Constructor</td>
404 </tr>
405 <tr>
406 <td><a href="#Imports.addImport">addImport</a></td>
407 <td>Public method to add a list of imported names.</td>
408 </tr>
409 <tr>
410 <td><a href="#Imports.getImport">getImport</a></td>
411 <td>Public method to get an imported module item.</td>
412 </tr>
413 <tr>
414 <td><a href="#Imports.getImports">getImports</a></td>
415 <td>Public method to get all imported module names.</td>
416 </tr>
417 </table>
418 <h3>Static Methods</h3>
419
420 <table>
421 <tr><td>None</td></tr>
422 </table>
423
424 <a NAME="Imports.__init__" ID="Imports.__init__"></a>
425 <h4>Imports (Constructor)</h4>
426 <b>Imports</b>(<i>module, file</i>)
427
428 <p>
429 Constructor
430 </p>
431 <dl>
432
433 <dt><i>module</i></dt>
434 <dd>
435 name of the module containing the import (string)
436 </dd>
437 <dt><i>file</i></dt>
438 <dd>
439 file name containing the import (string)
440 </dd>
441 </dl>
442 <a NAME="Imports.addImport" ID="Imports.addImport"></a>
443 <h4>Imports.addImport</h4>
444 <b>addImport</b>(<i>moduleName, names, lineno</i>)
445
446 <p>
447 Public method to add a list of imported names.
448 </p>
449 <dl>
450
451 <dt><i>moduleName</i></dt>
452 <dd>
453 name of the imported module (string)
454 </dd>
455 <dt><i>names</i></dt>
456 <dd>
457 list of names (list of strings)
458 </dd>
459 <dt><i>lineno</i></dt>
460 <dd>
461 line number of the import
462 </dd>
463 </dl>
464 <a NAME="Imports.getImport" ID="Imports.getImport"></a>
465 <h4>Imports.getImport</h4>
466 <b>getImport</b>(<i>moduleName</i>)
467
468 <p>
469 Public method to get an imported module item.
470 </p>
471 <dl>
472
473 <dt><i>moduleName</i></dt>
474 <dd>
475 name of the imported module (string)
476 </dd>
477 </dl>
478 <dl>
479 <dt>Return:</dt>
480 <dd>
481 imported module item (ImportedModule) or None
482 </dd>
483 </dl>
484 <a NAME="Imports.getImports" ID="Imports.getImports"></a>
485 <h4>Imports.getImports</h4>
486 <b>getImports</b>(<i></i>)
487
488 <p>
489 Public method to get all imported module names.
490 </p>
491 <dl>
492 <dt>Return:</dt>
493 <dd>
494 dictionary of imported module names with name as key and list
495 of line numbers of imports as value
496 </dd>
497 </dl>
498 <div align="right"><a href="#top">Up</a></div>
499 <hr />
500 <hr />
501 <a NAME="Publics" ID="Publics"></a>
502 <h2>Publics</h2>
503
504 <p>
505 Class to represent the list of public identifiers.
506 </p>
507 <h3>Derived from</h3>
508 None
509 <h3>Class Attributes</h3>
510
511 <table>
512 <tr><td>None</td></tr>
513 </table>
514 <h3>Class Methods</h3>
515
516 <table>
517 <tr><td>None</td></tr>
518 </table>
519 <h3>Methods</h3>
520
521 <table>
522
523 <tr>
524 <td><a href="#Publics.__init__">Publics</a></td>
525 <td>Constructor</td>
526 </tr>
527 </table>
528 <h3>Static Methods</h3>
529
530 <table>
531 <tr><td>None</td></tr>
532 </table>
533
534 <a NAME="Publics.__init__" ID="Publics.__init__"></a>
535 <h4>Publics (Constructor)</h4>
536 <b>Publics</b>(<i>module, file, lineno, idents</i>)
537
538 <p>
539 Constructor
540 </p>
541 <dl>
542
543 <dt><i>module</i></dt>
544 <dd>
545 name of the module containing this function
546 </dd>
547 <dt><i>file</i></dt>
548 <dd>
549 filename containing this class
550 </dd>
551 <dt><i>lineno</i></dt>
552 <dd>
553 linenumber of the class definition
554 </dd>
555 <dt><i>idents</i></dt>
556 <dd>
557 list of public identifiers
558 </dd>
559 </dl>
560 <div align="right"><a href="#top">Up</a></div>
561 <hr />
562 <hr />
563 <a NAME="VisibilityMixin" ID="VisibilityMixin"></a>
564 <h2>VisibilityMixin</h2>
565
566 <p>
567 Mixin class implementing the notion of visibility.
568 </p>
569 <h3>Derived from</h3>
570 ClbrBaseClasses.ClbrVisibilityMixinBase
571 <h3>Class Attributes</h3>
572
573 <table>
574 <tr><td>None</td></tr>
575 </table>
576 <h3>Class Methods</h3>
577
578 <table>
579 <tr><td>None</td></tr>
580 </table>
581 <h3>Methods</h3>
582
583 <table>
584
585 <tr>
586 <td><a href="#VisibilityMixin.__init__">VisibilityMixin</a></td>
587 <td>Constructor</td>
588 </tr>
589 </table>
590 <h3>Static Methods</h3>
591
592 <table>
593 <tr><td>None</td></tr>
594 </table>
595
596 <a NAME="VisibilityMixin.__init__" ID="VisibilityMixin.__init__"></a>
597 <h4>VisibilityMixin (Constructor)</h4>
598 <b>VisibilityMixin</b>(<i></i>)
599
600 <p>
601 Constructor
602 </p>
603 <div align="right"><a href="#top">Up</a></div>
604 <hr />
605 <hr />
606 <a NAME="_indent" ID="_indent"></a>
607 <h2>_indent</h2>
608 <b>_indent</b>(<i>ws</i>)
609
610 <p>
611 Module function to return the indentation depth.
612 </p>
613 <dl>
614
615 <dt><i>ws</i></dt>
616 <dd>
617 the whitespace to be checked (string)
618 </dd>
619 </dl>
620 <dl>
621 <dt>Return:</dt>
622 <dd>
623 length of the whitespace string (integer)
624 </dd>
625 </dl>
626 <div align="right"><a href="#top">Up</a></div>
627 <hr />
628 <hr />
629 <a NAME="calculateEndline" ID="calculateEndline"></a>
630 <h2>calculateEndline</h2>
631 <b>calculateEndline</b>(<i>lineno, lines, indent</i>)
632
633 <p>
634 Function to calculate the end line of a class or method/function.
635 </p>
636 <dl>
637
638 <dt><i>lineno</i> (int)</dt>
639 <dd>
640 line number to start at (one based)
641 </dd>
642 <dt><i>lines</i> (list of str)</dt>
643 <dd>
644 list of source lines
645 </dd>
646 <dt><i>indent</i> (int)</dt>
647 <dd>
648 indent length the class/method/function definition
649 </dd>
650 </dl>
651 <dl>
652 <dt>Return:</dt>
653 <dd>
654 end line of the class/method/function (one based)
655 </dd>
656 </dl>
657 <dl>
658 <dt>Return Type:</dt>
659 <dd>
660 int
661 </dd>
662 </dl>
663 <div align="right"><a href="#top">Up</a></div>
664 <hr />
665 <hr />
666 <a NAME="readmodule_ex" ID="readmodule_ex"></a>
667 <h2>readmodule_ex</h2>
668 <b>readmodule_ex</b>(<i>module, path=None, inpackage=False, isPyFile=False</i>)
669
670 <p>
671 Read a module file and return a dictionary of classes.
672 </p>
673 <p>
674 Search for MODULE in PATH and sys.path, read and parse the
675 module and return a dictionary with one entry for each class
676 found in the module.
677 </p>
678 <dl>
679
680 <dt><i>module</i> (str)</dt>
681 <dd>
682 name of the module file
683 </dd>
684 <dt><i>path</i> (list of str)</dt>
685 <dd>
686 path the module should be searched in
687 </dd>
688 <dt><i>inpackage</i> (bool)</dt>
689 <dd>
690 flag indicating a module inside a package is scanned
691 </dd>
692 <dt><i>isPyFile</i> (bool)</dt>
693 <dd>
694 flag indicating a Python file
695 </dd>
696 </dl>
697 <dl>
698 <dt>Return:</dt>
699 <dd>
700 the resulting dictionary
701 </dd>
702 </dl>
703 <dl>
704 <dt>Return Type:</dt>
705 <dd>
706 dict
707 </dd>
708 </dl>
709 <div align="right"><a href="#top">Up</a></div>
710 <hr />
711 <hr />
712 <a NAME="scan" ID="scan"></a>
713 <h2>scan</h2>
714 <b>scan</b>(<i>src, file, module</i>)
715
716 <p>
717 Public method to scan the given source text.
718 </p>
719 <dl>
720
721 <dt><i>src</i> (str)</dt>
722 <dd>
723 source text to be scanned
724 </dd>
725 <dt><i>file</i> (str)</dt>
726 <dd>
727 file name associated with the source text
728 </dd>
729 <dt><i>module</i> (str)</dt>
730 <dd>
731 module name associated with the source text
732 </dd>
733 </dl>
734 <dl>
735 <dt>Return:</dt>
736 <dd>
737 dictionary containing the extracted data
738 </dd>
739 </dl>
740 <dl>
741 <dt>Return Type:</dt>
742 <dd>
743 dict
744 </dd>
745 </dl>
746 <div align="right"><a href="#top">Up</a></div>
747 <hr />
748 </body></html>

eric ide

mercurial