Package PyFoam :: Package Applications :: Module EchoDictionary
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Applications.EchoDictionary

 1  #  ICE Revision: $Id$ 
 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   
16  from PyFoam.ThirdParty.six import print_ 
17   
18 -class EchoDictionary(PyFoamApplication, 19 CommonParserOptions):
20 - def __init__(self,args=None):
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
34 - def addOptions(self):
36
37 - def run(self):
38 fName=self.parser.getArgs()[0] 39 try: 40 dictFile=ParsedParameterFile(fName, 41 backup=False, 42 debug=self.opts.debugParser, 43 noHeader=self.opts.noHeader, 44 noBody=self.opts.noBody, 45 preserveComments=self.opts.preserveComments, 46 boundaryDict=self.opts.boundaryDict, 47 listDict=self.opts.listDict, 48 listDictWithHeader=self.opts.listDictWithHeader, 49 treatBinaryAsASCII=self.opts.treatBinaryAsASCII, 50 doMacroExpansion=self.opts.doMacros) 51 except IOError: 52 e = sys.exc_info()[1] # Needed because python 2.5 does not support 'as e' 53 self.error("Problem with file",fName,":",e) 54 55 print_(dictFile)
56 57 # Should work with Python3 and Python2 58