Public Member Functions | |
| __init__ (self) | |
| __enter__ (self) | |
| __exit__ (self, *args) | |
| uninstall (self) | |
| find_spec (self, fullname, path, target=None) | |
| getModules (self) | |
Public Attributes | |
| origMetaPath = sys.meta_path | |
Protected Attributes | |
| _modules = set() | |
Importer (for `sys.meta_path`) that records which modules are being
imported.
*This class does not do any importing itself.*
Examples
--------
Use this class as a context manager to ensure it is properly uninstalled
when done:
>>> with RecordingImporter() as importer:
... # import stuff
... import numpy as np
... print("Imported: " + importer.getModules())
| lsst.pex.config.config.RecordingImporter.find_spec | ( | self, | |
| fullname, | |||
| path, | |||
| target = None ) |
Find a module.
Called as part of the ``import`` chain of events.
Parameters
----------
fullname : `str`
Name of module.
path : `list` [`str`]
Search path. Unused.
target : `~typing.Any`, optional
Unused.
| lsst.pex.config.config.RecordingImporter.getModules | ( | self | ) |
Get the set of modules that were imported.
Returns
-------
modules : `set` of `str`
Set of imported module names.
| lsst.pex.config.config.RecordingImporter.uninstall | ( | self | ) |
Uninstall the importer.