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.3.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: configiverse-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae1f3a42ebdd7605d844edf11a1a244532c8e6fd1c7bb5c6a50d37c4e7d75e38
MD5 88e8fc3d87675db3123072aaed9e3a27
BLAKE2b-256 6137df8b96cf5a59f654981a5f126a649ddbd541e3a0d0bbe6c5058931639859

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