probator.config

class probator.config.DBCChoice

Bases: dict

Utility class for Choice for DBConfig

class probator.config.DBCString

Bases: str

Utility class for String values for DBConfig

class probator.config.DBCInt

Bases: int

Utility class for Integer values for DBConfig

class probator.config.DBCFloat

Bases: float

Utility class for Float values for DBConfig

class probator.config.DBCJSON

Bases: dict

Utility class for JSON values for DBConfig

class probator.config.DBCArray

Bases: list

Utility class for Array values for DBConfig

class probator.config.DBConfig

Bases: object

Database backed configuration object.

Styled to work similarly to Flask’s builtin config object, with the added feature that it understands namespaced configuration items to allow for duplicate names within different scopes.

reload_data()

Reloads the configuration from the database

Returns:None
namespace_exists(namespace)

Checks if a namespace exists

Parameters:namespace (str) – Namespace to check for
Returns:True if namespace exists, else False
key_exists(namespace, key)

Checks a namespace for the existance of a specific key

Parameters:
  • namespace (str) – Namespace to check in
  • key (str) – Name of the key to check for
Returns:

True if key exists in the namespace, else False

get(key, namespace='default', default=None, as_object=False)

Return the value of a key/namespace pair

Parameters:
  • key (str) – Key to return
  • namespace (str) – Namespace of the key
  • default (Any) – Optional default value to return, if key was not found
  • as_object (bool) – If True returns the object as a ConfigItem object instead of its primitive type
Returns:

Requested value if found, else default value or None

set(namespace, key, value, description=None)

Set (create/update) a configuration item

Parameters:
  • namespace (str) – Namespace for the item
  • key (str) – Key of the item
  • value (Any) – Value of the type, must by one of DBCString, DBCFloat, DBCInt, DBCArray, DBCJSON or
  • bool
  • description (str) – Description of the configuration item
Returns:

None

delete(namespace, key)

Remove a configuration item from the database

Parameters:
  • namespace (str) – Namespace of the config item
  • key (str) – Key to delete
Returns:

None