1 """Configuration objects for the MUFF Engine"""
3 # Copyright (c) 2005 mudpy, Jeremy Stanley <fungi@yuggoth.org>, all rights reserved.
4 # Licensed per terms in the LICENSE file distributed with this software.
6 # muff configuration files use the ini format supported by ConfigParser
9 # need os for testing whether the config file exists and is readable
12 # hack to load all modules in teh muff package
14 for module in muff.__all__:
15 exec("import " + module)
17 # list of places to look for the config
18 config_dirs = [".", "./etc", "/usr/local/muff", "/usr/local/muff/etc", "/etc/muff", "/etc" ]
20 # name of the config file
21 config_name = "mudpy.conf"
23 # find the config file
24 for each_dir in config_dirs:
25 config_file = each_dir + "/" + config_name
26 if os.access(config_file, os.R_OK): break
29 config_data = ConfigParser.SafeConfigParser()
30 config_data.read(config_file)
32 def get(section, option):
33 """Convenience function to get configuration data."""
34 return config_data.get(section, option)
36 def getfloat(section, option):
37 "Convenience function to get floating-point configuration data."""
38 return config_data.getfloat(section, option)
40 def getint(section, option):
41 """Convenience function to get integer configuration data."""
42 return config_data.getint(section, option)
44 def set(section, option, value):
45 """Convenienve function to set miscellaneous configuration data."""
46 return config_data.get(section, option, repr(value))