LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Public Attributes | List of all members
lsst.pex.config.config.RecordingImporter Class Reference

Public Member Functions

def __init__ (self)
 
def __enter__ (self)
 
def __exit__ (self, *args)
 
def uninstall (self)
 
def find_module (self, fullname, path=None)
 
def getModules (self)
 

Public Attributes

 origMetaPath
 

Detailed Description

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())

Definition at line 693 of file config.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pex.config.config.RecordingImporter.__init__ (   self)

Definition at line 710 of file config.py.

710  def __init__(self):
711  self._modules = set()
712 
daf::base::PropertySet * set
Definition: fits.cc:912

Member Function Documentation

◆ __enter__()

def lsst.pex.config.config.RecordingImporter.__enter__ (   self)

Definition at line 713 of file config.py.

713  def __enter__(self):
714  self.origMetaPath = sys.meta_path
715  sys.meta_path = [self] + sys.meta_path
716  return self
717 

◆ __exit__()

def lsst.pex.config.config.RecordingImporter.__exit__ (   self,
args 
)

Definition at line 718 of file config.py.

718  def __exit__(self, *args):
719  self.uninstall()
720  return False # Don't suppress exceptions
721 

◆ find_module()

def lsst.pex.config.config.RecordingImporter.find_module (   self,
  fullname,
  path = None 
)
Called as part of the ``import`` chain of events.

Definition at line 727 of file config.py.

727  def find_module(self, fullname, path=None):
728  """Called as part of the ``import`` chain of events.
729  """
730  self._modules.add(fullname)
731  # Return None because we don't do any importing.
732  return None
733 

◆ getModules()

def 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.

Definition at line 734 of file config.py.

734  def getModules(self):
735  """Get the set of modules that were imported.
736 
737  Returns
738  -------
739  modules : `set` of `str`
740  Set of imported module names.
741  """
742  return self._modules
743 
744 

◆ uninstall()

def lsst.pex.config.config.RecordingImporter.uninstall (   self)
Uninstall the importer.

Definition at line 722 of file config.py.

722  def uninstall(self):
723  """Uninstall the importer.
724  """
725  sys.meta_path = self.origMetaPath
726 

Member Data Documentation

◆ origMetaPath

lsst.pex.config.config.RecordingImporter.origMetaPath

Definition at line 714 of file config.py.


The documentation for this class was generated from the following file: