Skip to main content

Parser for BGD DSL Protocol embedded in text descriptions

Project description

BGD DSL Parser


Quick Start

from bgd_dsl import parse

text = get_some_data()
data: Dict = parse(text)

print(data)

Parser for BGD DSL Protocol — a lightweight embedded DSL used to store structured product data inside plain text descriptions.

The library extracts a DSL block from text and converts it into a structured Python dictionary.


Features

  • Parse structured data from text descriptions
  • Versioned DSL support
  • Nested fields (a.b.c)
  • Automatic type parsing
  • Lists support
  • Comment support
  • Easy integration via pip / poetry

Installation

pip

pip install bgd-dsl

poetry

poetry add bgd-dsl

Quick Start

parse file

from bgd_dsl import parse

text = open("src/description.txt").read()
data = parse(text)

print(data)

Output

{
    "metadata": {
        "version": 1,
        "updated_by": "wb_sync_service",
        "updated_at": "2026-02-24T00:00:00"
    },
    "core": {
        "weight_kg": 1.25,
        "length_cm": 80,
        "width_cm": 50,
        "height_cm": 10,
        "material": "polyester",
        "season": "winter",
        "dimensions": {
            "width_cm": 50,
            "height_cm": 80,
            "depth_cm": 10
        },
        "sizes": ["M", "L", "XXL"]
    },
    "override": {
        "wb": {
            "package_type": "BOX"
        },
        "ozon": {
            "age_limit": "adult",
            "sizes": ["S", "M", "L"]
        }
    }
}

BGD DSL Rules

Sections

Sections define top-level objects:

[core]
weight_kg = 1.25

{
  "core": {
    "weight_kg": 1.25
  }
}

Nested fields

Dot notation creates nested dictionaries:

dimensions.width_cm = 50

{
  "dimensions": {
    "width_cm": 50
  }
}

Lists

Comma-separated values become lists:

sizes = M, L, XXL

["M", "L", "XXL"]

Supported value types

The parser automatically detects:

  • int
  • float
  • bool
  • date (ISO)
  • list
  • dict
  • string

Comments

Supported comment styles:

; comment

\\ comment

Versioning

DSL contains a required version:

[metadata]
version = 1

Parser automatically selects the correct implementation.

Future DSL versions are supported without breaking existing integrations.

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

bgd_dsl-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

bgd_dsl-0.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file bgd_dsl-0.1.0.tar.gz.

File metadata

  • Download URL: bgd_dsl-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for bgd_dsl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f2521eadf7f20c4fd2ffde73a87cb49603e4c3c2b3ac333666a7aa56e52f501d
MD5 00dc2babdf76ae9f57b5b9963b34b58a
BLAKE2b-256 8281c038dfc41b4efffb79d2cdd9455089c0bbb8aa869c1a59adb5b6bc6f4df8

See more details on using hashes here.

File details

Details for the file bgd_dsl-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bgd_dsl-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for bgd_dsl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4dd98dcef1293234721f51a8e7456ce1a7a8b8a5dbe50cf58aaab1684f14453
MD5 5cc18d4cb582a489e88507ce6d52e47d
BLAKE2b-256 f95935f610ad520a831203d98542b4f3912934387102fd1e419e2ce738699037

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