Skip to main content

A checker for required fields in yaml files

Project description

Funny fact: confiture looks like configure.

Confiture, what’s that?

[STRIKEOUT:Jam typically contains both the juice and flesh of a fruit or vegetable, although some cookbooks define it as a cooked and jelled puree. The term “jam” refers to a product made of whole fruit cut into pieces or crushed, then heated with water and sugar to activate its pectin before being put into containers.]

Confiture is a small piece of code to test a yaml configuration file. By test we mean check that some required fields are indeed set.


spread confiture

Oh really? - No.

pip install confiture

Oh really? - Nope, pip name confiture was already used.

pip install spread-confiture

Oh really? - Hell yeah.


This project requires pyyaml to parse yaml files.


Template file

A template file is a file that describes the fields that we want to check when parsing a configuration file. It is also written in yaml, with the following scheme:

    bar: ""
        foo: ""
        bar: ""

bar: ""

A configuration file is consistant relatively to the template file if every required field specified by the template are set. Note that the configuration can also set other fields that are not specified by the template.

Create a Confiture object

To create a Confiture object relatively to a given template file:

from confiture import Confiture
# conf pour confiture ou configration ?
conf = Confiture("examples/templates/confiture.yaml")

Parse a configuration file

Once the Confiture object is created, we can test yaml configuration files:

# Simple test
# Test et récupération du contenu du fichier sous forme de dictionnaire
config = conf.check_and_get("examples/config/blueberry_ok.yaml")

If the configuration file is not consistant with the template, a ConfigFileError exception is raised.



from confiture import Confiture, ConfigFileError

print "[*] loading template"
confiture = Confiture("examples/templates/confiture.yaml")
print "[*] checking required files for blueberry"
    print "[*] blueberry file is correct"
except ConfigFileError as e:
    print e.message
print "[*] checking required files for banana"
    print "[*] banana file is correct"
except ConfigFileError as e:
    print e.message


(confiture) > python ./
[*] loading template
[*] checking required files for blueberry
[*] blueberry file is correct
[*] checking required files for banana
*** fruit field not found -- aborting


How did you get the idea to do (some) Confiture?

It was a forbidden morning of September, breakfast time. At the exact moment when I started speading Nutella on my toast…

Why a documentation?

Because a project without documentation is like a Confiture without bananas.

Why a documentation THAT long?

Because documentation is like banana in Confiture, the more there is the better it tastes.

Why a documentation THAT long for a project this simple?

Because now I can say that once in my life I wrote a documentation longer than the code itself.

Project details

Download files

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

Files for spread-confiture, version 0.17.3rc1
Filename, size File type Python version Upload date Hashes
Filename, size spread-confiture-0.17.3rc1.tar.gz (3.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page