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

Source Code for Module PyFoam.Applications.TestConfiguration

 1  #  ICE Revision: $Id$ 
 2  """ 
 3  Application class that implements pyFoamTestConfiguration.py 
 4  """ 
 5   
 6  from PyFoam.ThirdParty.six.moves import configparser as ConfigParser 
 7  from PyFoam.ThirdParty.six import print_ 
 8   
 9  from .PyFoamApplication import PyFoamApplication 
10   
11  from .CommonParserOptions import CommonParserOptions 
12   
13  from PyFoam.FoamInformation import foamVersionString 
14  from PyFoam import configuration as config 
15   
16 -class TestConfiguration(PyFoamApplication, 17 CommonParserOptions):
18 - def __init__(self, 19 args=None, 20 **kwargs):
21 description="""\ 22 Tests what value a section/option pair gives for a specific 23 OpenFOAM-version 24 25 Used to find configuration problems 26 """ 27 28 PyFoamApplication.__init__(self, 29 args=args, 30 description=description, 31 usage="%prog [options] <section> <option>", 32 nr=2, 33 interspersed=True, 34 **kwargs)
35
36 - def addOptions(self):
38
39 - def run(self):
40 section=self.parser.getArgs()[0] 41 option=self.parser.getArgs()[1] 42 43 print_("Foam-Version: ",foamVersionString()) 44 print_("Section: ",section) 45 print_("Option: ",option) 46 print_("Value: ",end="") 47 try: 48 print_(config().get(section,option)) 49 except ConfigParser.NoSectionError: 50 print_("<section not found>") 51 except ConfigParser.NoOptionError: 52 print_("<option not found>")
53 54 # Should work with Python3 and Python2 55