The Config

Tiramisu is made of almost three main classes/concepts :

  • the Option stands for the option types

  • the OptionDescription is the schema, the option’s structure

  • the Config which is the whole configuration entry point

_images/config.png

The handling of options

The handling of options is split into two parts: the description of which options are available, what their possible values and defaults are and how they are organized into a tree. A specific choice of options is bundled into a configuration object which has a reference to its option description (and therefore makes sure that the configuration values adhere to the option description).

Option description are nested Options

The Option (in this case the BoolOption), are organized into a tree into nested OptionDescription objects.

Every option has a name, as does every option group.

Config

Let’s perform a Getting started code review :

 1"getting started with the tiramisu library (it loads and prints properly)"
 2
 3from tiramisu import Config
 4from tiramisu import OptionDescription, BoolOption
 5
 6# let's create a group of options
 7descr = OptionDescription("optgroup", "", [
 8                          # ... with only one option inside
 9                          BoolOption("bool", "", default=False)
10                          ])
11
12cfg = Config(descr)

Let’s review the code. First, line 7, we create an OptionDescription named optgroup.

from tiramisu import OptionDescription, BoolOption
# let's create a group of options
descr = OptionDescription("optgroup", "", [

Option objects can be created in different ways, here we create a BoolOption

from tiramisu import OptionDescription, BoolOption
                          # ... with only one option inside
                          BoolOption("bool", "", default=False)

Then, line 12, we make a Config with the OptionDescription we built :

from tiramisu import Config
cfg = Config(descr)

Here is how to print our Config details:

cfg.help()
Root config object that enables us to handle the configuration options

Settings:
    forcepermissive      Access to option without verifying permissive properties
    unrestraint          Access to option without property restriction
    nowarnings           Do not warnings during validation

Commands:
    cache                Manage config cache
    config               Actions to Config
    information          Manage config informations
    option               Select an option
    owner                Global owner
    permissive           Manage config permissives
    property             Manage config properties
    value                Manage config value

Then let’s print our Option details.

cfg.option.help()
Select an option

Call: Select an option by path

Commands:
    dict         Convert config and option to tiramisu format
    find         Find an or a list of options
    list         List options (by default list only option)
    name         get the name
    updates      Updates value with tiramisu format

Finaly, let’s print the Config.

print(cfg)
<tiramisu.api.Config object at 0x7f3ee6204278>

download the getting started code

Go futher with Option and Config