class documentation

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

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

Inherited from _ModuleIteratorHelper:

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__.
Method iterModules Loop over the modules present below this entry or package on PYTHONPATH.
def __eq__(self, other: object) -> bool: (source)

PythonModules with the same name are equal.

def __init__(self, name: str, filePath: FilePath[str], pathEntry: PathEntry): (source)

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

Parameters
name:strsee ivar
filePath:FilePath[str]see ivar
pathEntry:PathEntrysee ivar
def __repr__(self) -> str: (source)

Return a string representation including the module name.

def isLoaded(self): (source)

Determine if the module is loaded into sys.modules.

Returns
a boolean: true if loaded, false if not.
def isPackage(self): (source)

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

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.

Returns
a generator yielding PythonAttribute instances describing the attributes of this module.
Raises
NotImplementedErrorif this module is not loaded.
def load(self, default=_nothing): (source)

Load this module.

Parameters
defaultif specified, the value to return in case of an error.
Returns
types.ModuleType.a genuine python module.
Raises
ExceptionImporting 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 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.

filePath = (source)

a FilePath-like object which points to the location of this module.

the fully qualified python name of this module.

parentPath = (source)

Undocumented

pathEntry = (source)

a PathEntry instance which this module was located from.

def _getEntry(self): (source)

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

Returns
a PathEntry instance.
def _packagePaths(self): (source)

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

def _subModuleName(self, mn): (source)

submodules of this module are prefixed with our name.