HWRF  trunk@4391
Public Member Functions | Public Attributes | List of all members
produtil.cd.NamedDir Class Reference

This subclass of TempDir takes a directory name, instead of generating one automatically. More...

Detailed Description

This subclass of TempDir takes a directory name, instead of generating one automatically.

By default, it will NOT delete the directory upon exit. That can be overridden by specifying keep=False.

Definition at line 228 of file cd.py.

Inheritance diagram for produtil.cd.NamedDir:
produtil.cd.TempDir

Public Member Functions

def __init__
 Create a NamedDir for the specified directory. More...
 
def name_make_dir (self)
 Replacement for the TempDir.name_make_dir. More...
 
- Public Member Functions inherited from produtil.cd.TempDir
def __init__
 Creates a TempDir. More...
 
def name_make_dir (self)
 Decide the name of the directory, and create the directory. More...
 
def mkdir_cd (self)
 Creates the temporary directory and chdirs the current process into that directory. More...
 
def cd_out (self)
 Exit the temporary directory created by mkdir_cd and return to the original directory, if possible. More...
 
def cd_rmdir (self)
 CD out and remove the old directory. More...
 
def exception_info (self)
 Called to dump information to a log, or failing that, the terminal if an unexpected exception is caught. More...
 
def __enter__ (self)
 This is a simple wrapper around mkdir_cd that is intended to be used with in a "with" block. More...
 
def __exit__ (self, etype, value, traceback)
 Exit the 'with' block. More...
 

Public Attributes

 dirname
 The directory name specified in the constructor. More...
 
- Public Attributes inherited from produtil.cd.TempDir
 dirname
 The name of the target directory. More...
 
 suffix
 Temporary directory name suffix.
 
 prefix
 Temporary directory name prefix.
 
 print_on_exception
 Should we print exceptions before exiting the directory?
 
 dir
 The directory object. More...
 
 olddir
 The name of the directory we came from. More...
 

Constructor & Destructor Documentation

def produtil.cd.NamedDir.__init__ (   self,
  dirname,
  keep = True,
  logger = None,
  keep_on_error = True,
  add_perms = 0,
  remove_perms = 0,
  rm_first = False 
)

Create a NamedDir for the specified directory.

The given logger is used to log messages. There are two deletion vs. non-deletion options:

Parameters
dirnameThe directory name
keepIf False, the file is deleted upon successful return of the "with" block. If True, the file is kept upon successful return.
loggerA logging.logger for log messages
add_permsPermissions to add to the directory after cding into it. Default: none.
remove_permsPermissions to remove from the directory after cding into it. Default: none.
keep_on_errorControls deletion upon catching of an Exception or GeneratorException (or subclass thereof).
rm_firstIf the directory already exists, delete it first and make a new one before cding to it.

Definition at line 234 of file cd.py.

Member Function Documentation

def produtil.cd.NamedDir.name_make_dir (   self)

Replacement for the TempDir.name_make_dir.

Uses the directory name specified in the constructor.

Definition at line 262 of file cd.py.

Member Data Documentation

produtil.cd.NamedDir.dirname

The directory name specified in the constructor.

Definition at line 258 of file cd.py.


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