Config helpers

Extra mods required: pyyaml, jsonschema

pyaltt2.config.choose_file(fname=None, env=None, choices=[])

Chooise existing file

Returned file path is user-expanded

Parameters:
  • fname – if specified, has top priority and others are not chechked
  • env – if specified and set, has second-top priority and choices are not inspected
  • choices – if env is not set or not specified, choose existing file from the list
Raises:

LookupError – if file doesn’t exists

pyaltt2.config.config_value(env=None, config=None, config_path=None, to_str=False, read_file='r', in_place=False, default=<class 'LookupError'>)

Get config value

Parameters:
  • env – search in system env, if specified, has top priority
  • config – config dict to process
  • config_path – config path (e.g. /some/long/key)
  • to_str – stringify value before returning
  • read_file – if value starts with ‘/’, read it from file with mode (default: ‘r’)
  • in_place – replace value in config dict
  • default – default value
Raises:

LookupError – if value is not found and no default value specified

pyaltt2.config.load_yaml(fname, schema=None)

Load config from YAML/JSON file

Parameters:
  • fname – file name to load
  • schema – JSON schema for validation