Skip to main content

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

configiverse-2.4.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file configiverse-2.4.2-py3-none-any.whl.

File metadata

  • Download URL: configiverse-2.4.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for configiverse-2.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 18e0c95bd299d8c683109d940303c7cbc6cb681ad165406d0a1fd5fa9a7d5058
MD5 ad14723cd7b359492b3ede2075f482da
BLAKE2b-256 9efbc2a1c31134ef358355ebe918e0542b87eb64b5b18ed32f15bfcfc8e13096

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page