Gerber parser that generates Shapely objects for PCB and geometries
Project description
gerbyx
Gerber parser that generates Shapely objects for PCB and geometries
- PyPI package: https://pypi.org/project/gerbyx/
- Free software: MIT License
Features
- ✅ Gerber X2 & X3 Support: Full support for both Gerber X2 and X3 standards
- ✅ Shapely Geometry Generation: Converts Gerber commands to Shapely objects
- ✅ Macro Apertures: Supports custom aperture macros (AM)
- ✅ Aperture Blocks: Handles aperture blocks (AB) with full instantiation support
- ✅ Layer Polarity: Dark and Clear polarity for additive/subtractive operations
- ✅ Attributes: File, aperture, and component attributes (TF, TA, TO)
- ✅ X3 Component Attributes: TO.C (reference), TO.CVal (value), and more
- ✅ Delete Attributes: TD command for removing attributes (X3)
- ✅ X3 Validation: Built-in validator for X3 compliance
- ✅ Visualization: Built-in Matplotlib visualization
- ✅ CLI Tool: Command-line interface for quick processing
- ✅ Performance Optimized: +6% faster with zero overhead logging
- ✅ Secure: No eval() vulnerabilities, safe expression evaluator
- ✅ Logging System: DEBUG/INFO/WARNING/ERROR levels with lazy evaluation
Gerber X3 Features
- Component reference designators (TO.C)
- Component values (TO.CVal)
- Inline comments with
# - Explicit macro closing with
%AM*% - Mandatory M02 end-of-file marker
- Aperture blocks instantiation
- Delete attributes (TD)
- X3 validation with error reporting
📚 Documentation
Comprehensive documentation is available in the docs/ folder:
- Getting Started - Installation and usage
- Gerber X3 Support - X3 features and compliance
- Performance - Optimization details (+6% speedup)
- Security - Security policy and fixes
- Logging - Logging system guide
- Testing - Test suite documentation
See docs/README.md for complete documentation index.
🚀 Quick Start
from gerbyx import logger
from gerbyx.tokenizer import tokenize_gerber
from gerbyx.parser import GerberParser
from gerbyx.processor import GerberProcessor
# Optional: Enable debug logging
logger.set_level('DEBUG') # or 'INFO' (default), 'WARNING', 'ERROR'
# Parse Gerber file
with open('file.gbr', 'r') as f:
gerber_source = f.read()
processor = GerberProcessor()
parser = GerberParser(processor)
tokens = tokenize_gerber(gerber_source)
parser.parse(tokens)
# Get geometries
geometries = processor.geometries
print(f"Generated {len(geometries)} geometries")
🔒 Security
From Version 0.2.0 critical security fixes are included:
- ✅ Removed
eval()vulnerability (RCE risk eliminated) - ✅ Safe expression evaluator for macro expressions
- ✅ Input validation and sanitization
See docs/SECURITY.md for details.
⚡ Performance
Optimized for speed:
- Parsing: +22% faster
- Tokenization: +13% faster
- Small files: +36% faster
- Zero overhead logging
See docs/OPTIMIZATION_SUMMARY.md for benchmarks.
Credits
This package was created with Cookiecutter and the audreyfeldroy/cookiecutter-pypackage project template.
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
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 gerbyx-0.2.3.tar.gz.
File metadata
- Download URL: gerbyx-0.2.3.tar.gz
- Upload date:
- Size: 73.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7498cc11d0073caa77acb02ba8fe45a03ff7e6fd2d1deccb0830ac5d38a33f95
|
|
| MD5 |
6e8957002b398b057a1709be7b820398
|
|
| BLAKE2b-256 |
c0c2ff02b2d5bf6ce39c52e65f20a6e6179a970b1f9c67161909bfb1992d9d96
|
File details
Details for the file gerbyx-0.2.3-py3-none-any.whl.
File metadata
- Download URL: gerbyx-0.2.3-py3-none-any.whl
- Upload date:
- Size: 26.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0475c963dc98bf2e5ce9e6d8e890916c688c89b489c646b2f8923113df2c3d0e
|
|
| MD5 |
0c8732a464fdf34365e3906b9d33247d
|
|
| BLAKE2b-256 |
4979b1b47de07f5ef39fa38fd4022998672f58c9d0fe983a5897fc9f089e6d39
|