Package mdp :: Package utils :: Class TemporaryDirectory
[hide private]
[frames] | no frames]

Class TemporaryDirectory


Create and return a temporary directory.  This has the same
behavior as mkdtemp but can be used as a context manager.  For
example:

    with TemporaryDirectory() as tmpdir:
        ...

Upon exiting the context, the directory and everthing contained
in it are removed.

Nested Classes [hide private]
  _os_error
OS system call failed.
Instance Methods [hide private]
 
__del__(self)
 
__enter__(self)
 
__exit__(self, exc, value, tb)
 
__init__(self, suffix='', prefix='tmp', dir=None)
x.__init__(...) initializes x; see help(type(x)) for signature
 
__repr__(self)
repr(x)
 
_rmtree(self, path)
 
cleanup(self, _warn=False)

Inherited from unreachable.newobject: __long__, __native__, __nonzero__, __unicode__, next

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
 
_isdir(s)
Return true if the pathname refers to an existing directory.
list_of_strings

_listdir(path)
Return a list containing the names of the entries in the directory.
 
_path_join(a, *p)
Join two or more pathname components, inserting '/' as needed.
 
_remove(path)
Remove a file (same as unlink(path)).
 
_rmdir(path)
Remove a directory.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__del__(self)
(Destructor)

 

__enter__(self)

 

__exit__(self, exc, value, tb)

 

__init__(self, suffix='', prefix='tmp', dir=None)
(Constructor)

 
x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__repr__(self)
(Representation operator)

 
repr(x)

Overrides: object.__repr__
(inherited documentation)

_isdir(s)
Static Method

 
Return true if the pathname refers to an existing directory.

_listdir(path)
Static Method

 
Return a list containing the names of the entries in the directory.

    path: path of directory to list

The list is in arbitrary order.  It does not include the special
entries '.' and '..' even if they are present in the directory.

Returns:
list_of_strings

_path_join(a, *p)
Static Method

 
Join two or more pathname components, inserting '/' as needed.
If any component is an absolute path, all previous path components
will be discarded.  An empty last part will result in a path that
ends with a separator.

_remove(path)
Static Method

 
Remove a file (same as unlink(path)).

_rmdir(path)
Static Method

 
Remove a directory.

_rmtree(self, path)

 

cleanup(self, _warn=False)