Skip to main content

A configuration/settings utility that that exposes project settings as standard Python dictionaries.

Project description

zettings

PyPI Python Versions PyPI - Downloads GitHub issues

Lines Of Code Codecov GitHub Actions Workflow Status

standard-readme compliant license

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. (overrides name)

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

MIT © Nick Stuer

Project details


Download files

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

Source Distribution

zettings-1.1.0.tar.gz (35.5 kB view details)

Uploaded Source

Built Distribution

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

zettings-1.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file zettings-1.1.0.tar.gz.

File metadata

  • Download URL: zettings-1.1.0.tar.gz
  • Upload date:
  • Size: 35.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for zettings-1.1.0.tar.gz
Algorithm Hash digest
SHA256 0203e6c47469a84c99c9e4f11e478cb58f26f22d067a46f55f9b10e55bae0633
MD5 0e370767419cd8567aabc2a6ef81ff51
BLAKE2b-256 da9c92aba2eeeee62d5ff216ef424d7f86b77517e637cee7e90445c9fe2149da

See more details on using hashes here.

File details

Details for the file zettings-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: zettings-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for zettings-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9cedba4aab14d6276e71f7c03d2d4d7647f89512e86cbf618f206f9315c0793
MD5 40446c7196cfad13c39faa07797050ed
BLAKE2b-256 0a26b65b9c8640bede75bdeb4ee9ef1d7ca9be2baa15c829b5928d0870a55d2e

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