Skip to main content

dworshak-config

dworshak-config is a lightweight 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 (json and pathlib).
  • Service-Oriented: Organizes settings by service and item (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 Obtain

# 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 = Obtain.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"
    }
}

CLI

The dworshak layer is the intended primary CLI entry point, but the dworshak-config CLI can be used directly.

See the dworshak-config Typer CLI structure.

dworshak-config helptree

Screenshot of the dworshak-config CLI helptree

helptree is utility funtion for Typer CLIs, imported from the typer-helptree library.


Sister Projects in the Dworshak Ecosystem

pipx install dworshak
pip install dworshak-secret
pip install dworshak-config
pip install dworshak-env
pip install dworshak-prompt

Metadata

Release files for dworshak-config 0.2.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dworshak-config 0.2.8
File Size Uploaded
dworshak_config-0.2.8.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dworshak-config 0.2.8
File Interpreter ABI Platform
dworshak_config-0.2.8-py3-none-any.whl Python 3 none any Details

Total release size: 20.8 kB

Release files / dworshak_config-0.2.8.tar.gz

Download URL dworshak_config-0.2.8.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dadce1a05124595066a82f5a1766394ff7c7d7a76ccee9dbb6e45a517d1f54a4
BLAKE2b-256 checksum
How to use checksums
3032cea4d714abd0aaa2696283f907778b73a7a70626a2b6168dde77b92b3d12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 5, 2026.

Transparency log

Release files / dworshak_config-0.2.8-py3-none-any.whl

Download URL dworshak_config-0.2.8-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e956d9bf6087931dfefb4a53aaa5d5a1edcc3c9d8f0ba92b16293be1c4265d6
BLAKE2b-256 checksum
How to use checksums
ed8bcab8bc50432e7f612e41635b3778ab833960a6fe73402b33b0485f4605af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.8 This release

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page