def __init__(self):
self._options_stack = [ default_pyomo_config() ]
# Load the user's configuration
sources = [(json.load, 'json')]
if yaml_available:
sources.append( (yaml.load, 'yml') )
sources.append( (yaml.load, 'yaml') )
for parser, suffix in sources:
cfg_file = os.path.join( appdirs.user_data_dir('pyomo'),
'config.'+suffix)
if os.path.exists(cfg_file):
fp = open(cfg_file)
try:
data = parser(fp)
except:
logger.error("Error parsing the user's default "
"configuration file\n\t%s." % (cfg_file,))
self._options_stack[0].set_value(data)
评论列表
文章目录