Get and set two-key plaintext configuration values stored to JSON file path.
Project description
dworshak-config
dworshak-config is a lightweight, zero-dependency library for managing nested JSON configurations. It serves as the standard storage backend for the Dworshak ecosystem, providing a stable way to persist non-sensitive application settings.
By decoupling storage from user interaction, dworshak-config ensures that your scripts can retrieve settings silently when they exist, leaving the "how to ask for them" to its sister package, dworshak-prompt.
Features
- Zero Dependencies: Pure Python standard library (
jsonandpathlib). - Service-Oriented: Organizes settings by
serviceanditem(e.g.,config["postgres"]["port"]). - Atomic Persistence: Automatically handles directory creation and pretty-printed JSON writes.
- Fail-Safe Loading: Gracefully handles corrupted or missing configuration files.
Installation
uv add dworshak-config
# or
pip install dworshak-config
Usage
Basic I/O
The DworshakConfig is the primary interface for reading and writing data.
from dworshak_config import DworshakConfig
# Uses default path: ~/.dworshak/config.json
cfg = DworshakConfig()
# Store a value
cfg.set_value("aws", "region", "us-east-1")
# Retrieve a value (returns None if missing)
region = cfg.get_value("aws", "region")
print(f"Targeting: {region}")
Custom Configuration Paths
Perfect for project-specific settings that shouldn't live in the global Dworshak folder.
from dworshak_config import DworshakConfig
# Point to a specific project file
project_cfg = DworshakConfig("./.my_project/config.json")
project_cfg.set_value("internal", "debug_mode", True)
The Ecosystem Integration
While dworshak-config handles the persistence, it is designed to be orchestrated by dworshak-prompt for interactive workflows.
# In your application using dworshak-prompt
from dworshak_prompt import DworshakGet
# This will:
# 1. Check ~/.dworshak/config.json for 'api_url'
# 2. If missing, prompt the user (Console/GUI/Web)
# 3. Save the answer back to config.json automatically
api_url = DworshakGet.config("my_service", "api_url")
Configuration Schema
Data is stored in a clean, human-readable nested JSON format:
{
"aws": {
"region": "us-east-1",
"output": "json"
},
"rjn_api": {
"base_url": "https://api.example.com"
}
}
Sister Projects in the Dworshak Ecosystem
- CLI/Orchestrator: dworshak
- Interactive UI: dworshak-prompt
- Secrets Storage: dworshak-secret
- Plaintext Pathed Configs: dworshak-secret
- Classic .env Injection: dworshak-secret
pipx install dworshak
pip install dworshak-secret
pip install dworshak-config
pip install dworshak-env
pip install dworshak-prompt
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 dworshak_config-0.2.2.tar.gz.
File metadata
- Download URL: dworshak_config-0.2.2.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a700749d770cabffc7d52352752cd5714761b1cb8d327e8c39e8d0cc9fbb212
|
|
| MD5 |
144a05f0c4a798396ca79f226c65fdaf
|
|
| BLAKE2b-256 |
5f6bde291a639a5313d812aff2f9d49077b961f19d4160b76789f56dbc56b800
|
Provenance
The following attestation bundles were made for dworshak_config-0.2.2.tar.gz:
Publisher:
publish.yml on City-of-Memphis-Wastewater/dworshak-config
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dworshak_config-0.2.2.tar.gz -
Subject digest:
4a700749d770cabffc7d52352752cd5714761b1cb8d327e8c39e8d0cc9fbb212 - Sigstore transparency entry: 955606659
- Sigstore integration time:
-
Permalink:
City-of-Memphis-Wastewater/dworshak-config@870501b8a4644f6b72dd88401c9f661d26fd1cd9 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/City-of-Memphis-Wastewater
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@870501b8a4644f6b72dd88401c9f661d26fd1cd9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dworshak_config-0.2.2-py3-none-any.whl.
File metadata
- Download URL: dworshak_config-0.2.2-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f79e68f23a7322c09ff30f5ede8d7fd5230bf925985aead97ca391c96916126
|
|
| MD5 |
17b1b74121e8493c06451a007f6b682b
|
|
| BLAKE2b-256 |
64c51a02f2f10e2f38abe22171e401df3be2e43d3d7c56a88cf5067324e641ea
|
Provenance
The following attestation bundles were made for dworshak_config-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on City-of-Memphis-Wastewater/dworshak-config
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dworshak_config-0.2.2-py3-none-any.whl -
Subject digest:
9f79e68f23a7322c09ff30f5ede8d7fd5230bf925985aead97ca391c96916126 - Sigstore transparency entry: 955606661
- Sigstore integration time:
-
Permalink:
City-of-Memphis-Wastewater/dworshak-config@870501b8a4644f6b72dd88401c9f661d26fd1cd9 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/City-of-Memphis-Wastewater
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@870501b8a4644f6b72dd88401c9f661d26fd1cd9 -
Trigger Event:
release
-
Statement type: