LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Public Attributes | Private Attributes | List of all members
lsst.pex.config.config.RecordingImporter Class Reference
Inheritance diagram for lsst.pex.config.config.RecordingImporter:

Public Member Functions

def __init__
 
def __enter__
 
def __exit__
 
def uninstall
 
def find_module
 
def getModules
 

Public Attributes

 origMetaPath
 

Private Attributes

 _modules
 

Detailed Description

An Importer (for sys.meta_path) that records which modules are being imported.

Objects also act as Context Managers, so you can:
    with RecordingImporter() as importer:
        import stuff
    print "Imported: " + importer.getModules()
This ensures it is properly uninstalled when done.

This class makes no effort to do any importing itself.

Definition at line 351 of file config.py.

Constructor & Destructor Documentation

def lsst.pex.config.config.RecordingImporter.__init__ (   self)
Create and install the Importer

Definition at line 362 of file config.py.

363  def __init__(self):
364  """Create and install the Importer"""
365  self._modules = set()

Member Function Documentation

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

Definition at line 366 of file config.py.

367  def __enter__(self):
369  self.origMetaPath = sys.meta_path
370  sys.meta_path = [self] + sys.meta_path
371  return self
def lsst.pex.config.config.RecordingImporter.__exit__ (   self,
  args 
)

Definition at line 372 of file config.py.

373  def __exit__(self, *args):
374  self.uninstall()
375  return False # Don't suppress exceptions
def lsst.pex.config.config.RecordingImporter.find_module (   self,
  fullname,
  path = None 
)
Called as part of the 'import' chain of events.

We return None because we don't do any importing.

Definition at line 380 of file config.py.

381  def find_module(self, fullname, path=None):
382  """Called as part of the 'import' chain of events.
383 
384  We return None because we don't do any importing.
385  """
386  self._modules.add(fullname)
387  return None
def lsst.pex.config.config.RecordingImporter.getModules (   self)
Return the set of modules that were imported.

Definition at line 388 of file config.py.

389  def getModules(self):
390  """Return the set of modules that were imported."""
391  return self._modules
def lsst.pex.config.config.RecordingImporter.uninstall (   self)
Uninstall the Importer

Definition at line 376 of file config.py.

377  def uninstall(self):
378  """Uninstall the Importer"""
379  sys.meta_path = self.origMetaPath

Member Data Documentation

lsst.pex.config.config.RecordingImporter._modules
private

Definition at line 364 of file config.py.

lsst.pex.config.config.RecordingImporter.origMetaPath

Definition at line 368 of file config.py.


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