def load_config(config_file):
"""
Load configuration from file (output: dict)
"""
if os.path.isfile(config_file):
try:
with open(config_file, 'rU') as f:
config = json.load(f)
except ValueError:
print('Wrong JSON format in {} file'.format(config_file))
sys.exit(3)
except IOError as e:
print('Error while reading from file, {}'.format(e))
sys.exit(2)
else:
return config
else:
print('Configuration file {} not found'.format(config_file))
sys.exit(1)
评论列表
文章目录