PyFoam.RunDictionary.ParsedParameterFile module

Parameter file is read into memory and modified there

exception PyFoam.RunDictionary.ParsedParameterFile.BinaryParserError(descr, data=None)[source]

Bases: PyFoam.RunDictionary.ParsedParameterFile.PyFoamParserError

class PyFoam.RunDictionary.ParsedParameterFile.Enumerate(names)[source]

Bases: object

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: PyFoam.Basics.PlyParser.PlyParser

Class that parses a string that contains the contents of an OpenFOAM-file and builds a nested structure of directories and lists from it

addCommentToDecorations(text)[source]
addNewlinesToDecorations(text)[source]
addToDecoration(text)[source]
condenseAllPreFixLists(orig)[source]

Checks whether this list is a list that consists only of prefix-Lists

directory()[source]
getData()[source]

Get the data structure

getDecoration()[source]
getHeader()[source]

Get the OpenFOAM-header

literals = '(){};[]^'
p_afterHeader(p)[source]

afterHeader :

p_binaryblob(p)[source]

binaryblob : BINARYBLOB

p_boundaryDict(p)[source]

boundaryDict : header list | header prelist

p_codeSeen(p)[source]

codeSeen :

p_codestream(p)[source]

codestream : codeSeen CODESTART CODESTREAMCHUNK CODEEND

p_dictbody(p)[source]

dictbody : dictbody dictline | dictline | empty

p_dictionary(p)[source]

dictionary : ‘{‘ enter_dict dictbody ‘}’ exit_dict | ‘{‘ ‘}’

p_dictitem(p)[source]

dictitem : longitem | pitem

p_dictkey(p)[source]

dictkey : word | SCONST

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

empty :

p_enter_dict(p)[source]

enter_dict :

p_error(p)[source]
p_exit_dict(p)[source]

exit_dict :

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

float : FCONST

p_global(p)[source]

global : header dictbody

p_gotHeader(p)[source]

gotHeader :

p_header(p)[source]

header : FOAMFILE dictionary

p_ignore_rest_of_line(p)[source]

ignore_rest_of_line :

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

integer : ICONST

p_item(p)[source]

item : pitem | REACTION | prelist | list | uniformfield | dictionary

p_itemlist(p)[source]

itemlist : itemlist item | itemlist ‘;’ | item

p_list(p)[source]

list : ‘(‘ itemlist ‘)’

p_longitem(p)[source]

longitem : pitemlist pitem

p_macro(p)[source]

macro : KANALGITTER include RESTOFLINE | KANALGITTER inputMode RESTOFLINE | KANALGITTER remove RESTOFLINE

p_noBody(p)[source]

noBody : FOAMFILE ‘{‘ dictbody gotHeader ‘}’

p_noHeader(p)[source]

noHeader : dictbody

p_number(p)[source]

number : integer | FCONST

p_onlyListOrPList(p)[source]

onlyListOrPList : list | prelist | uniformfield

p_pitem(p)[source]

pitem : word | SCONST | number | dictionary | list | dimension | substitution | empty

p_pitemlist(p)[source]

pitemlist : pitemlist pitem | pitem

p_prelist(p)[source]

prelist : integer prelist_seen ‘(‘ itemlist ‘)’ | integer prelist_seen ‘(‘ binaryblob ‘)’ | integer prelist_seen ‘(‘ unparsed ‘)’ | integer prelist_seen ‘{‘ item ‘}’

p_prelist_seen(p)[source]

prelist_seen :

p_pureList(p)[source]

pureList : onlyListOrPList

p_pureListWithHeader(p)[source]

pureListWithHeader : header onlyListOrPList

p_remove(p)[source]

remove : REMOVE ignore_rest_of_line word | REMOVE wlist

p_substitution(p)[source]

substitution : SUBSTITUTION

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

symmtensor : ‘(‘ number number number number number 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_unparsed(p)[source]

unparsed : UNPARSEDCHUNK

p_vector(p)[source]

vector : ‘(‘ number number number ‘)’

p_wlist(p)[source]

wlist : ‘(‘ wordlist ignore_rest_of_line ‘)’

p_word(p)[source]

word : NAME | UNIFORM | NONUNIFORM | MERGE | OVERWRITE | DEFAULT | WARN | PROTECT | ERROR

p_wordlist(p)[source]

wordlist : wordlist word | word

parseSubst_root(nm, stck)[source]
parserError(text, c, ind)[source]

Prints the error message of the parser and exit

printContext(c, ind)[source]

Prints the context of the current index

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'}
resetDecoration()[source]
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_NAME(t)[source]

[a-zA-Z_][+-<>(),.*|a-zA-Z_0-9&%:]*

t_SCONST = '\\"([^\\\\\\n]|(\\\\.))*?\\"'
t_SUBSTITUITION(t)[source]

$[a-zA-Z_.:{][+-<>(),.*|a-zA-Z_0-9&%:${}]*

t_binaryblob_close(t)[source]

)

t_binaryblob_error(t)[source]
t_binaryblob_ignore = ''
t_binaryblob_throwaway(t)[source]

[^)]

t_ccode_comment(t)[source]

//.*

t_codestream_end(t)[source]

#}

t_codestream_error(t)[source]
t_codestream_ignore = ''
t_codestream_throwaway(t)[source]

[^#]

t_error(t)[source]
t_ignore = ' \t\r'
t_ignorerestofline_SCONST(t)[source]

“([^\n]|(.))*?”

t_ignorerestofline_error(t)[source]
t_ignorerestofline_ignore = ''
t_ignorerestofline_newline(t)[source]

[n]

t_ignorerestofline_restofline(t)[source]

[^n]+

t_mlcomment_endcomment(t)[source]

*/

t_mlcomment_error(t)[source]
t_mlcomment_ignore = ''
t_mlcomment_newlevel(t)[source]

/*

t_mlcomment_throwaway(t)[source]

[^*]

t_newline(t)[source]

n+

t_startmlcomment(t)[source]

/*

t_unparsed_error(t)[source]
t_unparsed_ignore = ' \t\n0123456789.-+e'
t_unparsed_left(t)[source]

(

t_unparsed_right(t)[source]

)

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: PyFoam.RunDictionary.ParsedParameterFile.FoamFileParser

Convenience class that parses only a headerless OpenFOAM dictionary

class PyFoam.RunDictionary.ParsedParameterFile.NotAPrelist(a, b)[source]

Bases: object

Class to return if the length of the prelist does not fit the prefix

class PyFoam.RunDictionary.ParsedParameterFile.ParsedBoundaryDict(name, treatBinaryAsASCII=False, backup=False, debug=False)[source]

Bases: PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile

Convenience class that parses only a OpenFOAM polyMesh-boundaries file

parse(content)[source]

Constructs a representation of the file

class PyFoam.RunDictionary.ParsedParameterFile.ParsedFileHeader(name)[source]

Bases: PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile

Only parse the header of a file

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: PyFoam.RunDictionary.FileBasis.FileBasisBackup

Parameterfile whose complete representation is read into memory, can be manipulated and afterwards written to disk

getValueDict()[source]

Get a dictionary with the values with the decorators removed

parse(content)[source]

Constructs a representation of the file

exception PyFoam.RunDictionary.ParsedParameterFile.PyFoamParserError(descr, data=None)[source]

Bases: PyFoam.Error.FatalErrorPyFoamException

class PyFoam.RunDictionary.ParsedParameterFile.WriteParameterFile(name, backup=False, className='dictionary', objectName=None, createZipped=False, **kwargs)[source]

Bases: PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile

A specialization that is used to only write to the file