DTL (Domain Transport Language) Parser - Smart Tool with enum validation, autofix, and beautiful CLI
Project description
๐งฌ 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 โจ
Project details
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 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
|