Skip to main content

Gerber parser that generates Shapely objects for PCB and geometries

Project description

gerbyx

PyPI version Github tag

Gerber parser that generates Shapely objects for PCB and geometries

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:

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

Version 0.2.0 includes critical security fixes:

  • ✅ 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

gerbyx-0.2.2.tar.gz (70.4 kB view details)

Uploaded Source

Built Distribution

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

gerbyx-0.2.2-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

Details for the file gerbyx-0.2.2.tar.gz.

File metadata

  • Download URL: gerbyx-0.2.2.tar.gz
  • Upload date:
  • Size: 70.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for gerbyx-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4ec8d04f925738c88e1b2dbf72e0e6e44e60a892a72badac629b8f93271b0f97
MD5 95dec7339ee18b6ef36b40f96d589e40
BLAKE2b-256 208e42c79934134817ee49cdeaddfa5861ffe086c711933d633319daf1a38180

See more details on using hashes here.

File details

Details for the file gerbyx-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: gerbyx-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 25.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for gerbyx-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9969a167f34ff4b003220e1cc191924fb855aa65d30f66aef84ccf992b871dea
MD5 38ff98aff93db5510e590e1c8958bc19
BLAKE2b-256 00f7a96798dd0256c5058fb27e636b0b9fb238d0ae4af876af03f019151cee44

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