class twisted.python.modules.PythonModule(_ModuleIteratorHelper): (source)
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__. |
Create a PythonModule. Do not construct this directly, instead inspect a PythonPath or other PythonModule instances.
Parameters | name | see ivar |
filePath | see ivar | |
pathEntry | see ivar |
Implement in subclasses to specify what path entry submodules will come from.
Returns | a PathEntry instance. |
Return a string representation including the module name.
Returns | Undocumented (type: str ) |
Determine if the module is loaded into sys.modules.
Returns | a boolean: true if loaded, false if not. |
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 | NotImplementedError | if this module is not loaded. |
Returns true if this module is also a package, and might yield something from iterModules.
Load this module.
Parameters | default | if specified, the value to return in case of an error. |
Returns | a genuine python module. (type: types.ModuleType.) | |
Raises | Exception | Importing 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. |
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.
Yield a sequence of FilePath-like objects which represent path segments.