diff options
author | Gregory Lee <lee218@llnl.gov> | 2017-03-09 10:36:32 -0800 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2017-03-09 10:36:32 -0800 |
commit | 604b75c1f9d53e0f094a22d1167558aa4df566af (patch) | |
tree | be4e614e34d061617f61a1a5c9849ad12ebfcf8e /lib | |
parent | 2ac343e92ea0213121f05e4edaf51da4abfd79c9 (diff) | |
download | spack-604b75c1f9d53e0f094a22d1167558aa4df566af.tar.gz spack-604b75c1f9d53e0f094a22d1167558aa4df566af.tar.bz2 spack-604b75c1f9d53e0f094a22d1167558aa4df566af.tar.xz spack-604b75c1f9d53e0f094a22d1167558aa4df566af.zip |
created elf virtual package and updated dependent packages (#3317)
* created elf virtual package and updated dependent packages
* added `hide_files` context manager to handle moving files.
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'): |