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.1.tar.gz (73.0 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.1-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gerbyx-0.2.1.tar.gz
  • Upload date:
  • Size: 73.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gerbyx-0.2.1.tar.gz
Algorithm Hash digest
SHA256 153a6fc33c50f67c7a4eb7d6580d81fe5c92a3e7eeaa2ee7480caf9bdfa85cef
MD5 51011c076a9536a71fd6978d388ecc84
BLAKE2b-256 fbebd3d121acaad428651eab049b9807926ad2eb847b05d5882e703b6af5fd5d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gerbyx-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 28.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gerbyx-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cfaaa984a407913e4d31436b130cca1265898b0b4c3d01b8246a2fcd20c49b64
MD5 7905ad33cf33ae9c5347c33a141a6dd6
BLAKE2b-256 dda8dbca08537f4d064b7ad0e8b3e8e2dc868455d51173cfba137ec228188c90

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