class documentation

class twisted.python.modules.PythonModule(_ModuleIteratorHelper): (source)

View In Hierarchy

Representation of a module which could be imported from sys.path.

Instance Variable name the fully qualified python name of this module.
Instance Variable filePath a FilePath-like object which points to the location of this module.
Instance Variable pathEntry a PathEntry instance which this module was located from.
Method __init__ Create a PythonModule. Do not construct this directly, instead inspect a PythonPath or other PythonModule instances.
Instance Variable parentPath Undocumented
Method __repr__ Return a string representation including the module name.
Method isLoaded Determine if the module is loaded into sys.modules.
Method iterAttributes List all the attributes defined in this module.
Method isPackage Returns true if this module is also a package, and might yield something from iterModules.
Method load Load this module.
Method __eq__ PythonModules with the same name are equal.
Method walkModules Similar to iterModules, this yields self, and then every module in my package or entry, and every submodule in each package or entry.
Method _getEntry Implement in subclasses to specify what path entry submodules will come from.
Method _subModuleName submodules of this module are prefixed with our name.
Method _packagePaths Yield a sequence of FilePath-like objects which represent path segments.

Inherited from _ModuleIteratorHelper:

Method iterModules Loop over the modules present below this entry or package on PYTHONPATH.
Method __getitem__ Retrieve a module from below this path or package.
Method __iter__ Implemented to raise NotImplementedError for clarity, so that attempting to loop over this object won't call __getitem__.
name = (source)
the fully qualified python name of this module.
filePath = (source)
a FilePath-like object which points to the location of this module.
pathEntry = (source)
a PathEntry instance which this module was located from.
def __init__(self, name, filePath, pathEntry): (source)

Create a PythonModule. Do not construct this directly, instead inspect a PythonPath or other PythonModule instances.

Parametersnamesee ivar
filePathsee ivar
pathEntrysee ivar
parentPath = (source)

Undocumented

def _getEntry(self): (source)

Implement in subclasses to specify what path entry submodules will come from.

Returnsa PathEntry instance.
def __repr__(self): (source)

Return a string representation including the module name.

ReturnsUndocumented (type: str)
def isLoaded(self): (source)

Determine if the module is loaded into sys.modules.

Returnsa boolean: true if loaded, false if not.
def iterAttributes(self): (source)

List all the attributes defined in this module.

Note: Future work is planned here to make it possible to list python attributes on a module without loading the module by inspecting ASTs or bytecode, but currently any iteration of PythonModule objects insists they must be loaded, and will use inspect.getmodule.

Returnsa generator yielding PythonAttribute instances describing the attributes of this module.
RaisesNotImplementedErrorif this module is not loaded.
def isPackage(self): (source)

Returns true if this module is also a package, and might yield something from iterModules.

def load(self, default=_nothing): (source)

Load this module.

Parametersdefaultif specified, the value to return in case of an error.
Returnsa genuine python module. (type: types.ModuleType.)
RaisesExceptionImporting modules is a risky business; the erorrs of any code run at module scope may be raised from here, as well as ImportError if something bizarre happened to the system path between the discovery of this PythonModule object and the attempt to import it. If you specify a default, the error will be swallowed entirely, and not logged.
def __eq__(self, other): (source)

PythonModules with the same name are equal.

ParametersotherUndocumented (type: object)
ReturnsUndocumented (type: bool)
def walkModules(self, importPackages=False): (source)

Similar to iterModules, this yields self, and then every module in my package or entry, and every submodule in each package or entry.

In other words, this is deep, and iterModules is shallow.

def _subModuleName(self, mn): (source)

submodules of this module are prefixed with our name.

def _packagePaths(self): (source)

Yield a sequence of FilePath-like objects which represent path segments.

API Documentation for Twisted, generated by pydoctor 20.12.1 at 2021-02-28 19:53:36.