Skip to content

pjz/mincfg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ea8b4b7 · Oct 11, 2023

History

46 Commits
Nov 29, 2022
Jul 12, 2023
Oct 11, 2023
Oct 11, 2023
Jan 10, 2021
Jan 9, 2021
Oct 11, 2023
Jul 12, 2023
Jul 12, 2023
Jan 9, 2021
Oct 11, 2023

Repository files navigation

MinCfg

Tests/Pylint/Mypy

the Minimum Configuration Handling System

There are many configuration management/definition systems. This one is mine. This is an overview. There are also more formal docs.

A set of simple tools to build a configuration system with

The first set are 'sources':

  • DictSource, which takes values from a python dict and is useful for defaults
  • SubsetSource, which returns a subset of another source, to help with merge precedence
  • OSEnvironSource, which parses config values from os.environ into hierarchical dictionaries
  • YamlFileSource, which parses a yaml file into hierarchical dictionaires (pip install mincfg[yaml] for support)
  • INIFileSource, which understands INI files (based on configobj) (pip install mincfg[ini] for support)
  • DotEnvSouce, which understands .env files (based on python-dotenv) (pip install mincfg[env] for support)

The second tool is:

  • MergedConfiguration: which merges multiple configuration sources into a coherent whole

Yes, much more could be done:

  • required keys
  • value validation
  • default parsers
  • default default values (that .get() without a default would default to)
  • more file types (json, ... xml?)
  • sphinx/rtd docs

... PRs accepted!

Much inspiration - and the .get() signature - is taken from everett, but the implementation is all mine.

To install

pip install mincfg