qmi.core.config

Read and process configuration files.

The QMI configuration file language closely resembles JSON. The configuration language differs from JSON as follows:

  • The top-level value in the file must be a dictionary (the JSON specification calls this an object).

  • Comments are allowed (and ignored during reading).

  • Comments start with # and continue until the end of the line.

  • Comments can not be placed inside strings.

Functions

config_pairs_hook(config_pairs)

Reject duplicate keys.

dump_config_file(cfg, filename)

Write configuration data to a file.

dump_config_string(cfg)

Serialize configuration data to a string.

load_config_file(filename)

Load configuration data from a file.

load_config_string(s)

Load configuration data from a string.

qmi.core.config.config_pairs_hook(config_pairs) OrderedDict

Reject duplicate keys.

qmi.core.config.load_config_string(s: str) dict

Load configuration data from a string.

Parameters:

s – String containing configuration data.

Returns:

Parsed configuration data checked for duplicates.

qmi.core.config.load_config_file(filename: str) dict

Load configuration data from a file.

Parameters:

filename – Path of configuration file.

Returns:

Parsed configuration data.

qmi.core.config.dump_config_string(cfg: dict) str

Serialize configuration data to a string.

Parameters:

cfg – Configuration data.

Returns:

Serialized configuration string.

qmi.core.config.dump_config_file(cfg: dict, filename: str) None

Write configuration data to a file.

Parameters:
  • cfg – Configuration data.

  • filename – Path of configuration file to write.