Welcome to Trafaret Config’s documentation!

Trafaret-config is a wrapper that loads yaml and checks config using trafaret while keeping track of actual lines of file where error has happened.

Additionally, it can pretty print the error.

Basic Usage

For easier real-life usage see Command-Line section.

import sys
import trafaret
from trafaret_config import read_and_validate

TRAFARET = trafaret.Dict({'x': trafaret.String()})

try:
    config = read_and_validate('config.yaml', TRAFARET)
except ConfigError as e:
    e.output()
    sys.exit(1)

Example output (from a test.py which has better trafaret than example above):

bad.yaml:2: smtp.port: value can't be converted to int
bad.yaml:3: smtp.ssl_port: value can't be converted to int
bad.yaml:4: port: value can't be converted to int

Indices and tables