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 documentparse_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 inchesto_millimeters(dim)- Convert dimension to millimetersformat_imperial(dim)- Format as imperial stringformat_metric(dim)- Format as metric string
Formulas
create_context(variables)- Create formula evaluation contextevaluate_formula(expr, context)- Evaluate formula expressionresolve_formulas(formulas)- Resolve all formulas in a Formulas object
Utilities
validate_document(doc)- Validate document structurecalculate_board_feet(doc)- Calculate total board feetgenerate_cut_list(doc)- Generate cut list from resolved documentformat_cut_list(items)- Format cut list as string table
License
MIT
Project details
Release history Release notifications | RSS feed
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)
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66b21c3a1cd2fba9b2fc81cf8dae90ff288448f75e5ba5229374a5a9d2ba88cd
|
|
| MD5 |
925a90e0ad3d0b1addddcf231dadaa56
|
|
| BLAKE2b-256 |
4fde4e50a874ff08c1016c7ff802593c23fc285a2d71cc4d45971332ee195af0
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c42cdfc2daee4a6aaf49863491a101eb4c53706489397908f6ed550f7cbc46c6
|
|
| MD5 |
3ca533ea33f32871c68ae88aed3bb069
|
|
| BLAKE2b-256 |
1e9965665155af9ae3dac347d1d52dd94282845546f508dbd933dd7bd7e909d5
|