pygerber package

Subpackages

Submodules

pygerber.API2D module

pygerber.API2D.render_file(file_path: str, *, dpi: int = 600, colors: pygerber.parser.pillow.parser.ColorSet = ColorSet(dark=(66, 166, 66, 255), clear=(16, 66, 36, 255), background=(0, 0, 0, 0)), ignore_deprecated: bool = True, image_padding: int = 0) PIL.Image.Image[source]

Loads, parses and renders file from given path and returns its render as PIL.Image.Image.

Parameters
  • file_path (str) – Path to gerber file to render.

  • dpi (int, optional) – Output image DPI, defaults to 600

  • colors (ColorSet, optional) – Color specification, defaults to DEFAULT_COLOR_SET_GREEN

  • ignore_deprecated (bool, optional) – If false causes parser to stop when deprecated syntax is met, defaults to True

  • image_padding (int, optional) – Additional image padding, defaults to 0

Returns

Output image.

Return type

Image.Image

pygerber.API2D.render_file_and_save(file_path: str, save_path: str, *, dpi: int = 600, colors: pygerber.parser.pillow.parser.ColorSet = ColorSet(dark=(66, 166, 66, 255), clear=(16, 66, 36, 255), background=(0, 0, 0, 0)), ignore_deprecated: bool = True, image_padding: int = 0)[source]

Loads, parses, renders file from file_path and saves it in save_path.

Parameters
  • file_path (str) – Path to gerber file.

  • save_path (str) – Path to save render.

  • dpi (int, optional) – DPI of output image, defaults to 600

  • colors (ColorSet, optional) – Color set to use, defaults to DEFAULT_COLOR_SET_GREEN

  • ignore_deprecated (bool, optional) – If true, causes parser to not stop when deprecated syntax is found, defaults to True

  • image_padding (int, optional) – Additional pixel padding for image, defaults to 0

pygerber.API2D.render_from_json(file_path: str) PIL.Image.Image[source]

Render 2D image from specfile written in json.

Parameters

file_path (str) – json specfile path.

Returns

rendered and merged image.

Return type

Image.Image

pygerber.API2D.render_from_spec(spec: Dict[str, Any]) PIL.Image.Image[source]

Render 2D image from specfile alike dictionary.

Parameters

spec (Dict) – specfile parameters dictionary.

Returns

rendered and merged image.

Return type

Image.Image

pygerber.API2D.render_from_toml(file_path: str) PIL.Image.Image[source]

Render 2D image from specfile written in toml.

Parameters

file_path (str) – toml specfile path.

Returns

rendered and merged image.

Return type

Image.Image

pygerber.API2D.render_from_yaml(file_path: str) PIL.Image.Image[source]

Render 2D image from specfile written in yaml.

Parameters

file_path (str) – yaml specfile path.

Returns

rendered and merged image.

Return type

Image.Image

pygerber.API3D module

pygerber.cli module

pygerber.cli.get_argument_parser() argparse.ArgumentParser[source]
pygerber.cli.handle_blender_cli(*_)[source]
pygerber.cli.handle_pygerber_cli(args)[source]

pygerber.constants module

class pygerber.constants.Interpolation[source]

Bases: object

ClockwiseCircular = 2
CounterclockwiseCircular = 3
Linear = 1
class pygerber.constants.Mirroring[source]

Bases: object

No = 'N'
X = 'X'
XY = 'XY'
Y = 'Y'
class pygerber.constants.Polarity[source]

Bases: object

CLEAR = 'C'
DARK = 'D'
class pygerber.constants.Unit[source]

Bases: object

INCHES = 'IN'
MILLIMETERS = 'MM'

pygerber.coparser module

class pygerber.coparser.CoParser[source]

Bases: object

default_format = '%FSLAX36Y36*%'
dump(co: float) str[source]
format: pygerber.tokens.fs.FormatSpecifierToken
format_zeros(float_string)[source]
get_mode() str[source]
get_zeros() None[source]
parse(float_string: str) float[source]
set_default_format()[source]
set_format(format: pygerber.tokens.fs.FormatSpecifierToken) None[source]
set_mode(mode: str) None[source]
set_zeros(zeros: str) None[source]

pygerber.drawing_state module

class pygerber.drawing_state.DrawingState[source]

Bases: object

begin_region()[source]
coparser: pygerber.coparser.CoParser
end_region()[source]
interpolation: pygerber.constants.Interpolation
is_regionmode: bool
mirroring: str
parse_co(float_string: str)[source]
polarity: str
rotation: float
scale: float
set_co_format(fs: FormatSpecifierToken)[source]
set_defaults()[source]
set_interpolation(interpolation)[source]
set_mirroring(mode)[source]
set_polarity(polarity)[source]
set_rotation(angle: float)[source]
set_scaling(scale: float)[source]
set_unit(unit)[source]
unit: pygerber.constants.Unit

pygerber.exceptions module

exception pygerber.exceptions.ApertureSelectionError[source]

Bases: Exception

exception pygerber.exceptions.DeprecatedSyntax[source]

Bases: pygerber.exceptions.InvalidSyntaxError

exception pygerber.exceptions.EndOfStream[source]

Bases: Exception

exception pygerber.exceptions.FeatureNotSupportedError[source]

Bases: Exception

exception pygerber.exceptions.InvalidCommandFormat[source]

Bases: pygerber.exceptions.InvalidSyntaxError

exception pygerber.exceptions.InvalidSyntaxError[source]

Bases: Exception

exception pygerber.exceptions.RenderingError[source]

Bases: Exception

exception pygerber.exceptions.TokenNotFound[source]

Bases: pygerber.exceptions.InvalidSyntaxError

pygerber.exceptions.suppress_context(exc: Exception) Exception[source]

pygerber.mathclasses module

class pygerber.mathclasses.BoundingBox(x0: 'float', y0: 'float', x1: 'float', y1: 'float') 'None'[source]

Bases: object

as_tuple() Tuple[float][source]

Tuple (left, upper, right, lower)

as_tuple_y_inverse() Tuple[float][source]
contains(other: pygerber.mathclasses.BoundingBox) bool[source]
height() float[source]
include_point(point: pygerber.mathclasses.Vector2D) pygerber.mathclasses.BoundingBox[source]
left: float
lower: float
padded(delta) pygerber.mathclasses.BoundingBox[source]
right: float
transform(vector: pygerber.mathclasses.Vector2D) pygerber.mathclasses.BoundingBox[source]
upper: float
width() float[source]
class pygerber.mathclasses.Vector2D(x: 'float', y: 'float')[source]

Bases: object

as_tuple()[source]
as_tuple_3D(z: float = 0.0)[source]
dot(other: pygerber.mathclasses.Vector2D) float[source]
floor()[source]
length()[source]
normalize()[source]
x: float
y: float
pygerber.mathclasses.angle_from_zero(vector: pygerber.mathclasses.Vector2D) float[source]
pygerber.mathclasses.format_bytes(val: float) str[source]

pygerber.tokenizer module

class pygerber.tokenizer.Tokenizer(ignore_deprecated: bool = True)[source]

Bases: object

begin_index: int = 0
char_index = 0
line_index = 1
push_token(token: Token) None[source]
raise_token_not_found(source)[source]
set_defaults()[source]
state: pygerber.drawing_state.DrawingState
token_stack: collections.deque
token_stack_size: int = 0
tokenize(source, file_path: str = '<string>') Deque[Token][source]
tokenize_file(file_path: str | Path) Deque[Token][source]

Module contents