def load_toml_xo_config(filename):
"""Returns a XOConfig created by loading a TOML file from the
filesystem.
Args:
filename (string): The name of the file to load the config from
Returns:
config (XOConfig): The XOConfig created from the stored
toml file.
Raises:
LocalConfigurationError
"""
if not os.path.exists(filename):
LOGGER.info(
"Skipping transaction proccesor config loading from non-existent"
" config file: %s", filename)
return XOConfig()
LOGGER.info("Loading transaction processor information from config: %s",
filename)
try:
with open(filename) as fd:
raw_config = fd.read()
except IOError as e:
raise LocalConfigurationError(
"Unable to load transaction processor configuration file:"
" {}".format(str(e)))
toml_config = toml.loads(raw_config)
invalid_keys = set(toml_config.keys()).difference(
['connect'])
if invalid_keys:
raise LocalConfigurationError(
"Invalid keys in transaction processor config: "
"{}".format(", ".join(sorted(list(invalid_keys)))))
config = XOConfig(
connect=toml_config.get("connect", None)
)
return config
评论列表
文章目录