diff options
| author | Yaakov M. Nemoy <loupgaroublond@gmail.com> | 2009-02-05 17:11:40 +0100 |
|---|---|---|
| committer | Yaakov M. Nemoy <loupgaroublond@gmail.com> | 2009-02-05 17:11:40 +0100 |
| commit | 85d8bd9c75d31053567d493b9bd16843be325a07 (patch) | |
| tree | 49d546bfeb87750aafcd74638dc829c69c16a8ec /base | |
| parent | a5f537fa183b4e7e0bfcd4bb4088eb816ff59728 (diff) | |
| download | fedora-devshell-85d8bd9c75d31053567d493b9bd16843be325a07.tar.gz fedora-devshell-85d8bd9c75d31053567d493b9bd16843be325a07.tar.xz fedora-devshell-85d8bd9c75d31053567d493b9bd16843be325a07.zip | |
Makes close_later a generic function rather than a method of some class
Diffstat (limited to 'base')
| -rw-r--r-- | base/util.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/base/util.py b/base/util.py index 5193bcd..acea171 100644 --- a/base/util.py +++ b/base/util.py @@ -52,7 +52,7 @@ def rm(tgt): rmtree(tgt) else: remove(tgt) - + def copy(src, dst): # we're using copyfileobj so we can do this from a URL if isfile(src): @@ -71,7 +71,7 @@ def symlink(src, dst): rm(dst) sym(abspath(src), abspath(dst)) return dst - + def move(src, dst): if lexists(dst): rm(dst) @@ -112,5 +112,24 @@ def base_dir(tarball): ti = tarball.next() return ti.name.split('/')[0] +_to_close = list() +_all_closed = False + +def close_later(directory): + global _to_close + if directory not in _to_close: + self._to_close.append(directory) + return directory + +def close_all(): + global _all_closed + global _to_close + if _all_closed: + return + for directory in _to_close: + directory.close() + + __all__ = ['pwd', 'copy', 'with_sudo', 'with_su', 'symlink', 'move', - 'log_file', 'one', 'remove_all', 'flatten', 'base_dir'] + 'log_file', 'one', 'remove_all', 'flatten', 'base_dir', + 'close_later', 'close_all'] |
