armi.utils.directoryChangers module

class armi.utils.directoryChangers.DirectoryChanger(destination, filesToMove=None, filesToRetrieve=None, dumpOnException=True)[source]

Bases: object

Utility to change directory.

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

  • dumpOnException (bool, optional) – Flag to tell system to retrieve the entire directory if an exception is raised within a the context manager.

  • dir (Use with 'with' statements to execute code in a different) –

  • clean (guaranteeing a) –

  • directory (return to the original) –

  • DirectoryChanger('C (>>> with) –

  • pass (...) –

Establish the new and return directories

open()[source]

User requested open, used to stalling the close from a with statement.

This method has been made for old uses of os.chdir() and is not recommended. Please use the with statements

close()[source]

User requested close.

moveFiles()[source]

Copy filesToMove into the destination directory on entry.

retrieveFiles()[source]

Copy filesToRetrieve back into the initial directory on exit.

class armi.utils.directoryChangers.TemporaryDirectoryChanger(root=None, filesToMove=None, filesToRetrieve=None, dumpOnException=True)[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.

Establish the new and return directories

classmethod GetRandomDirectory(root)[source]
class armi.utils.directoryChangers.ForcedCreationDirectoryChanger(destination, filesToMove=None, filesToRetrieve=None, dumpOnException=True)[source]

Bases: armi.utils.directoryChangers.DirectoryChanger

Creates the directory tree necessary to reach your desired destination

Establish the new and return directories

armi.utils.directoryChangers.directoryChangerFactory()[source]