diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/llnl/util/filesystem.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index 7f6773266d..f456a5edf1 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -50,6 +50,7 @@ __all__ = [ 'fix_darwin_install_name', 'force_remove', 'force_symlink', + 'hide_files', 'install', 'install_tree', 'is_exe', @@ -257,6 +258,18 @@ def working_dir(dirname, **kwargs): os.chdir(orig_dir) +@contextmanager +def hide_files(*file_list): + try: + baks = ['%s.bak' % f for f in file_list] + for f, bak in zip(file_list, baks): + shutil.move(f, bak) + yield + finally: + for f, bak in zip(file_list, baks): + shutil.move(bak, f) + + def touch(path): """Creates an empty file at the specified path.""" with open(path, 'a'): |