The Gaudi Framework  v32r2 (46d42edc)
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 219 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 227 of file GaudiTest.py.

227  def __init__(self,
228  suffix='',
229  prefix='tmp',
230  dir=None,
231  text=False,
232  keep=False):
233  self.file = None
234  self.name = None
235  self._keep = keep
236 
237  self._fd, self.name = tempfile.mkstemp(suffix, prefix, dir, text)
238  self.file = os.fdopen(self._fd, "r+")
239 

◆ __del__()

def GaudiTest.TempFile.__del__ (   self)

Definition at line 243 of file GaudiTest.py.

243  def __del__(self):
244  if self.file:
245  self.file.close()
246  if self.name and not self._keep:
247  os.remove(self.name)
248 

Member Function Documentation

◆ __getattr__()

def GaudiTest.TempFile.__getattr__ (   self,
  attr 
)

Definition at line 249 of file GaudiTest.py.

249  def __getattr__(self, attr):
250  return getattr(self.file, attr)
251 
252 

◆ __str__()

def GaudiTest.TempFile.__str__ (   self)

Definition at line 240 of file GaudiTest.py.

240  def __str__(self):
241  return self.name
242 

Member Data Documentation

◆ _keep

GaudiTest.TempFile._keep
private

Definition at line 230 of file GaudiTest.py.

◆ file

GaudiTest.TempFile.file

Definition at line 228 of file GaudiTest.py.

◆ name

GaudiTest.TempFile.name

Definition at line 229 of file GaudiTest.py.


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