The Gaudi Framework  v33r0 (d5ea422b)
GaudiTest.TempDir Class Reference

Public Member Functions

def __init__ (self, keep=False, chdir=False)
 
def __str__ (self)
 
def __del__ (self)
 
def __getattr__ (self, attr)
 

Public Attributes

 name
 

Private Attributes

 _keep
 
 _origdir
 

Detailed Description

Small class for temporary directories.
When instantiated, it creates a temporary directory and the instance
behaves as the string containing the directory name.
When the instance goes out of scope, it removes all the content of
the temporary directory (automatic clean-up).

Definition at line 200 of file GaudiTest.py.

Constructor & Destructor Documentation

◆ __init__()

def GaudiTest.TempDir.__init__ (   self,
  keep = False,
  chdir = False 
)

Definition at line 208 of file GaudiTest.py.

208  def __init__(self, keep=False, chdir=False):
209  self.name = tempfile.mkdtemp()
210  self._keep = keep
211  self._origdir = None
212  if chdir:
213  self._origdir = os.getcwd()
214  os.chdir(self.name)
215 

◆ __del__()

def GaudiTest.TempDir.__del__ (   self)

Definition at line 219 of file GaudiTest.py.

219  def __del__(self):
220  if self._origdir:
221  os.chdir(self._origdir)
222  if self.name and not self._keep:
223  shutil.rmtree(self.name)
224 

Member Function Documentation

◆ __getattr__()

def GaudiTest.TempDir.__getattr__ (   self,
  attr 
)

Definition at line 225 of file GaudiTest.py.

225  def __getattr__(self, attr):
226  return getattr(self.name, attr)
227 
228 

◆ __str__()

def GaudiTest.TempDir.__str__ (   self)

Definition at line 216 of file GaudiTest.py.

216  def __str__(self):
217  return self.name
218 

Member Data Documentation

◆ _keep

GaudiTest.TempDir._keep
private

Definition at line 210 of file GaudiTest.py.

◆ _origdir

GaudiTest.TempDir._origdir
private

Definition at line 211 of file GaudiTest.py.

◆ name

GaudiTest.TempDir.name

Definition at line 209 of file GaudiTest.py.


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