ilexconf logo

Build status of package Build status of GitHub pages docs Build status of Read the Docs Code coverage report PyPI

Ilexconf Documentation

ilexconf is a Python library to load and merge configs from multiple sources, access & change the values, and write them back. It has no dependencies by default but provides additional functions, relying on popular libraries to parse yaml, toml, provide command line app, etc.

Features

  • Create empty config

    from ilexconf import Config
    config = Config()
    
  • Assign to non-existent keys

    config.a.b.c = True
    
  • Access values however you want

    config.a.b.c == True
    config["a"]["b"]["c"] == True
    config["a.b.c"] == True
    config["a.b"].c == True
    config.a["b.c"] == True
    config.a["b"].c == True
    
  • Correctly merge lists

    config.a.b.c = [
        "my_string",
        {"d": "nested_value"}
    ]
    config.a.b.c[0] == "my_string"
    config.a.b.c[1] == Config({"d": "nested_value"})
    dict(config.a.b.c[1]) == {"d": "nested_value"}
    
  • Support json, ini, yaml, toml, python modules

    config = from_json("settings.json")
    config = from_python("settings.py")
    
  • Correctly merge configs

  • Support environment variables

  • Support command line arguments as configuration

  • Rich Command Line

    # Show config variables
    ilexconf list config.json
    
    # Set variable
    ilexconf set my_config.json my.key my_value
    

Note

Every single example on this page is unit tested.

Table of Contents

API reference