Manage multiple configs over multiple scopes
Project description
Configiverse
Manage multiple configs across scopes
Configiverse is a library meant to make managing multiple config files easier. It allows the user to assign priorities to different config files, determining which configs setting to give priority to.
Installation
Pip repo should be configured for Nexus.
Install as any normal Python package:
pip install configiverse
Usage
Quick Start
You first create a Configiverse object to hold all the configs. Then you can add the config objects. You can also pass a list of Config objects directly to the Configiverse initialization if you want.
Note: You need to know the path to the config file at a minimum.
from configiverse import Configiverse
#Create the initial Configiverse instance
config = Configiverse()
#Add config objects
config.addConfig(TOMLConfig(
name="global",
path="/etc/configs/global.toml",
priority=0
))
config.addConfig(Config(
name="user",
path="/home/user/.config/user.toml",
priority=10
))
#Note that the "user" Config has a higher priority value than "global". The "user"s config values will overwrite "global"s wherever they match
Once you've added some Configs, you can parse them to generate a dictionary, similar to how most (all?) config parsers in Python work. The Configiverse.parse() method will save the generated dict to Configiverse.config as well as return the dict.
You can also access the items directly through the Configiverse object.
config.parse()
print(config.config) #Prints the whole config dict
print(config["config_item"]) #Gets a single config item
Advanced Usage
Priority & Parsing Order
Parsing order does matter somewhat, especially with many configs with the same priority.
When running Configiverse.parse(), it will sort the list in priority ascending order. If two priorities match, they will be compared in the order they were added.
It is advised to always use unique priorities for all configs that are added to prevent confusing priority collision situations like this.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file configiverse-2.2.1-py3-none-any.whl.
File metadata
- Download URL: configiverse-2.2.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aae20823f4492c9d3b2ba19bf06c98370ea93e3afa6a51f5d018347d0f532ef2
|
|
| MD5 |
0a53a0c2c04f46b306b0cefbc36e3940
|
|
| BLAKE2b-256 |
c5bd2c1b586d5fb237ec00e1b136a85b75fba19834ef6b919675889468418ec6
|