def load(filename=DEFAULT_CONFIG_FILE, stage=None):
''' Load the configuration and return it. '''
try:
# pass
file_contents = fs.read(filename)
resolve_dotenv_file(os.path.dirname(filename), stage)
# Expand the environment variables used in the yaml config.
loaded_config = os.path.expandvars(file_contents)
# Parse the yaml configuration.
# And merge it with the defaults before it's used everywhere.
loaded_config = yaml.load(loaded_config)
merged_config = merge_config(loaded_config)
_config.update(merged_config)
return get()
except KeyError:
halt('Invalid configuration file "{}"'.format(filename))
except IOError:
halt('Error loading config file "%s"' % filename)
评论列表
文章目录