Skip to main content

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

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 โœจ

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

dtl_parser-1.4.1.tar.gz (25.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dtl_parser-1.4.1-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

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

Hashes for dtl_parser-1.4.1.tar.gz
Algorithm Hash digest
SHA256 f8a767627543296501b9afd3d557e38905963b051a946be35e40a56e0c739f0a
MD5 7123c5f2d959fb8882326bd7efd1cbcb
BLAKE2b-256 323fd09e6e31372fc44342dbca37facbda11f131e71689aa7183de5c6056491d

See more details on using hashes here.

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

Hashes for dtl_parser-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 47d66bf7b383b337fd3bae02516d4b1cdfdb1fe66f5778dba5584889fe522829
MD5 0d17da44fae8c63753ae4ee6c1f67418
BLAKE2b-256 e93cc31b703cd376a8449a19794191b196c7964fa4f10b5a665e849fe26da393

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page