A configuration/settings utility that that exposes project settings as standard Python dictionaries.
Project description
zettings
A configuration/settings utility that that exposes project settings as standard Python dictionaries.
zettings is a Python configuration library designed for simplicity. It loads settings data from TOML files and exposes them as standard Python dictionaries. This allows you to work with settings in a familiar, Pythonic way.
Table of Contents
Features
- TOML: Uses TOML under the hood for modern settings files.
- Dictionary: Access and change settings with regular dictionary operations.
- Nested Keys: Supports nested dictionary keys with dotted key notation.
- Optional
defaults: Provide default values for initializing the settings file or for when a key is missing in the settings file. - Optional
always_reload: Reload the setting file everytime a key is read. (Enabled by default) - Optional
filepath: Provide the exact file Path of the .toml file to use. (overridesname)
Install
# PyPI
pip install zettings
or
uv add zettings
Dependencies
Python 3.9 or greater
Usage
Example
This will create/use a 'settings.toml' file located in the '.zettings' directory of the user's home directory.
from zettings import Settings
# Standard Dictionary Format
defaults = {
"settings": {
"name": "MyName",
"mood": "happy",
},
}
# Dotted Key Notation
defaults = {}
defaults["settings.name"] = "MyName"
defaults["settings.mood"] = "happy"
settings = Settings(".zettings/settings.toml", defaults) # Change 'zettings' to your project's name
print(settings["settings.mood"])
settings["settings.mood"] = "angry"
print(settings["settings.mood"])
Contributing
PRs accepted.
If editing the Readme, please conform to the standard-readme specification.
Bug Reports and Feature Requests
Please use the issue tracker to report any bugs or request new features.
Contributors
License
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 Distribution
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 zettings-1.0.1.tar.gz.
File metadata
- Download URL: zettings-1.0.1.tar.gz
- Upload date:
- Size: 34.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abea88b5e2813d7bfa3310f24e60c14e232bf614f313784d5e21c4e47b02f2af
|
|
| MD5 |
d2be6e6fde84f2106d6e5a5daba2ac19
|
|
| BLAKE2b-256 |
b70f32157970c5131c86af301b44d5915d0076101fe08352735d5a20ecac8ab2
|
File details
Details for the file zettings-1.0.1-py3-none-any.whl.
File metadata
- Download URL: zettings-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
176c49296894f310a83503f33c09fdea2cad0d16f279e11e9b3570e37b051a36
|
|
| MD5 |
a4d2f8c2c196a083b19bc874db93062b
|
|
| BLAKE2b-256 |
1f1747d36b5865deca65b65f90f6f7991c0c006e0d53e64814be65c80a4295bc
|