Skip to main content

🧬 DTL Parser

Domain Transport Language SDK for Python - Smart Tool Edition

PyPI version Python License: MIT

╔══════════════════════════════════════════════════════════════════════════════╗
║                                                                              ║
║     ██████╗ ████████╗██╗         ██████╗  █████╗ ██████╗ ███████╗███████╗   ║
║     ██╔══██╗╚══██╔══╝██║         ██╔══██╗██╔══██╗██╔══██╗██╔════╝██╔════╝   ║
║     ██║  ██║   ██║   ██║         ██████╔╝███████║██████╔╝███████╗█████╗     ║
║     ██║  ██║   ██║   ██║         ██╔═══╝ ██╔══██║██╔══██╗╚════██║██╔══╝     ║
║     ██████╔╝   ██║   ███████╗    ██║     ██║  ██║██║  ██║███████║███████╗   ║
║     ╚═════╝    ╚═╝   ╚══════╝    ╚═╝     ╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝   ║
║                                                                              ║
║              ⭐ 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


🇦🇪 Product of Dubai, Made in Emirates

Born in Dubai, Built for the World

✨ Version 1.4.1 - Smart Tool Edition ✨

Metadata

Release files for dtl-parser 1.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dtl-parser 1.4.1
File Size Uploaded
dtl_parser-1.4.1.tar.gz 25.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dtl-parser 1.4.1
File Interpreter ABI Platform
dtl_parser-1.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 46.7 kB

Release files / dtl_parser-1.4.1.tar.gz

Download URL dtl_parser-1.4.1.tar.gz
Size 25.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f8a767627543296501b9afd3d557e38905963b051a946be35e40a56e0c739f0a
BLAKE2b-256 checksum
How to use checksums
323fd09e6e31372fc44342dbca37facbda11f131e71689aa7183de5c6056491d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release files / dtl_parser-1.4.1-py3-none-any.whl

Download URL dtl_parser-1.4.1-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47d66bf7b383b337fd3bae02516d4b1cdfdb1fe66f5778dba5584889fe522829
BLAKE2b-256 checksum
How to use checksums
e93cc31b703cd376a8449a19794191b196c7964fa4f10b5a665e849fe26da393
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

1.4.1 This release

2 release files

1.3.1

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page