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

Source Code for Module PyFoam.Applications.PyFoamApplication

 1  #  ICE Revision: $Id: PyFoamApplication.py 7581 2007-06-27 15:29:14Z bgschaid $  
 2  """Base class for pyFoam-applications""" 
 3   
 4  from PyFoam.Basics.FoamOptionParser import FoamOptionParser 
 5  from PyFoam.Error import error 
 6   
 7  import sys 
 8   
9 -class PyFoamApplication(object):
10 - def __init__(self,description=None,usage=None,interspersed=False,nr=None):
11 """ 12 @param description: description of the command 13 @param usage: Usage 14 @param interspersed: Is the command line allowed to be interspersed (options after the arguments) 15 """ 16 self.parser=FoamOptionParser(description=description,usage=usage,interspersed=interspersed) 17 self.addOptions() 18 self.parser.parse(nr=nr) 19 self.opts=self.parser.getOptions() 20 21 self.run()
22
23 - def addOptions(self):
24 """ 25 Add options to the parser 26 """ 27 pass
28
29 - def run(self):
30 """ 31 Run the real application 32 """ 33 error("Not a valid application")
34 35
36 - def error(self,*args):
37 """ 38 Prints an error message and exits 39 @param args: Arguments that are to be printed 40 """ 41 print "Error in",sys.argv[0],":", 42 for a in args: 43 print a, 44 print 45 sys.exit(-1)
46