Skip to main content

DictParser

DictParser is a typed utility to read configuration values from dictionaries, JSON files, and YAML files with support for dynamic placeholders.

Features

  • Dot-path access for nested dictionaries and lists
  • Runtime placeholder resolution with {key} syntax
  • Recursive resolution for nested containers (dict, list, tuple, set)
  • Optional shallow copy for mutable return values
  • Full resolved export with get_all()
  • JSON/YAML serialization helpers: to_json() and to_yaml()
  • File export helper with format inference: save()

Installation

Install from source:

pip install -e .

Quick Example

from dictparser import DictParser

data = {
    "aa": "and",
    "c": [0, 1, "{a.c.d}"],
    "a": {"b": 1, "c": {"d": "{aa}", "e": "{a.b}"}},
}

parser = DictParser(data)

assert parser.get("a.b") == 1
assert parser.get("a.c.d") == "and"
assert parser.get("a.c.e") == "1"
assert parser.get("c.1") == 1
assert parser.get("c.2") == "and"

Notes on Resolution Dispatch

The resolver internally dispatches by container type while navigating paths:

  • dictionary key lookup for mappings
  • integer index lookup for lists and tuples
  • recursive placeholder expansion for nested containers

This behavior is now documented directly in source comments in src/dictparser/dictparser.py.

API Additions

The class exposes additional helpers for full output and persistence:

resolved = parser.get_all()
json_text = parser.to_json()
yaml_text = parser.to_yaml()

# Infer format from output suffix (.json/.yaml/.yml), fallback json.
parser.save("output.json")
parser.save("output.yaml")

# Force format regardless of output suffix.
parser.save("output.txt", format="json")
parser.save("output.txt", format="yaml")

CLI Usage

The package exposes a CLI entry point:

dictparser INPUT_FILE [-k KEY] [-o OUTPUT_FILE] [-f {json,yaml}]
  • Without -k/--key, the CLI resolves and returns the entire dictionary (get_all).
  • With -k/--key, the CLI resolves and returns only the selected key (get).
  • With -o/--output, the CLI saves the result to file.
  • With -f/--format, the output format is forced.
  • Without -f/--format, format is inferred from output filename and defaults to json.

Third-Party Licenses

Third-party licenses are archived in:

  • licenses/third_party/packages/

Dependency summary and source links are listed in:

  • licenses/third_party/summary.tsv
  • THIRD_PARTY_NOTICES.md

Release files for ga-dictparser 0.1.1

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

Source distribution (sdist)

Source distribution for ga-dictparser 0.1.1
File Size Uploaded
ga_dictparser-0.1.1.tar.gz 20.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ga-dictparser 0.1.1
File Interpreter ABI Platform
ga_dictparser-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 28.0 kB

Release files / ga_dictparser-0.1.1.tar.gz

Download URL ga_dictparser-0.1.1.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3a812ac084f7cc064769d866c7d45cad31b0eee7e380415fba4f23cf01ce9c28
BLAKE2b-256 checksum
How to use checksums
cbaae7d8d33c02651c86cc88a7138a6cb2d635d563998c62088e8caaf17ef4ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 8, 2026.

Transparency log

Release files / ga_dictparser-0.1.1-py3-none-any.whl

Download URL ga_dictparser-0.1.1-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
062048c934bcd012892d5a374fc356dc23ce34c63e616dc540665a93b7d2d032
BLAKE2b-256 checksum
How to use checksums
a1fb7e5a55d4fa323913d075ad7c67b92cce441f7e8cb12a3bcaa6721c6ea427
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 8, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.3

2 release files

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

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