Skip to main content

pypi versions license ci docs

dictIO

Table of Contents

dictIO is a Python package to read, write and manipulate dictionary text files.

It was designed to leverage the versatility of text based dictionary files, or 'dict files' in short, while easing their use in Python through seamless support for Python dicts.

dictIO supports

  • reading and writing Python dicts in dict files.
  • usage of references and expressions in dict files, dynamically resolved during reading.
  • usage of cascaded dict files, allowing separation of a case-agnostic configuration dict and its case-specific parameterization: baseDict + paramDict = caseDict

Further, dictIO

  • is widely tolerant in reading different flavours (quotes, preserving comments, etc.)
  • can read and write also JSON, XML and OpenFOAM (with some limitations)

Installation

pip install dictIO

Usage

dictIO's core class is SDict, a generic data structure for serializable dictionaries.
SDict inherits from Python's builtin dict. It can hence be used transparently in any context where a dict or any other MutableMapping type is expected.

You can use SDict the same way you use dict. E.g. you can pass a dict literal to its constructor:

from dictIO import SDict

my_dict: SDict[str, int] = SDict(
    {
        "foo": 1,
        "bar": 2,
    }
)

The simplest way to to dump and load a dict to / from a file, is to use SDict's dump() and load() instance methods:

To dump my_dict to a file, use .dump():

my_dict.dump("myDict")

To load the formerly dumped file into a new dict, use .load():

my_dict_loaded: SDict[str, int] = SDict().load("myDict")

In cases where you need more control over how dict files are read and written,
dictIO's DictReader and DictWriter classes offer this flexibility, while still maintaining a simple and high level API:

from dictIO import DictReader, DictWriter

my_dict = DictReader.read("myDict")
DictWriter.write(my_dict, "parsed.myDict")

The above example reads a dict file, merges any (sub-)dicts included through #include directives, evaluates expressions contained in the dict, and finally saves the read and evaluated dict with prefix 'parsed' as 'parsed.myDict'.

This sequence of reading, evaluating and writing a dict is also called 'parsing' in dictIO. Because this task is so common, dictIO provides a convenience class for it: Using DictParser.parse() the above task can be accomplished in one line of code:

from dictIO import DictParser

DictParser.parse("myDict")

The parse operation can also be executed from the command line, using the 'dictParser' command line script installed with dictIO:

dictParser myDict

For more examples and usage, please refer to dictIO's documentation.

File Format

The native file format used by dictIO shares, by intention, some commonalities with the OpenFOAM file format, but is kept simpler and more tolerant to different flavours of string formatting.

With some limitations, dictIO supports also reading from and writing to OpenFOAM, Json and XML.

For a detailed documentation of the native file format used by dictIO, see File Format in dictIO's documentation on GitHub Pages.

Development Setup

1. Install uv

This project uses uv as package manager. If you haven't already, install uv, preferably using it's "Standalone installer" method:
..on Windows:

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

..on MacOS and Linux:

curl -LsSf https://astral.sh/uv/install.sh | sh

(see docs.astral.sh/uv for all / alternative installation methods.)

Once installed, you can update uv to its latest version, anytime, by running:

uv self update

2. Clone the repository

Clone the dictIO repository into your local development directory:

git clone https://github.com/dnv-opensource/dictIO path/to/your/dev/dictIO

Change into the project directory after cloning:

cd dictIO

3. Install dependencies

Run uv sync -U to create a virtual environment and install all project dependencies into it:

uv sync -U

Note: Using --no-dev will omit installing development dependencies.

Explanation: The -U option stands for --update. It forces uv to fetch and install the latest versions of all dependencies, ensuring that your environment is up-to-date.

Note: uv will create a new virtual environment called .venv in the project root directory when running uv sync -U the first time. Optionally, you can create your own virtual environment using e.g. uv venv, before running uv sync -U.

4. (Optional) Activate the virtual environment

When using uv, there is in almost all cases no longer a need to manually activate the virtual environment.
uv will find the .venv virtual environment in the working directory or any parent directory, and activate it on the fly whenever you run a command via uv inside your project folder structure:

uv run <command>

However, you still can manually activate the virtual environment if needed. When developing in an IDE, for instance, this can in some cases be necessary depending on your IDE settings. To manually activate the virtual environment, run one of the "known" legacy commands:
..on Windows:

.venv\Scripts\activate.bat

..on Linux:

source .venv/bin/activate

5. Install pre-commit hooks

The .pre-commit-config.yaml file in the project root directory contains a configuration for pre-commit hooks. To install the pre-commit hooks defined therein in your local git repository, run:

uv run pre-commit install

All pre-commit hooks configured in .pre-commit-config.yaml will now run each time you commit changes.

pre-commit can also manually be invoked, at anytime, using:

uv run pre-commit run --all-files

To skip the pre-commit validation on commits (e.g. when intentionally committing broken code), run:

uv run git commit -m <MSG> --no-verify

To update the hooks configured in .pre-commit-config.yaml to their newest versions, run:

uv run pre-commit autoupdate

. Test that the installation works

To test that the installation works, run pytest in the project root folder:

uv run pytest

Meta

Copyright (c) 2026 DNV AS. All rights reserved.

Frank Lumpitzsch - @LinkedIn - frank.lumpitzsch@dnv.com

Claas Rostock - @LinkedIn - claas.rostock@dnv.com

Seunghyeon Yoo - @LinkedIn - seunghyeon.yoo@dnv.com

Distributed under the MIT license. See LICENSE for more information.

https://github.com/dnv-opensource/dictIO

Contributing

  1. Fork it (https://github.com/dnv-opensource/dictIO/fork)
  2. Create an issue in your GitHub repo
  3. Create your branch based on the issue number and type (git checkout -b issue-name)
  4. Evaluate and stage the changes you want to commit (git add -i)
  5. Commit your changes (git commit -am 'place a descriptive commit message here')
  6. Push to the branch (git push origin issue-name)
  7. Create a new Pull Request in GitHub

For your contribution, please make sure you follow the STYLEGUIDE before creating the Pull Request.

Metadata

Release files for dictIO 0.4.6

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

Source distribution (sdist)

Source distribution for dictIO 0.4.6
File Size Uploaded
dictio-0.4.6.tar.gz 247.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dictIO 0.4.6
File Interpreter ABI Platform
dictio-0.4.6-py3-none-any.whl Python 3 none any Details

Total release size: 309.8 kB

Release files / dictio-0.4.6.tar.gz

Download URL dictio-0.4.6.tar.gz
Size 247.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b5eade04d7b5bb1467637b0f99d2ce04efbc93a54b11b32edd9df0617774c1ed
BLAKE2b-256 checksum
How to use checksums
760196f3b8b9763732a19450c16c85f4600639acdda089909a35bd643d26d490
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 Oct 15, 2026.

Transparency log

Release files / dictio-0.4.6-py3-none-any.whl

Download URL dictio-0.4.6-py3-none-any.whl
Size 62.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb28621779b15ebba8e2073527a79f4443af4e9fb219a61bb1005e836bbdc9be
BLAKE2b-256 checksum
How to use checksums
cb249e74efd2bd63195417337334d6051ad5f250198fb7843cd629153ea82703
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 Oct 15, 2026.

Transparency log
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