DAN (Data Advanced Notation) Parser and Encoder for Python
Project description
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
pip install -e .
Or install from source:
git clone https://github.com/yourusername/dan-py.git
cd dan-py
pip install -e .
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
- examples/README.md - Example files documentation
Contributing
Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dan_annotation-0.1.0.tar.gz.
File metadata
- Download URL: dan_annotation-0.1.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe222e29f4154dbf3cf3d50543ccf4054f52d897093920de8ddbd69fd037f284
|
|
| MD5 |
02f30d908977e443d5e5d3cc66249719
|
|
| BLAKE2b-256 |
509de6a894546f44666f9d39d1a2320011262bcf77797637f9292ad18175231c
|
File details
Details for the file dan_annotation-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dan_annotation-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6069c139b0b89ba8e8d7094f0200e56963583e1a0fd963570d16f9ea94a31bb
|
|
| MD5 |
03bf555d89f171ba184fea3e134c97de
|
|
| BLAKE2b-256 |
68fa67bfcff99f92b188f2345d61f9f5f1f87e8661754706ea443d808cff00e5
|