Package PyFoam :: Package Infrastructure :: Module Hardcoded
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Infrastructure.Hardcoded

 1  """Hardcoded values""" 
 2   
 3  from os import path,makedirs,environ 
 4   
 5  _pyFoamDirName="pyFoam" 
 6   
 7  _pyFoamConfigName="pyfoamrc" 
 8   
9 -def globalDirectory():
10 """@return: the global directory""" 11 return path.join("/etc",_pyFoamDirName)
12
13 -def globalConfigFile():
14 """@return: The name of the global configuration File""" 15 return path.join(globalDirectory(),_pyFoamConfigName)
16
17 -def userDirectory():
18 """@return: the user directory""" 19 return path.expanduser(path.join("~","."+_pyFoamDirName))
20
21 -def userConfigFile():
22 """@return: The name of the user configuration File""" 23 return path.join(userDirectory(),_pyFoamConfigName)
24
25 -def userName():
26 """@return: name of the current user""" 27 user="" 28 if environ.has_key("USER"): 29 user=environ["USER"] 30 return user
31
32 -def logDirectory():
33 """Path to the log directory that this user may write to. 34 /var/log/pyFoam for root, ~/.pyFoam/log for all others 35 @return: path to the log directory.""" 36 if userName()=="root": 37 return path.join("/var/log","pyFoam") 38 else: 39 return path.join(userDirectory(),"log")
40
41 -def assertDirectory(name):
42 """Makes sure that the directory exists 43 @param name: the directory""" 44 if path.exists(name): 45 return 46 else: 47 makedirs(name,mode=0755)
48