PyFoam.RunDictionary.ParsedParameterFile module
Parameter file is read into memory and modified there
- exception PyFoam.RunDictionary.ParsedParameterFile.BinaryParserError(descr, data=None)[source]
Bases:
PyFoamParserError- __annotations__ = {}
- __module__ = 'PyFoam.RunDictionary.ParsedParameterFile'
- class PyFoam.RunDictionary.ParsedParameterFile.Enumerate(names)[source]
Bases:
object- __dict__ = mappingproxy({'__module__': 'PyFoam.RunDictionary.ParsedParameterFile', '__init__': <function Enumerate.__init__>, '__dict__': <attribute '__dict__' of 'Enumerate' objects>, '__weakref__': <attribute '__weakref__' of 'Enumerate' objects>, '__doc__': None, '__annotations__': {}})
- __module__ = 'PyFoam.RunDictionary.ParsedParameterFile'
- __weakref__
list of weak references to the object (if defined)
- class PyFoam.RunDictionary.ParsedParameterFile.FoamFileParser(content, fName=None, debug=False, noHeader=False, noBody=False, doMacroExpansion=False, boundaryDict=False, preserveComments=True, preserveNewlines=True, listDict=False, listDictWithHeader=False, listLengthUnparsed=None, binaryMode=False, treatBinaryAsASCII=False, duplicateCheck=False, noVectorOrTensor=False, dictStack=None, duplicateFail=True)[source]
Bases:
PlyParserClass that parses a string that contains the contents of an OpenFOAM-file and builds a nested structure of directories and lists from it
- __annotations__ = {}
- __init__(content, fName=None, debug=False, noHeader=False, noBody=False, doMacroExpansion=False, boundaryDict=False, preserveComments=True, preserveNewlines=True, listDict=False, listDictWithHeader=False, listLengthUnparsed=None, binaryMode=False, treatBinaryAsASCII=False, duplicateCheck=False, noVectorOrTensor=False, dictStack=None, duplicateFail=True)[source]
- Parameters:
content – the string to be parsed
fName – Name of the actual file (if any)
debug – output debug information during parsing
noHeader – switch that turns off the parsing of the header
duplicateCheck – Check for duplicates in dictionaries
duplicateFail – Fail if a duplicate is discovered
- __module__ = 'PyFoam.RunDictionary.ParsedParameterFile'
- condenseAllPreFixLists(orig)[source]
Checks whether this list is a list that consists only of prefix-Lists
- literals = '(){};[]^'
- p_dictline(p)[source]
dictline : dictkey dictitem ‘;’ | dictkey list ‘;’ | dictkey prelist ‘;’ | dictkey uniformfield ‘;’ | dictkey fieldvalue ‘;’ | macro | substitution ‘;’ | dictkey codestream ‘;’ | dictkey dictionary | ‘;’
- p_dimension(p)[source]
dimension : ‘[’ number number number number number number number ‘]’ | ‘[’ number number number number number ‘]’ | ‘[’ symbolic_dimension ‘]’
- p_fieldvalue_nonuniform(p)[source]
fieldvalue : NONUNIFORM NAME list | NONUNIFORM prelist | NONUNIFORM NAME prelist
- p_fieldvalue_uniform(p)[source]
fieldvalue : UNIFORM number | UNIFORM vector | UNIFORM tensor | UNIFORM symmtensor
- p_include(p)[source]
include : INCLUDE SCONST ignore_rest_of_line | INCLUDE_ETC SCONST ignore_rest_of_line | INCLUDE_FUNC NAME ignore_rest_of_line | INCLUDE_FUNC SCONST ignore_rest_of_line | INCLUDEIFPRESENT SCONST ignore_rest_of_line
- p_inputMode(p)[source]
inputMode : INPUTMODE ignore_rest_of_line ERROR | INPUTMODE ignore_rest_of_line WARN | INPUTMODE ignore_rest_of_line PROTECT | INPUTMODE ignore_rest_of_line DEFAULT | INPUTMODE ignore_rest_of_line MERGE | INPUTMODE ignore_rest_of_line OVERWRITE
- p_macro(p)[source]
macro : KANALGITTER include RESTOFLINE | KANALGITTER inputMode RESTOFLINE | KANALGITTER remove RESTOFLINE
- p_pitem(p)[source]
pitem : word | SCONST | number | dictionary | list | dimension | substitution | empty
- p_prelist(p)[source]
prelist : integer prelist_seen ‘(’ itemlist ‘)’ | integer prelist_seen ‘(’ binaryblob ‘)’ | integer prelist_seen ‘(’ unparsed ‘)’ | integer prelist_seen ‘{’ item ‘}’
- p_symbolic_dimension(p)[source]
symbolic_dimension : symbolic_dimension_terminal symbolic_dimension | symbolic_dimension_terminal
- p_symbolic_dimension_terminal(p)[source]
symbolic_dimension_terminal : word | number | ‘(’ | ‘)’ | ‘*’ | ‘/’ | ‘^’
- p_tensor(p)[source]
tensor : ‘(’ number number number number number number number number number ‘)’
- p_uniformfield(p)[source]
uniformfield : integer ‘{’ number ‘}’ | integer ‘{’ vector ‘}’ | integer ‘{’ tensor ‘}’ | integer ‘{’ symmtensor ‘}’
- p_word(p)[source]
word : NAME | UNIFORM | NONUNIFORM | MERGE | OVERWRITE | DEFAULT | WARN | PROTECT | ERROR
- reserved = {'FoamFile': 'FOAMFILE', 'default': 'DEFAULT', 'error': 'ERROR', 'include': 'INCLUDE', 'includeEtc': 'INCLUDE_ETC', 'includeFunc': 'INCLUDE_FUNC', 'includeIfPresent': 'INCLUDEIFPRESENT', 'inputMode': 'INPUTMODE', 'merge': 'MERGE', 'nonuniform': 'NONUNIFORM', 'overwrite': 'OVERWRITE', 'protect': 'PROTECT', 'remove': 'REMOVE', 'sinclude': 'INCLUDEIFPRESENT', 'uniform': 'UNIFORM', 'warn': 'WARN'}
- states = (('unparsed', 'exclusive'), ('codestream', 'exclusive'), ('mlcomment', 'exclusive'), ('binaryblob', 'exclusive'), ('ignorerestofline', 'exclusive'))
- t_CODEEND = '\\#\\}'
- t_CODESTART = '\\#\\{'
- t_FCONST = '(-|)((\\d+)(\\.\\d*)([eE](\\+|-)?(\\d+))? | (\\d+)[eE](\\+|-)?(\\d+))([lL]|[fF])?'
- t_ICONST = '(-|)\\d+([uU]|[lL]|[uU][lL]|[lL][uU])?'
- t_KANALGITTER = '\\#'
- t_SCONST = '\\"([^\\\\\\n]|(\\\\.))*?\\"'
- t_binaryblob_ignore = ''
- t_codestream_ignore = ''
- t_ignore = ' \t\r'
- t_ignorerestofline_ignore = ''
- t_mlcomment_ignore = ''
- t_unparsed_ignore = ' \t\n0123456789.-+e'
- tokens = ('NAME', 'ICONST', 'FCONST', 'SCONST', 'FOAMFILE', 'UNIFORM', 'NONUNIFORM', 'UNPARSEDCHUNK', 'CODESTREAMCHUNK', 'REACTION', 'SUBSTITUTION', 'MERGE', 'OVERWRITE', 'ERROR', 'WARN', 'PROTECT', 'DEFAULT', 'INCLUDE', 'INCLUDE_ETC', 'INCLUDE_FUNC', 'INCLUDEIFPRESENT', 'REMOVE', 'INPUTMODE', 'KANALGITTER', 'CODESTART', 'CODEEND', 'BINARYBLOB', 'RESTOFLINE')
- class PyFoam.RunDictionary.ParsedParameterFile.FoamStringParser(content, debug=False, noVectorOrTensor=False, duplicateCheck=False, listDict=False, doMacroExpansion=False, duplicateFail=False)[source]
Bases:
FoamFileParserConvenience class that parses only a headerless OpenFOAM dictionary
- __annotations__ = {}
- __init__(content, debug=False, noVectorOrTensor=False, duplicateCheck=False, listDict=False, doMacroExpansion=False, duplicateFail=False)[source]
- Parameters:
content – the string to be parsed
debug – output debug information during parsing
- __module__ = 'PyFoam.RunDictionary.ParsedParameterFile'
- class PyFoam.RunDictionary.ParsedParameterFile.NotAPrelist(a, b)[source]
Bases:
objectClass to return if the length of the prelist does not fit the prefix
- __dict__ = mappingproxy({'__module__': 'PyFoam.RunDictionary.ParsedParameterFile', '__doc__': 'Class to return if the length of the prelist does not fit the prefix', '__init__': <function NotAPrelist.__init__>, '__dict__': <attribute '__dict__' of 'NotAPrelist' objects>, '__weakref__': <attribute '__weakref__' of 'NotAPrelist' objects>, '__annotations__': {}})
- __module__ = 'PyFoam.RunDictionary.ParsedParameterFile'
- __weakref__
list of weak references to the object (if defined)
- class PyFoam.RunDictionary.ParsedParameterFile.ParsedBoundaryDict(name, treatBinaryAsASCII=False, backup=False, debug=False)[source]
Bases:
ParsedParameterFileConvenience class that parses only a OpenFOAM polyMesh-boundaries file
- __annotations__ = {}
- __init__(name, treatBinaryAsASCII=False, backup=False, debug=False)[source]
- Parameters:
name – The name of the parameter file
backup – create a backup-copy of the file
- __module__ = 'PyFoam.RunDictionary.ParsedParameterFile'
- class PyFoam.RunDictionary.ParsedParameterFile.ParsedFileHeader(name)[source]
Bases:
ParsedParameterFileOnly parse the header of a file
- __annotations__ = {}
- __init__(name)[source]
- Parameters:
name – The name of the parameter file
backup – create a backup-copy of the file
boundaryDict – the file to parse is a boundary file
listDict – the file only contains a list
listDictWithHeader – the file only contains a list and a header
listLengthUnparsed – Lists longer than that length are not parsed
binaryMode – Parse long lists in binary mode (to be overridden by
the settings in the header). :param treatBinaryAsASCII: even if the header says that this is a binary file treat it like an ASCII-file :param noHeader: don’t expect a header :param noBody: don’t read the body of the file (only the header) :param doMacroExpansion: expand #include and $var :param noVectorOrTensor: short lists of length 3, 6 an 9 are NOT interpreted as vectors or tensors :param dontRead: Do not read the file during construction :param longListOutputThreshold: Lists that are longer than this are prefixed with a length :param dictStack: dictionary stack for lookup (only used for include)
- __module__ = 'PyFoam.RunDictionary.ParsedParameterFile'
- class PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile(name, backup=False, debug=False, boundaryDict=False, listDict=False, listDictWithHeader=False, listLengthUnparsed=None, preserveComments=True, noHeader=False, binaryMode=False, treatBinaryAsASCII=False, noBody=False, doMacroExpansion=False, dontRead=False, noVectorOrTensor=False, dictStack=None, createZipped=True, longListOutputThreshold=20)[source]
Bases:
FileBasisBackupParameterfile whose complete representation is read into memory, can be manipulated and afterwards written to disk
- __annotations__ = {}
- __init__(name, backup=False, debug=False, boundaryDict=False, listDict=False, listDictWithHeader=False, listLengthUnparsed=None, preserveComments=True, noHeader=False, binaryMode=False, treatBinaryAsASCII=False, noBody=False, doMacroExpansion=False, dontRead=False, noVectorOrTensor=False, dictStack=None, createZipped=True, longListOutputThreshold=20)[source]
- Parameters:
name – The name of the parameter file
backup – create a backup-copy of the file
boundaryDict – the file to parse is a boundary file
listDict – the file only contains a list
listDictWithHeader – the file only contains a list and a header
listLengthUnparsed – Lists longer than that length are not parsed
binaryMode – Parse long lists in binary mode (to be overridden by
the settings in the header). :param treatBinaryAsASCII: even if the header says that this is a binary file treat it like an ASCII-file :param noHeader: don’t expect a header :param noBody: don’t read the body of the file (only the header) :param doMacroExpansion: expand #include and $var :param noVectorOrTensor: short lists of length 3, 6 an 9 are NOT interpreted as vectors or tensors :param dontRead: Do not read the file during construction :param longListOutputThreshold: Lists that are longer than this are prefixed with a length :param dictStack: dictionary stack for lookup (only used for include)
- __module__ = 'PyFoam.RunDictionary.ParsedParameterFile'
- exception PyFoam.RunDictionary.ParsedParameterFile.PyFoamParserError(descr, data=None)[source]
Bases:
FatalErrorPyFoamException- __annotations__ = {}
- __module__ = 'PyFoam.RunDictionary.ParsedParameterFile'
- class PyFoam.RunDictionary.ParsedParameterFile.WriteParameterFile(name, backup=False, className='dictionary', objectName=None, createZipped=False, **kwargs)[source]
Bases:
ParsedParameterFileA specialization that is used to only write to the file
- __annotations__ = {}
- __init__(name, backup=False, className='dictionary', objectName=None, createZipped=False, **kwargs)[source]
- Parameters:
name – The name of the parameter file
backup – create a backup-copy of the file
boundaryDict – the file to parse is a boundary file
listDict – the file only contains a list
listDictWithHeader – the file only contains a list and a header
listLengthUnparsed – Lists longer than that length are not parsed
binaryMode – Parse long lists in binary mode (to be overridden by
the settings in the header). :param treatBinaryAsASCII: even if the header says that this is a binary file treat it like an ASCII-file :param noHeader: don’t expect a header :param noBody: don’t read the body of the file (only the header) :param doMacroExpansion: expand #include and $var :param noVectorOrTensor: short lists of length 3, 6 an 9 are NOT interpreted as vectors or tensors :param dontRead: Do not read the file during construction :param longListOutputThreshold: Lists that are longer than this are prefixed with a length :param dictStack: dictionary stack for lookup (only used for include)
- __module__ = 'PyFoam.RunDictionary.ParsedParameterFile'