Conf

class Conf

A utility class that allows you to retrieve and parse a conf file as JSON, or validate a given conf file.

__init__()

Methods

static _get_conf(filename)

Tries to load and JSON parse a given filename.

Parameters:

filename (str) – The conf filename to parse.

Returns:

The parsed conf file, or None if the file can’t be found.

Return type:

dict or None

static _validate_conf(filename, keys)

Validates that a given configuration file exists, and contains the given keys with some associated value. Terminates the script if any of these checks fail.

Parameters:
  • filename (str) – The conf filename to validate.

  • keys (dict) – The list of keys to check for existence/associated value.

Returns:

The parsed conf file.

Return type:

dict