1
2 """
3 Application class that implements pyFoamEchoDictionary
4 """
5
6 import sys,re
7
8 from PyFoamApplication import PyFoamApplication
9
10 from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile
11
12 from CommonParserOptions import CommonParserOptions
13
14 from PyFoam.Error import PyFoamException
15
19 description="""\
20 Reads a Foam-Dictionary and prints it to the screen. Mainly for
21 reformatting unformated dictionaries and debugging the parser
22 """
23
24 PyFoamApplication.__init__(self,
25 args=args,
26 description=description,
27 usage="%prog [options] <dictfile>",
28 nr=1,
29 changeVersion=False,
30 interspersed=True)
31
34
36 fName=self.parser.getArgs()[0]
37 try:
38 dictFile=ParsedParameterFile(fName,
39 backup=False,
40 debug=self.opts.debugParser,
41 noHeader=self.opts.noHeader,
42 noBody=self.opts.noBody,
43 preserveComments=self.opts.preserveComments,
44 boundaryDict=self.opts.boundaryDict,
45 listDict=self.opts.listDict,
46 listDictWithHeader=self.opts.listDictWithHeader,
47 doMacroExpansion=self.opts.doMacros)
48 except IOError,e:
49 self.error("Problem with file",fName,":",e)
50
51 print dictFile
52