Sat, 26 Apr 2025 12:34:32 +0200
MicroPython
- Added a configuration option to disable the support for the no longer produced Pimoroni Pico Wireless Pack.
<!DOCTYPE html> <html><head> <title>eric7.Utilities.ClassBrowsers.pyclbr</title> <meta charset="UTF-8"> <link rel="stylesheet" href="styles.css"> </head> <body> <a NAME="top" ID="top"></a> <h1>eric7.Utilities.ClassBrowsers.pyclbr</h1> <p> Parse a Python file and retrieve classes, functions/methods and attributes. </p> <p> Parse enough of a Python file to recognize class and method definitions and to find out the superclasses of a class as well as its attributes. </p> <h3>Global Attributes</h3> <table> <tr><td>SUPPORTED_TYPES</td></tr> <tr><td>TABWIDTH</td></tr> <tr><td>_commentsub</td></tr> <tr><td>_getnext</td></tr> </table> <h3>Classes</h3> <table> <tr> <td><a href="#Attribute">Attribute</a></td> <td>Class to represent a class attribute.</td> </tr> <tr> <td><a href="#Class">Class</a></td> <td>Class to represent a Python class.</td> </tr> <tr> <td><a href="#Function">Function</a></td> <td>Class to represent a Python function.</td> </tr> <tr> <td><a href="#ImportedModule">ImportedModule</a></td> <td>Class to represent an imported module.</td> </tr> <tr> <td><a href="#Imports">Imports</a></td> <td>Class to represent the list of imported modules.</td> </tr> <tr> <td><a href="#Publics">Publics</a></td> <td>Class to represent the list of public identifiers.</td> </tr> <tr> <td><a href="#VisibilityMixin">VisibilityMixin</a></td> <td>Mixin class implementing the notion of visibility.</td> </tr> </table> <h3>Functions</h3> <table> <tr> <td><a href="#_indent">_indent</a></td> <td>Module function to return the indentation depth.</td> </tr> <tr> <td><a href="#calculateEndline">calculateEndline</a></td> <td>Function to calculate the end line of a class or method/function.</td> </tr> <tr> <td><a href="#readmodule_ex">readmodule_ex</a></td> <td>Read a module file and return a dictionary of classes.</td> </tr> <tr> <td><a href="#scan">scan</a></td> <td>Public method to scan the given source text.</td> </tr> </table> <hr /> <hr /> <a NAME="Attribute" ID="Attribute"></a> <h2>Attribute</h2> <p> Class to represent a class attribute. </p> <h3>Derived from</h3> ClbrBaseClasses.Attribute, VisibilityMixin <h3>Class Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#Attribute.__init__">Attribute</a></td> <td>Constructor</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="Attribute.__init__" ID="Attribute.__init__"></a> <h4>Attribute (Constructor)</h4> <b>Attribute</b>(<i>module, name, file, lineno, col_offset=0</i>) <p> Constructor </p> <dl> <dt><i>module</i> (str)</dt> <dd> name of the module containing this class </dd> <dt><i>name</i> (str)</dt> <dd> name of this class </dd> <dt><i>file</i> (str)</dt> <dd> file name containing this attribute </dd> <dt><i>lineno</i> (int)</dt> <dd> line number of the attribute definition </dd> <dt><i>col_offset</i> (int (optional))</dt> <dd> column number of the attribute definition (defaults to 0) </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> <a NAME="Class" ID="Class"></a> <h2>Class</h2> <p> Class to represent a Python class. </p> <h3>Derived from</h3> ClbrBaseClasses.Class, VisibilityMixin <h3>Class Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#Class.__init__">Class</a></td> <td>Constructor</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="Class.__init__" ID="Class.__init__"></a> <h4>Class (Constructor)</h4> <b>Class</b>(<i>module, name, superClasses, file, lineno, col_offset=0</i>) <p> Constructor </p> <dl> <dt><i>module</i> (str)</dt> <dd> name of the module containing this class </dd> <dt><i>name</i> (str)</dt> <dd> name of this class </dd> <dt><i>superClasses</i> (list of str)</dt> <dd> list of class names this class is inherited from </dd> <dt><i>file</i> (str)</dt> <dd> file name containing this class </dd> <dt><i>lineno</i> (int)</dt> <dd> line number of the class definition </dd> <dt><i>col_offset</i> (int (optional))</dt> <dd> column number of the class definition (defaults to 0) </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> <a NAME="Function" ID="Function"></a> <h2>Function</h2> <p> Class to represent a Python function. </p> <h3>Derived from</h3> ClbrBaseClasses.Function, VisibilityMixin <h3>Class Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#Function.__init__">Function</a></td> <td>Constructor</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="Function.__init__" ID="Function.__init__"></a> <h4>Function (Constructor)</h4> <b>Function</b>(<i>module, name, file, lineno, col_offset=0, signature="", separator=", ", modifierType=ClbrBaseClasses.Function.General, annotation="", </i>) <p> Constructor </p> <dl> <dt><i>module</i> (str)</dt> <dd> name of the module containing this function </dd> <dt><i>name</i> (str)</dt> <dd> name of this function </dd> <dt><i>file</i> (str)</dt> <dd> file name containing this function </dd> <dt><i>lineno</i> (int)</dt> <dd> line number of the function definition </dd> <dt><i>col_offset</i> (int (optional))</dt> <dd> column number of the function definition (defaults to 0) </dd> <dt><i>signature</i> (str)</dt> <dd> parameter list of the function </dd> <dt><i>separator</i> (str)</dt> <dd> string separating the parameters </dd> <dt><i>modifierType</i> (int)</dt> <dd> type of the function </dd> <dt><i>annotation</i> (str)</dt> <dd> return annotation </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> <a NAME="ImportedModule" ID="ImportedModule"></a> <h2>ImportedModule</h2> <p> Class to represent an imported module. </p> <h3>Derived from</h3> None <h3>Class Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#ImportedModule.__init__">ImportedModule</a></td> <td>Constructor</td> </tr> <tr> <td><a href="#ImportedModule.addImport">addImport</a></td> <td>Public method to add a list of imported names.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="ImportedModule.__init__" ID="ImportedModule.__init__"></a> <h4>ImportedModule (Constructor)</h4> <b>ImportedModule</b>(<i>module, file, importedModule</i>) <p> Constructor </p> <dl> <dt><i>module</i> (str)</dt> <dd> name of the module containing the import </dd> <dt><i>file</i> (str)</dt> <dd> file name containing the import </dd> <dt><i>importedModule</i> (str)</dt> <dd> name of the imported module </dd> </dl> <a NAME="ImportedModule.addImport" ID="ImportedModule.addImport"></a> <h4>ImportedModule.addImport</h4> <b>addImport</b>(<i>lineno, importedNames</i>) <p> Public method to add a list of imported names. </p> <dl> <dt><i>lineno</i> (int)</dt> <dd> line number of the import </dd> <dt><i>importedNames</i> (list of str)</dt> <dd> list of imported names </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> <a NAME="Imports" ID="Imports"></a> <h2>Imports</h2> <p> Class to represent the list of imported modules. </p> <h3>Derived from</h3> None <h3>Class Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#Imports.__init__">Imports</a></td> <td>Constructor</td> </tr> <tr> <td><a href="#Imports.addImport">addImport</a></td> <td>Public method to add a list of imported names.</td> </tr> <tr> <td><a href="#Imports.getImport">getImport</a></td> <td>Public method to get an imported module item.</td> </tr> <tr> <td><a href="#Imports.getImports">getImports</a></td> <td>Public method to get all imported module names.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="Imports.__init__" ID="Imports.__init__"></a> <h4>Imports (Constructor)</h4> <b>Imports</b>(<i>module, file</i>) <p> Constructor </p> <dl> <dt><i>module</i> (str)</dt> <dd> name of the module containing the import </dd> <dt><i>file</i> (str)</dt> <dd> file name containing the import </dd> </dl> <a NAME="Imports.addImport" ID="Imports.addImport"></a> <h4>Imports.addImport</h4> <b>addImport</b>(<i>moduleName, names, lineno</i>) <p> Public method to add a list of imported names. </p> <dl> <dt><i>moduleName</i> (str)</dt> <dd> name of the imported module </dd> <dt><i>names</i> (list of str)</dt> <dd> list of names </dd> <dt><i>lineno</i> (int)</dt> <dd> line number of the import </dd> </dl> <a NAME="Imports.getImport" ID="Imports.getImport"></a> <h4>Imports.getImport</h4> <b>getImport</b>(<i>moduleName</i>) <p> Public method to get an imported module item. </p> <dl> <dt><i>moduleName</i> (str)</dt> <dd> name of the imported module </dd> </dl> <dl> <dt>Return:</dt> <dd> imported module item </dd> </dl> <dl> <dt>Return Type:</dt> <dd> ImportedModule </dd> </dl> <a NAME="Imports.getImports" ID="Imports.getImports"></a> <h4>Imports.getImports</h4> <b>getImports</b>(<i></i>) <p> Public method to get all imported module names. </p> <dl> <dt>Return:</dt> <dd> dictionary of imported module names with name as key and list of line numbers of imports as value </dd> </dl> <dl> <dt>Return Type:</dt> <dd> dict </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> <a NAME="Publics" ID="Publics"></a> <h2>Publics</h2> <p> Class to represent the list of public identifiers. </p> <h3>Derived from</h3> None <h3>Class Attributes</h3> <table> <tr><td>file</td></tr> <tr><td>identifiers</td></tr> <tr><td>lineno</td></tr> <tr><td>module</td></tr> <tr><td>name</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> <a NAME="VisibilityMixin" ID="VisibilityMixin"></a> <h2>VisibilityMixin</h2> <p> Mixin class implementing the notion of visibility. </p> <h3>Derived from</h3> ClbrBaseClasses.ClbrVisibilityMixinBase <h3>Class Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#VisibilityMixin.__init__">VisibilityMixin</a></td> <td>Constructor</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="VisibilityMixin.__init__" ID="VisibilityMixin.__init__"></a> <h4>VisibilityMixin (Constructor)</h4> <b>VisibilityMixin</b>(<i></i>) <p> Constructor </p> <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> <a NAME="_indent" ID="_indent"></a> <h2>_indent</h2> <b>_indent</b>(<i>ws</i>) <p> Module function to return the indentation depth. </p> <dl> <dt><i>ws</i> (str)</dt> <dd> the whitespace to be checked </dd> </dl> <dl> <dt>Return:</dt> <dd> length of the whitespace string </dd> </dl> <dl> <dt>Return Type:</dt> <dd> int </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> <a NAME="calculateEndline" ID="calculateEndline"></a> <h2>calculateEndline</h2> <b>calculateEndline</b>(<i>lineno, lines, indent</i>) <p> Function to calculate the end line of a class or method/function. </p> <dl> <dt><i>lineno</i> (int)</dt> <dd> line number to start at (one based) </dd> <dt><i>lines</i> (list of str)</dt> <dd> list of source lines </dd> <dt><i>indent</i> (int)</dt> <dd> indent length the class/method/function definition </dd> </dl> <dl> <dt>Return:</dt> <dd> end line of the class/method/function (one based) </dd> </dl> <dl> <dt>Return Type:</dt> <dd> int </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> <a NAME="readmodule_ex" ID="readmodule_ex"></a> <h2>readmodule_ex</h2> <b>readmodule_ex</b>(<i>module, searchPath=None, isTypeFile=False</i>) <p> Read a module file and return a dictionary of classes. </p> <p> Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. </p> <dl> <dt><i>module</i> (str)</dt> <dd> name of the module file </dd> <dt><i>searchPath</i> (list of str)</dt> <dd> path the module should be searched in </dd> <dt><i>isTypeFile</i> (bool)</dt> <dd> flag indicating a file of this type </dd> </dl> <dl> <dt>Return:</dt> <dd> the resulting dictionary </dd> </dl> <dl> <dt>Return Type:</dt> <dd> dict </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> <a NAME="scan" ID="scan"></a> <h2>scan</h2> <b>scan</b>(<i>src, file, module</i>) <p> Public method to scan the given source text. </p> <dl> <dt><i>src</i> (str)</dt> <dd> source text to be scanned </dd> <dt><i>file</i> (str)</dt> <dd> file name associated with the source text </dd> <dt><i>module</i> (str)</dt> <dd> module name associated with the source text </dd> </dl> <dl> <dt>Return:</dt> <dd> dictionary containing the extracted data </dd> </dl> <dl> <dt>Return Type:</dt> <dd> dict </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> </body></html>