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