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

Source Code for Module PyFoam.Applications.EchoDictionary

 1  #  ICE Revision: $Id: EchoDictionary.py 9240 2008-08-18 10:44:50Z bgschaid $  
 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 -class EchoDictionary(PyFoamApplication):
13 - def __init__(self,args=None):
14 description=""" 15 Reads a Foam-Dictionary and prints it to the screen. Mainly for reformatting 16 unformated dictionaries and debugging the parser 17 """ 18 19 PyFoamApplication.__init__(self, 20 args=args, 21 description=description, 22 usage="%prog [options] <dictfile>", 23 nr=1, 24 changeVersion=False, 25 interspersed=True)
26
27 - def addOptions(self):
28 self.parser.add_option("--debug", 29 action="store_true", 30 default=None, 31 dest="debug" 32 ,help="Debugs the parser") 33 34 self.parser.add_option("--no-header", 35 action="store_true", 36 default=False, 37 dest="noHeader", 38 help="Don't expect a header while parsing") 39 40 self.parser.add_option("--no-body", 41 action="store_true", 42 default=False, 43 dest="noBody", 44 help="Don't expect a body while parsing (only parse the header)") 45 46 self.parser.add_option("--boundary", 47 action="store_true", 48 default=False, 49 dest="boundaryDict", 50 help="Expect that this file is a boundary dictionary") 51 52 self.parser.add_option("--list", 53 action="store_true", 54 default=False, 55 dest="listDict", 56 help="Expect that this file only contains a list")
57 58
59 - def run(self):
60 fName=self.parser.getArgs()[0] 61 try: 62 dictFile=ParsedParameterFile(fName, 63 backup=False, 64 debug=self.opts.debug, 65 noHeader=self.opts.noHeader, 66 noBody=self.opts.noBody, 67 boundaryDict=self.opts.boundaryDict, 68 listDict=self.opts.listDict) 69 except IOError,e: 70 self.error("Problem with file",fName,":",e) 71 72 print dictFile
73