Erbsland Configuration Parser for Python

Welcome to the implementation of the Erbsland Configuration Language Parser—a modern and robust configuration parser built for Python 3.12 and beyond. This implementation is designed to be secure, minimal in dependencies, and easy to integrate into your existing projects.

All you need is a Python 3.12 or newer – there are no external dependencies, no hassle.

Read how to use the parser →

Topics

Installation

Details about installing the parser.

Installation
How to Use the Parser

Learn how to use the parser in your application.

Usage
API Reference

Reference material on all classes and methods of the parser’s API.

API Reference
Configuration Language Documentation

The formal documentation of the Erbsland Configuration Language.

https://config-lang.erbsland.dev
Requirements

The requirements needed to use this parser.

Requirements
License

Familiarize yourself with the terms of use under the Apache 2.0 license.

License

Quick Usage Overview

Installation

pip install erbsland-conf

Minimal Example

import erbsland.conf as elcl
doc = elcl.load("config.elcl")
print(doc.get_int("server.port"))

A More Realistic Example

import erbsland.conf as elcl

def parse_configuration(file_name: str):
    doc = elcl.load(file_name)
    # Access required values and check the type.
    server_name = doc.get_text("main.server.name")
    # Provide a default if the value is optional.
    port = doc.get_int("main.server.port", default=8080)
    # Iterating over section lists naturally.
    for client_value in doc["client"]:
        name = client_value.get_text("name")
        ip = client_value.get_text("ip")
        port = client_value.get_int("port", default=9000)

        # Reading values from optional sections.
        if filter_value := client_value.get("filter", default=None):
            # Requiring lists of specific types.
            keywords = filter_value.get_list("keywords", str)
            # ...
        # ...
    # ...

def main():
    try:
        parse_configuration("quick-intro.elcl")
        # ... running the application ...
        exit(0)
    except elcl.Error as e:
        print("Error reading the configuration.")
        print(e.to_text(elcl.ErrorOutput.FILENAME_ONLY | elcl.ErrorOutput.USE_LINES))
        exit(1)

if __name__ == "__main__":
    main()

Contents at a Glance

Indices and Tables