armi.utils.directoryChangers module¶
- class armi.utils.directoryChangers.DirectoryChanger(destination, filesToMove=None, filesToRetrieve=None, dumpOnException=True, outputPath=None)[source]¶
Bases:
object
Utility to change directory.
Use with ‘with’ statements to execute code in a different dir, guaranteeing a clean return to the original directory
>>> with DirectoryChanger('C:\whatever') ... pass
- Parameters
destination (str) – Path of directory to change into
filesToMove (list of str, optional) – Filenames to bring from the CWD into the destination
filesToRetrieve (list of str, optional) – Filenames to bring back from the destination to the cwd. Note that if any of these files do not exist then the file will be skipped and a warning will be provided.
dumpOnException (bool, optional) – Flag to tell system to retrieve the entire directory if an exception is raised within a the context manager.
outputPath (str, optional) – Output path for filesToRetrieve. If None, default is the initial working directory from which the DirectoryChanger is called.
Establish the new and return directories
- class armi.utils.directoryChangers.TemporaryDirectoryChanger(root=None, filesToMove=None, filesToRetrieve=None, dumpOnException=True, outputPath=None)[source]¶
Bases:
armi.utils.directoryChangers.DirectoryChanger
Create temporary directory, changes into it, and if there is no error/exception generated when using a
with
statement, it deletes the directory.Notes
If there is an error/exception generated while in a
with
statement, the temporary directory contents will be copied to the original directory and then the temporary directory will be deleted.
- class armi.utils.directoryChangers.ForcedCreationDirectoryChanger(destination, filesToMove=None, filesToRetrieve=None, dumpOnException=True, outputPath=None)[source]¶
Bases:
armi.utils.directoryChangers.DirectoryChanger
Creates the directory tree necessary to reach your desired destination