🧬 DTL Parser
Domain Transport Language SDK for Python - Smart Tool Edition
╔══════════════════════════════════════════════════════════════════════════════╗
║ ║
║ ██████╗ ████████╗██╗ ██████╗ █████╗ ██████╗ ███████╗███████╗ ║
║ ██╔══██╗╚══██╔══╝██║ ██╔══██╗██╔══██╗██╔══██╗██╔════╝██╔════╝ ║
║ ██║ ██║ ██║ ██║ ██████╔╝███████║██████╔╝███████╗█████╗ ║
║ ██║ ██║ ██║ ██║ ██╔═══╝ ██╔══██║██╔══██╗╚════██║██╔══╝ ║
║ ██████╔╝ ██║ ███████╗ ██║ ██║ ██║██║ ██║███████║███████╗ ║
║ ╚═════╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚══════╝ ║
║ ║
║ ⭐ Domain Transport Language - Smart Parser ⭐ ║
║ ║
║ 🇦🇪 Product of Dubai, Made in Emirates ║
║ Born in Dubai, Built for the World ║
║ ║
╚══════════════════════════════════════════════════════════════════════════════╝
✨ Features
- 🧠 Smart Tool - Intelligent DTL processing with auto-detection
- 📊 Full DTL Parsing - Parse DTL files and strings with complete type support
- ✅ Enum Validation - Exact-match validation with up to 10 values per field
- 🔧 Autofix / Magic Corrections - Automatically fix common errors
- 🔍 Fuzzy Matching - Smart typo suggestions using Levenshtein distance
- 📤 Multi-Format Export - Convert to JSON or CSV
- 🏭 Programmatic Creation - Create tables and documents in code
- 🎨 Beautiful CLI - Colorful command-line interface
- 📝 Type-Safe - Full type hints for IDE support
📦 Installation
pip install dtl-parser
🚀 Quick Start
CLI Usage (Smart Tool)
# Show beautiful banner
dtl --banner
# Parse and analyze a file
dtl analyze data.dtl
# Validate with suggestions
dtl validate data.dtl
# Auto-fix errors
dtl fix data.dtl --output fixed.dtl
# Convert to JSON
dtl convert data.dtl --format json
# Pretty print
dtl parse data.dtl --pretty
Python API
from dtl_parser import DTLParser, SmartTool, print_banner
# Show the magical banner ✨
print_banner()
# Parse a DTL file
parser = DTLParser()
doc = parser.parse_file("data.dtl")
# Use the Smart Tool
tool = SmartTool()
# Analyze the file
analysis = tool.analyze("data.dtl")
print(f"Health Score: {analysis['health_score']}/100")
# Pretty print with colors
tool.pretty_print(doc)
# Health check
health = tool.health_check(doc)
print(f"Status: {health['status']}")
🧠 Smart Tool Features
Auto Schema Inference
from dtl_parser import SmartTool
tool = SmartTool()
# Infer schema from raw data
data = [
{"id": "U001", "name": "Alice", "status": "active", "score": 95},
{"id": "U002", "name": "Bob", "status": "inactive", "score": 87},
{"id": "U003", "name": "Charlie", "status": "active", "score": 92},
]
# SmartTool detects types and creates enum for 'status'
table = tool.infer_schema(data, "USERS")
print(table.to_dtl())
# Output:
# USERS|id:s,name:s,status:e(active,inactive),score:i|3|S0|W0|C0
# U001|Alice|active|95
# ...
Intelligent Query
# Query with filters
active_users = tool.query(users_table, status="active")
admins = tool.query(users_table, role="admin", status="active")
Health Check
health = tool.health_check(doc)
# Returns:
# {
# "status": "healthy", # healthy | warning | critical
# "score": 95,
# "checks": [...],
# "recommendations": [...]
# }
✅ Validation
from dtl_parser import DTLParser
parser = DTLParser()
doc = parser.parse_file("data.dtl")
# Validate and get errors with suggestions
errors = doc.validate()
for error in errors:
print(f"[{error.severity.value}] Line {error.line}: {error.message}")
if error.suggestion:
print(f" 💡 Suggestion: {error.suggestion}")
🔧 Autofix
from dtl_parser import DTLParser
dtl_with_errors = """
@dtlv1.0^dtWEB^pDemo^c0^s0^w0^hash
@sec^none^0x0^none^0
users|id:s,status:e(active,inactive,pending)|2|S0|W0|C0
U001|actve
U002|pendng
U003|inactive
"""
parser = DTLParser()
doc = parser.parse(dtl_with_errors)
# Apply autofix ✨
fixed_doc, changes = doc.autofix()
for change in changes:
print(f"✨ {change}")
# Output:
# ✨ Fixed table name case: users → USERS
# ✨ Fixed row count in USERS: 2 → 3
# ✨ Fixed USERS[0].status: 'actve' → 'active'
# ✨ Fixed USERS[1].status: 'pendng' → 'pending'
🏭 Create Tables Programmatically
from dtl_parser import create_table, create_document
# Create a table with enum fields
orders = create_table("ORDERS", {
"id": "s",
"customer": "s",
"status": "e(pending,confirmed,shipped,delivered)",
"priority": "e(low,medium,high,urgent)",
"total": "f",
"created": "D"
})
# Add rows
orders.add_row({
"id": "ORD-001",
"customer": "Alice",
"status": "pending",
"priority": "high",
"total": 99.99,
"created": "2025-01-15"
})
# Create document and export
doc = create_document(domain="dtWEB")
doc.add_table(orders)
print(doc.to_dtl())
📊 DTL Data Types
| Type | Code | Description | Example |
|---|---|---|---|
| String | s |
Text value | Hello World |
| Integer | i |
Whole number | 42 |
| Float | f |
Decimal number | 3.14 |
| Boolean | b |
0 or 1 | 1 |
| Date | D |
YYYY-MM-DD | 2025-01-15 |
| Timestamp | T |
ISO 8601 | 2025-01-15T10:30:00Z |
| UUID | u |
Unique ID | 550e8400-e29b-... |
| JSON | j |
Embedded JSON | {"key":"value"} |
| Array | a(x) |
List of type x | a,b,c |
| Enum | e(...) |
Exact match | e(low,medium,high) |
🏥 Domain Examples
Healthcare (dtHC)
patients = create_table("PATIENTS", {
"mrn": "s",
"name": "s",
"gender": "e(M,F,O)",
"blood_type": "e(A+,A-,B+,B-,AB+,AB-,O+,O-)",
"status": "e(active,discharged,deceased)"
}, security="S2") # HIPAA compliant
Finance (dtFN)
transactions = create_table("TRANSACTIONS", {
"id": "u",
"type": "e(deposit,withdrawal,transfer)",
"currency": "e(USD,EUR,GBP,AED)",
"amount": "f",
"status": "e(pending,completed,failed)"
}, web3="W1") # With blockchain signature
🎨 Beautiful Output
from dtl_parser import print_banner, Colors
# Print the banner
print_banner() # Full banner
print_banner(mini=True) # Compact banner
# Use colors in your output
print(f"{Colors.TEAL}DTL is awesome!{Colors.ENDC}")
print(f"{Colors.GREEN}✅ Success{Colors.ENDC}")
print(f"{Colors.RED}❌ Error{Colors.ENDC}")
📜 License
MIT License - see LICENSE file.
👤 Author
Padam Sundar Kafle
Lead Architect, DTL & AlifZetta
📧 padam@axz.si
🔗 Links
- Website: dtlaz.org
- Documentation: dtlaz.org/docs
- GitHub: github.com/AlifZetta/dtl-parser-python
🇦🇪 Product of Dubai, Made in Emirates
Born in Dubai, Built for the World
✨ Version 1.4.1 - Smart Tool Edition ✨
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dtl_parser-1.4.1.tar.gz
(25.8 kB
view details)
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 dtl_parser-1.4.1.tar.gz.
File metadata
- Download URL: dtl_parser-1.4.1.tar.gz
- Upload date:
- Size: 25.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8a767627543296501b9afd3d557e38905963b051a946be35e40a56e0c739f0a
|
|
| MD5 |
7123c5f2d959fb8882326bd7efd1cbcb
|
|
| BLAKE2b-256 |
323fd09e6e31372fc44342dbca37facbda11f131e71689aa7183de5c6056491d
|
File details
Details for the file dtl_parser-1.4.1-py3-none-any.whl.
File metadata
- Download URL: dtl_parser-1.4.1-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47d66bf7b383b337fd3bae02516d4b1cdfdb1fe66f5778dba5584889fe522829
|
|
| MD5 |
0d17da44fae8c63753ae4ee6c1f67418
|
|
| BLAKE2b-256 |
e93cc31b703cd376a8449a19794191b196c7964fa4f10b5a665e849fe26da393
|