The gemstone.config module


class gemstone.config.Configurable(name, *, template=None)[source]

Defines a configurable value for the application.

Example (You should not use configurables in this way unless you are writing a custom Configurator)

c = Configurable("test", template=lambda x: x * 2)
c.get_final_value()  # "10" * 2 -> 1010

c2 = Configurable("list_of_ints", template=lambda x: [int(y) for y in x.split(",")])
c.get_final_value()  # [1,2,3,4,5]
  • name – The name of the configurable parameter
  • template – A callable template to apply over the extracted value


class gemstone.config.BaseConfigurator[source]

Base class for defining configurators. A configurator is a class that, starting from a set of name-configurable pairs, depending on the configurables’ options and the environment, builds a configuration for the application.


Gets the extracted value for the specified name, if available. If no value could be loaded for the specified name, None must be returned.


Returns the registered configurable with the specified name or None if no such configurator exists.


Loads the configuration for the application


Registers a configurable instance with this configurator

Parameters:configurable – a Configurable instance
class gemstone.config.CommandLineConfigurator[source]

Configurator that collects values from command line arguments. For each registered configurable, will attempt to get from command line the value designated by the argument --name where name is the name of the configurable.


For the configurables

  • Configurable(“a”)
  • Configurable(“b”)
  • Configurable(“c”)

the following command line interface will be exposed

usage: [-h] [--a A] [--b B] [--c C]

optional arguments:
  -h, --help  show this help message and exit
  --a A
  --b B
  --c C

The can be called like this

python --a=1 --b=2 --c=3