Package: keiconf
keiconfA small, minimalist application json configuration tool for small projects.Uses only stdlib if that matters to you.Table of ContentsWhy tho?InstallationUsageParametersDevelopmentLimitationsFrequently Asked QuestionsLicenseWhy tho?Fair question.I originally started this project as an excuse to use Hatch and write a pyproject.toml no-distutils/setuptools python project and see how green the grass was.I've typically been unhappy with the configuration options for python in a way I can't articulate very well, and I just wanted a simple json file read with some guiderails. Some quick user-side discovery to find my platform's config path and get going.This project isn't meant to be a fully featured configuration system to slap into your next big webservice, it's just a small system to slap on your next prototype or small project.Installationpip install keiconfUsagefrom keiconf import KeiConf

k = KeiConf(filepath="path/to/file.json")
k.get("your_key")
k.get("path.to.your.nested_key")
k.start() # start watching config file for changesParamsKeiConf(filepath, indent=2, fail_on_missing_key=False, create_if_not_exist=False, watch_for_changes=False)filepath:strThe path to your target configuration fileex./path/to/file.jsonindent:intThe json indentation to use for the written fileex.2fail_on_missing_keys:boolIfTrue, will raise a KeyError if a key is missing, which you can catch and exit on.IfFalse, will return nothingcreate_if_not_exist:boolifTrue, will create the missing path directories and empty configuration file if it does not existifFalsewill fail naturally on opening nonexistent configuration filewatch_for_changes:boolifTruewill launch the config file watcher oninitifFalsewill not launch the config file watcher oninitSeeConfig File Watcherfor more informationConfig File WatcherIf your KeiConf instance is started withwatch_for_changes=Truethen a threaded file watcher will load changes to your configuration file as it sees them (within keiconf._CHANGE_WATCH_INTERVAL).If your KeiConf instance is started withwatch_for_changes=Falsethen the threaded file watcher is not created automatically.You can stop and start the file watcher manually via the start() and stop() functions. It can be start()'ed even if you launched with watch_for_changes=Falsek = KeiConf(...)
k.start() # starts the file watcher if it isn't already
k.stop() # stops a running file watcher if it is runningThe file watcher and loader is protected by athreading.Lock()DevelopmentDevelopment/Testing/Contribution requires hatch. Hatch provides the project management, environment abstraction, dependency resolution, and dev/test entrypoints.python3 -m pip install hatchalthough it is recommended to install hatch via pipxpython3 -m pip install pipx
python3 -m pipx ensurepath
python3 -m pipx install hatchLimitationsNeed to investigate behavior with listsFAQWhy not dot notation / attribute reference?A: I looked into this as I was interested in possibly doing it, but it looked rather lengthy to implement and involved modifying the base class quite a bit or using wrappers and I just wasn't sure that was in the spirit of minimalism. The get() function uses a string dot notationget("path.to.key")as a sort of middle ground. --- I may revisit in the future.Licensekeiconfis distributed under the terms of theMITlicense.