Package PyFoam :: Module FoamInformation
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.FoamInformation

 1  """Getting Information about the Foam-Installation (like the installation directory)""" 
 2   
 3  from os import environ,path 
 4   
5 -def getPathFromEnviron(name):
6 """Gets a path from an environment variable 7 @return: the path 8 @rtype: string 9 @param name: the name of the environment variable""" 10 11 tmp="" 12 if environ.has_key(name): 13 tmp=path.normpath(environ[name]) 14 15 return tmp
16
17 -def foamTutorials():
18 """@return: directory in which the tutorials reside""" 19 20 return getPathFromEnviron("FOAM_TUTORIALS")
21
22 -def foamMPI():
23 """@return the used MPI-Implementation""" 24 if not environ.has_key("WM_MPLIB"): 25 return () 26 else: 27 vStr=environ["WM_MPLIB"] 28 return vStr
29
30 -def foamVersion():
31 """@return: tuple that represents the Foam-version as found 32 in $WM_PROJECT_VERSION""" 33 34 if not environ.has_key("WM_PROJECT_VERSION"): 35 return () 36 else: 37 vStr=environ["WM_PROJECT_VERSION"] 38 res=[] 39 40 for el in vStr.split("."): 41 for e in el.split("-"): 42 try: 43 res.append(int(e)) 44 except: 45 res.append(e) 46 47 return tuple(res)
48
49 -def foamVersionNumber():
50 """@return: tuple that represents the Foam-Version-Number (without 51 strings""" 52 53 ver=foamVersion() 54 55 nr=[] 56 i=0 57 58 for e in ver: 59 if type(e)==int: 60 nr.append(e) 61 else: 62 break 63 64 return tuple(nr)
65