PyFoam.RunDictionary.FileBasis module
Basis for the handling of OpenFOAM-files
Transparently accepts gnuzipped files
- class PyFoam.RunDictionary.FileBasis.CleanCharactersFile(name, charsToRemove)[source]
Bases:
FileBasisRead file and remove characters from the content
- __annotations__ = {}
- __init__(name, charsToRemove)[source]
@param charsToRemove: string with characters that should be removed
- __module__ = 'PyFoam.RunDictionary.FileBasis'
- class PyFoam.RunDictionary.FileBasis.FileBasis(name, createZipped=True, useBinary=False)[source]
Bases:
UtilitiesBase class for the other OpenFOAM–file-classes
- __annotations__ = {}
- __init__(name, createZipped=True, useBinary=False)[source]
- Parameters:
name – Name of the file. If the field is zipped the .gz is
appended. Alternatively it can be a filehandle :param createZipped: if the file doesnot exist: should it be created as a zipped file?
- __module__ = 'PyFoam.RunDictionary.FileBasis'
- addedString = '//PyFoamAdded'
Comment for lines that were added by PyFoam-routines
- copyRest(l, out)[source]
Copy the rest of the file
- Parameters:
l – a LineReader object
out – filehandle to echo the lines to
- getCaseDir()[source]
Return the path to the case of this file (if any valid case is found). Else return None
- goMatch(l, exp, out=None, stop=None)[source]
Read lines until a regular expression is matched
- Parameters:
l – a LineReader object
exp – the expression to look for
out – filehandle to echo the lines to
stop – pattern that indicates that exp will never be found
- Returns:
match-object if exp is found, the line if stop is found and None if the end of the file is reached
- goTo(l, s, out=None, echoLast=False, stop=None)[source]
Read lines until a token is found
- Parameters:
l – a LineReader object
s – the string to look for
out – filehandle to echo the lines to
stop – pattern that indicates that exp will never be found (only passed through to goMatch)
echoLast – echo the line with the string
- purgeFile()[source]
Undo all the manipulations done by PyFOAM
Goes through the file and removes all lines that were added
- removedString = '//PyFoamRemoved: '
Comment for lines that were overwritten by PyFoam-routines
- class PyFoam.RunDictionary.FileBasis.FileBasisBackup(name, backup=False, createZipped=True, useBinary=False)[source]
Bases:
FileBasisA file with a backup-copy
- __annotations__ = {}
- __init__(name, backup=False, createZipped=True, useBinary=False)[source]
- Parameters:
name (str) – The name of the parameter file
backup (boolean) – create a backup-copy of the file
- __module__ = 'PyFoam.RunDictionary.FileBasis'
- counter = {}