Skip to main content

A consistency handling system that was initially designed in the configuration management

Project description

Logo Rougail

Rougail

Description

Rougail is a free full-featured configuration manager library written in python3.

The configuration is describe in YAML dictionary files.

Those dictionaries are converted into Tiramisu objects.

Rougail can be incorporated with other technologies and stacks regardless of whether they’re written in Python or not.

Simple example

Create a directory:

# mkdir dict

Dictionary

A dictionary is a variables description file.

Create the file dict/dictionary.yml:

---
version: '1.0'
# describe a variable my_first_variable
# and a family with a variable my_second_variable
my_first_variable:
  default: my_value
my_family:
  my_second_variable:
    type: number
    mandatory: true
    value: 1

Generate variable

With default value:

Here is a python3 example file:

from rougail import Rougail, RougailConfig
from pprint import pprint

RougailConfig['dictionaries_dir'] = ['dict']
RougailConfig['templates_dir'] = ['tmpl']
RougailConfig['tmp_dir'] = 'tmp'
RougailConfig['destinations_dir'] = 'dest'
rougail = Rougail()
config = rougail.get_config()
pprint(config.value.get(), sort_dicts=False)

The result is:

{'rougail.my_first_variable': 'my_value',
 'rougail.my_family.my_second_variable': 1}

With modified value

Use Tiramisu API to change values:

from rougail import Rougail, RougailConfig
from pprint import pprint

RougailConfig['dictionaries_dir'] = ['dict']
RougailConfig['templates_dir'] = ['tmpl']
RougailConfig['tmp_dir'] = 'tmp'
RougailConfig['destinations_dir'] = 'dest'
rougail = Rougail()
config = rougail.get_config()
config.option('rougail.my_first_variable').value.set('modified_value')
config.option('rougail.my_family.my_second_variable').value.set(2)
pprint(config.value.get(), sort_dicts=False)

The destination file is generated with new values:

{'rougail.my_first_variable': 'modified_value',
 'rougail.my_family.my_second_variable': 2}

Link

Related projects

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rougail-1.0.2.tar.gz (819.6 kB view hashes)

Uploaded Source

Built Distribution

rougail-1.0.2-py3-none-any.whl (62.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page