armi.utils.directoryChangers module

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

Bases: object

Utility class to change directory

Use with ‘with’ statements to execute code in a different dir, guaranteeing a clean return to the original directory

>>> with DirectoryChanger(r'C:\whatever')
...     pass

Establish the new and return directories

__enter__()[source]

At the inception of a with command, navigate to a new directory if one is supplied.

__exit__(exc_type, exc_value, traceback)[source]

At the termination of a with command, navigate back to the original directory.

__repr__()[source]

Print the initial and destination paths

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]
retrieveFiles()[source]

Retrieve any desired files.

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

Establish the new and return directories

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

Bases: armi.utils.directoryChangers.DirectoryChanger

Creates the directory tree necessary to reach your desired destination

clean

if True and the directory exists, clear all contents on entry.

Type

bool

Establish the new and return directories

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