dirconf
dirconf is a Python tool for declaratively specifying configuration directory structures, and constructing Python dict representations of their contents.
For full user documentation and examples please visit https://jmarshrossney.github.io/dirconf/.
Motivations
I wrote this because I sometimes have to work with quite old scientific models that require various configuration files and data inputs in various formats to be present in various locations. I was (and remain) concerned about how easy it can be to misconfigure certain models without realising, and how common workflows compromise reproducibility.
dirconf helps by
-
Allowing the user to describe the structure of a directory representing a valid configuration using Python dataclasses, and validate real directories against this description.
-
Providing a scaffold for defining consistent read/write mechanisms through which complex, distributed configurations in legacy formats can be mapped to Python
dicts.
The ability to represent configurations as dicts is very useful indeed.
With no extra effort, we can:
- Validate configurations using excellent tools such as JSON Schema and Pydantic.
- Generate new configurations and metadata programmatically, as opposed to copying and editing files by hand or writing shell scripts.
Installation
dirconf is a Python package and thus can be installed using pip, or tools such as uv and poetry that wrap around pip.
uv add dirconf
or
pip install dirconf
Currently Python versions equal to or above 3.12 are supported.
Overview of usage
There are two essential steps for adapting dirconf to a specific use-case.
- Define handlers satisfying the
Handlerprotocol for each of the paths (files and directories) present in your configuration. - Define the structure of a valid configuration in terms of its paths and their respective handlers, by subclassing the
DirConfigclass. This is most easily done using themake_dirconfigfunction.
The custom DirConfig subclass can then be used to
- Read a configuration from the filesystem into a Python
dict. - Write a configuration
dictto the filesystem.
These steps are most easily understood through examples: see the docs. All examples are based on self-contained marimo notebooks, which can be found in the examples directory.
Philosophy
dirconf contains ~700 lines of code (including docstrings) and has no dependencies beyond the Standard Library.
This is by design.
I have no intention of developing dirconf into a more sophisticated tool than it already is.
The aim is that is works seamlessly alongside other tools and packages for parsing and validation, without ever getting in the way or creating conflicts.
With that out of the way, please feel free to raise an issue or make a pull request to suggest a change or feature.
See CONTRIBUTING.md for full details.
Metadata
Release files for dirconf 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dirconf-0.6.0.tar.gz | 11.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dirconf-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.5 kB
Release files / dirconf-0.6.0.tar.gz
| Download URL | dirconf-0.6.0.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
663fe256f57299412d34d7f04b2928af6879e909aefb11af3f715124ece6fef0
|
|
BLAKE2b-256 checksum How to use checksums |
a474503f14056766fb4436baebc1626d691b3f87025b05c9a6e981b59f0ef25a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / dirconf-0.6.0-py3-none-any.whl
| Download URL | dirconf-0.6.0-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
939c04619fe4cbf4809c3468dfc003305ddacd58c9ad3d6716348b004517a842
|
|
BLAKE2b-256 checksum How to use checksums |
8bf275621968af5923f5a17d62026623dbb251998cea13f822eb5c112ef55a28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for dirconf 0.6.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.