armi.utils.directoryChangers module
- class armi.utils.directoryChangers.DirectoryChanger(destination, filesToMove=None, filesToRetrieve=None, dumpOnException=True, outputPath=None)[source]
Bases:
objectUtility 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:
DirectoryChangerCreate a temporary directory, change into it, and if there is no error/exception generated when using a
withstatement, delete the directory.Notes
If there is an error/exception generated while in a
withstatement, the temporary directory contents will be copied to the original directory and then the temporary directory will be deleted.There is the ability for a user to set the environment variable ARMI_TEMP_ROOT_PATH, which will globally override the root argument being passed in. This is a useful tool for running code or tests in a read-only environment.
- class armi.utils.directoryChangers.ForcedCreationDirectoryChanger(destination, filesToMove=None, filesToRetrieve=None, dumpOnException=True, outputPath=None)[source]
Bases:
DirectoryChangerCreates the directory tree necessary to reach your desired destination.