Skip to main content

Reference parser for WoodML woodworking markup language

Project description

WoodML Parser (Python)

Reference implementation of the WoodML parser for Python.

Installation

pip install woodml-parser

Or install from source:

pip install -e .

CLI Usage

After installation, the woodml command is available:

# Parse and display project info
woodml parse project.woodml

# Generate a cut list
woodml cutlist project.woodml -f table

# Validate a file
woodml validate project.woodml

# Show project information
woodml info project.woodml -f json

CLI Options

  • -o, --output <file> - Write output to file instead of stdout
  • -f, --format <fmt> - Output format: json, text, table (default: text)
  • -v, --verbose - Show detailed output
  • -h, --help - Show help message

Library Usage

from woodml import parse_and_resolve, generate_cut_list, format_cut_list

# Parse a WoodML document
woodml_source = '''
woodml: "1.0"

project:
  name: "Simple Box"
  units: imperial

formulas:
  vars:
    length: 12"
    width: 8"

parts:
  - id: side
    dimensions:
      length: $length
      width: $width
      thickness: 1/2"
    quantity: 2
'''

# Parse and resolve all variables
doc = parse_and_resolve(woodml_source)

# Generate cut list
cut_list = generate_cut_list(doc)
print(format_cut_list(cut_list))

API

Parsing

  • parse(source) - Parse WoodML string into document
  • parse_and_resolve(source) - Parse and resolve all variables/formulas

Units

  • parse_dimension(value) - Parse dimension string (e.g., "3-1/2\"")
  • to_inches(dim) - Convert dimension to inches
  • to_millimeters(dim) - Convert dimension to millimeters
  • format_imperial(dim) - Format as imperial string
  • format_metric(dim) - Format as metric string

Formulas

  • create_context(variables) - Create formula evaluation context
  • evaluate_formula(expr, context) - Evaluate formula expression
  • resolve_formulas(formulas) - Resolve all formulas in a Formulas object

Utilities

  • validate_document(doc) - Validate document structure
  • calculate_board_feet(doc) - Calculate total board feet
  • generate_cut_list(doc) - Generate cut list from resolved document
  • format_cut_list(items) - Format cut list as string table

License

MIT

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

woodml_parser-1.0.0.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

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

woodml_parser-1.0.0-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file woodml_parser-1.0.0.tar.gz.

File metadata

  • Download URL: woodml_parser-1.0.0.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for woodml_parser-1.0.0.tar.gz
Algorithm Hash digest
SHA256 66b21c3a1cd2fba9b2fc81cf8dae90ff288448f75e5ba5229374a5a9d2ba88cd
MD5 925a90e0ad3d0b1addddcf231dadaa56
BLAKE2b-256 4fde4e50a874ff08c1016c7ff802593c23fc285a2d71cc4d45971332ee195af0

See more details on using hashes here.

File details

Details for the file woodml_parser-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: woodml_parser-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 28.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for woodml_parser-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c42cdfc2daee4a6aaf49863491a101eb4c53706489397908f6ed550f7cbc46c6
MD5 3ca533ea33f32871c68ae88aed3bb069
BLAKE2b-256 1e9965665155af9ae3dac347d1d52dd94282845546f508dbd933dd7bd7e909d5

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