The Gaudi Framework  v33r1 (b1225454)
GaudiTest.TempFile Class Reference

Public Member Functions

def __init__ (self, suffix='', prefix='tmp', dir=None, text=False, keep=False)
 
def __str__ (self)
 
def __del__ (self)
 
def __getattr__ (self, attr)
 

Public Attributes

 file
 
 name
 

Private Attributes

 _keep
 

Detailed Description

Small class for temporary files.
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 229 of file GaudiTest.py.

Constructor & Destructor Documentation

◆ __init__()

def GaudiTest.TempFile.__init__ (   self,
  suffix = '',
  prefix = 'tmp',
  dir = None,
  text = False,
  keep = False 
)

Definition at line 237 of file GaudiTest.py.

237  def __init__(self,
238  suffix='',
239  prefix='tmp',
240  dir=None,
241  text=False,
242  keep=False):
243  self.file = None
244  self.name = None
245  self._keep = keep
246 
247  self._fd, self.name = tempfile.mkstemp(suffix, prefix, dir, text)
248  self.file = os.fdopen(self._fd, "r+")
249 

◆ __del__()

def GaudiTest.TempFile.__del__ (   self)

Definition at line 253 of file GaudiTest.py.

253  def __del__(self):
254  if self.file:
255  self.file.close()
256  if self.name and not self._keep:
257  os.remove(self.name)
258 

Member Function Documentation

◆ __getattr__()

def GaudiTest.TempFile.__getattr__ (   self,
  attr 
)

Definition at line 259 of file GaudiTest.py.

259  def __getattr__(self, attr):
260  return getattr(self.file, attr)
261 
262 

◆ __str__()

def GaudiTest.TempFile.__str__ (   self)

Definition at line 250 of file GaudiTest.py.

250  def __str__(self):
251  return self.name
252 

Member Data Documentation

◆ _keep

GaudiTest.TempFile._keep
private

Definition at line 240 of file GaudiTest.py.

◆ file

GaudiTest.TempFile.file

Definition at line 238 of file GaudiTest.py.

◆ name

GaudiTest.TempFile.name

Definition at line 239 of file GaudiTest.py.


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