DAN (Data Advanced Notation) Python Library
A Python implementation of the DAN (Data Advanced Notation) parser and encoder. DAN is a human-readable data format that combines the simplicity of key-value pairs with the power of nested structures and tables.
Features
- Decode: Parse DAN text into Python dictionaries
- Encode: Convert Python dictionaries into DAN text
- Support for nested blocks, tables, arrays, and various data types
- Comment support (# and //)
- Type inference (strings, numbers, booleans, arrays)
- Comprehensive test suite with 40+ test cases
- Multiple real-world examples
See FEATURES.md for a complete feature list.
Installation
This repo uses uv for environments and lockfiles (uv.lock).
# Install uv: https://docs.astral.sh/uv/getting-started/installation/
uv sync
Editable install from a clone:
git clone https://github.com/marcuwynu23/dan-py.git
cd dan-py
uv sync
With dev tools (e.g. pytest):
uv sync --group dev
uv run pytest tests/
You can still install from PyPI with pip when a release is published:
pip install dan-annotation
Quick Start
Decoding DAN
from dan import decode
text = """
app {
name: "MyApp"
version: 1.0
server {
host: localhost
port: 3000
}
}
"""
data = decode(text)
print(data)
# {'app': {'name': 'MyApp', 'version': 1.0, 'server': {'host': 'localhost', 'port': 3000}}}
Encoding to DAN
from dan import encode
data = {
"app": {
"name": "MyApp",
"version": 1.0,
"server": {
"host": "localhost",
"port": 3000
}
}
}
text = encode(data)
print(text)
Working with Tables
text = """
users: table(id, username, email) [
1, alice, "alice@example.com"
2, bob, "bob@example.com"
]
"""
data = decode(text)
# {'users': [{'id': 1, 'username': 'alice', 'email': 'alice@example.com'}, ...]}
Reading from Files
from dan import decode
with open('config.dan', 'r') as f:
config = decode(f.read())
Examples
Check out the examples/ directory for real-world usage scenarios:
- Application configuration (
config.dan) - Database schemas (
database_schema.dan) - API routes (
api_routes.dan) - Microservices configuration (
microservices.dan) - Docker Compose (
docker_compose.dan) - Kubernetes resources (
kubernetes.dan) - And many more!
Running Tests
# Run all tests
python -m unittest discover tests -v
# Run specific test file
python -m unittest tests.test_dan -v
# Using pytest (if installed)
pytest tests/
Documentation
- FEATURES.md - Complete feature documentation
- CONTRIBUTING.md - Guidelines for contributing
- CHANGELOG.md - Version history and changes
- SECURITY.md - Responsible vulnerability disclosure
- examples/README.md - Example files documentation
Contributing
Contributions are welcome! Please read CONTRIBUTING.md and CODE_OF_CONDUCT.md. Optional support: PayPal or the repository Sponsor button (.github/FUNDING.yml).
License
This project is licensed under the MIT License - see the LICENSE file for details.
Security
Please report security vulnerabilities to the maintainers. See SECURITY.md for more information.
Support
Metadata
Release files for dan-annotation 1.0.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 | Actions |
|---|---|---|---|---|
| dan_annotation-1.0.0.tar.gz | 10.0 kB | Without provenance | Details for dan_annotation-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dan_annotation-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for dan_annotation-1.0.0-py3-none-any.whl |
Total release size: 16.1 kB
Release files / dan_annotation-1.0.0.tar.gz
| Download URL | dan_annotation-1.0.0.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3dd7ed043a798e906a0e75fe7ea8ed3528e83052d0ac840a3c90345ae5c7f1b0
|
|
BLAKE2b-256 checksum How to use checksums |
387badc3035394b99c532823dec80b762ece3f7e9e0e1f3586d854896cdd8d40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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 / dan_annotation-1.0.0-py3-none-any.whl
| Download URL | dan_annotation-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad87b09ff955e7eff383d76414f8b7d3d3f0f878e764139df00fe42fadd49c0a
|
|
BLAKE2b-256 checksum How to use checksums |
dcad292a3f0d4818603154bcfa39523ee96da458dc6144452cafa33eb4da38cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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 dan-annotation 1.0.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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.