4. experipy.config - Configuration utilities

This modules provides the Namespace class, which provides a mechanism for defining collections of configurable constants.

4.1. Namespace objects

class experipy.config.Namespace(name=None, **kwargs)

Namespace objects are intended to act as collections of constants.

All arguments passed to the Namespace when it is instantiated are bound to attributes of the instance, allowing attribute reference as opposed to dictionary access syntax. For example: n = Namespace("N", foo="bar") would generate a namespace with an attribute n.foo whose value is "bar".

Namespaces also support configuration using configparser INI files. By default, configuration is stored and read from ~/.experipyrc, unless the environment variable EXPERIPY_CONFIG_PATH is set, in which case that value is used as the filename.

Parameters:
  • name (str) – The name to assign to the namespace. If not provided, the resulting Namespace instance will be anonymous and not configurable via the configuration file.
  • **kwargs – The remaining keyword arguments will be added the Namespace’s dictionary, allowing for attribute access. If a name was provided, and the namespace had a section in the configuration file, conflicting arguments will have their values ignored in favor of the value in the configuration file.
classmethod dump_full_config(fname='/home/docs/.experipyrc')

Write a config of all instantiated and preconfigured Namespaces.

All instantiated and named Namespaces will be dumped to the given file, along with any Namespace configurations which have been loaded from the config, but whose corresponding Namespace has not yet been instantiated.

Parameters:fname (str) – Name of the file to write the config to. If not provided, it will default to the current config file (“~/.experipyrc” or the value of the EXPERIPY_CONFIG_PATH environment variable).