# eric6.Utilities.ClassBrowsers.pyclbr

Parse a Python file and retrieve classes, functions/methods and attributes.

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.

This is module is based on pyclbr found in the Python 2.2.2 distribution.

### Global Attributes

SUPPORTED_TYPES
TABWIDTH
_commentsub
_getnext
_modules

### Classes

Attribute | Class to represent a class attribute.
Class | Class to represent a Python class.
Function | Class to represent a Python function.
ImportedModule | Class to represent an imported module.
Imports | Class to represent the list of imported modules.
Publics | Class to represent the list of public identifiers.
VisibilityMixin | Mixin class implementing the notion of visibility.

### Functions

_indent | Module function to return the indentation depth.
readmodule_ex | Read a module file and return a dictionary of classes.

## Attribute

Class to represent a class attribute.

### Derived from

ClbrBaseClasses.Attribute, VisibilityMixin

### Class Attributes

None

### Class Methods

None

### Methods

Attribute | Constructor

### Static Methods

None

#### Attribute (Constructor)

Attribute(module, name, file, lineno)

Constructor

module
  name of the module containing this class
name
  name of this class
file
  filename containing this attribute
lineno
  linenumber of the class definition

Up

## Class

Class to represent a Python class.

### Derived from

ClbrBaseClasses.Class, VisibilityMixin

### Class Attributes

None

### Class Methods

None

### Methods

Class | Constructor

### Static Methods

None

#### Class (Constructor)

Class(module, name, superClasses, file, lineno)

Constructor

module
  name of the module containing this class
name
  name of this class
superClasses
  list of class names this class is inherited from
file
  filename containing this class
lineno
  linenumber of the class definition

Up

## Function

Class to represent a Python function.

### Derived from

ClbrBaseClasses.Function, VisibilityMixin

### Class Attributes

None

### Class Methods

None

### Methods

Function | Constructor

### Static Methods

None

#### Function (Constructor)

Function(module, name, file, lineno, signature='', separator=', ', modifierType=ClbrBaseClasses.Function.General, annotation="")

Constructor

module
  name of the module containing this function
name
  name of this function
file
  filename containing this class
lineno
  linenumber of the class definition
signature
  parameterlist of the method
separator
  string separating the parameters
modifierType
  type of the function
annotation
  return annotation

Up

## ImportedModule

Class to represent an imported module.

### Derived from

object

### Class Attributes

None

### Class Methods

None

### Methods

ImportedModule | Constructor
addImport | Public method to add a list of imported names.

### Static Methods

None

#### ImportedModule (Constructor)

ImportedModule(module, file, importedModule)

Constructor

module
  name of the module containing the import (string)
file
  file name containing the import (string)
importedModule
  name of the imported module (string)

#### ImportedModule.addImport

addImport(lineno, importedNames)

Public method to add a list of imported names.

lineno
  line number of the import
importedNames
  list of imported names (list of strings)

Up

## Imports

Class to represent the list of imported modules.

### Derived from

object

### Class Attributes

None

### Class Methods

None

### Methods

Imports | Constructor
addImport | Public method to add a list of imported names.
getImport | Public method to get an imported module item.
getImports | Public method to get all imported module names.

### Static Methods

None

#### Imports (Constructor)

Imports(module, file)

Constructor

module
  name of the module containing the import (string)
file
  file name containing the import (string)

#### Imports.addImport

addImport(moduleName, names, lineno)

Public method to add a list of imported names.

moduleName
  name of the imported module (string)
names
  list of names (list of strings)
lineno
  line number of the import

#### Imports.getImport

getImport(moduleName)

Public method to get an imported module item.

moduleName
  name of the imported module (string)

Returns:
  imported module item (ImportedModule) or None

#### Imports.getImports

getImports()

Public method to get all imported module names.

Returns:
  dictionary of imported module names with name as key and list of line numbers of imports as value

Up

## Publics

Class to represent the list of public identifiers.

### Derived from

object

### Class Attributes

None

### Class Methods

None

### Methods

Publics | Constructor

### Static Methods

None

#### Publics (Constructor)

Publics(module, file, lineno, idents)

Constructor

module
  name of the module containing this function
file
  filename containing this class
lineno
  linenumber of the class definition
idents
  list of public identifiers

Up

## VisibilityMixin

Mixin class implementing the notion of visibility.

### Derived from

ClbrBaseClasses.ClbrVisibilityMixinBase

### Class Attributes

None

### Class Methods

None

### Methods

VisibilityMixin | Constructor

### Static Methods

None

#### VisibilityMixin (Constructor)

VisibilityMixin()

Constructor

Up

## _indent

_indent(ws)

Module function to return the indentation depth.

ws
  the whitespace to be checked (string)

Returns:
  length of the whitespace string (integer)

Up

## readmodule_ex

readmodule_ex(module, path=None, inpackage=False, isPyFile=False)

Read a module file and return a dictionary of classes.

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.

module
  name of the module file (string)
path
  path the module should be searched in (list of strings)
inpackage
  flag indicating a module inside a package is scanned
isPyFile
  flag indicating a Python file (boolean)

Returns:
  the resulting dictionary

Up