Skip to content

context2

context2

Gerber AST parser, version 2, parsing context.

Parser2Context

Context used by Gerber AST parser, version 2.

Source code in src/pygerber/gerberx3/parser2/context2.py
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
class Parser2Context:
    """Context used by Gerber AST parser, version 2."""

    def __init__(self, options: Parser2ContextOptions | None = None) -> None:
        self.options = Parser2ContextOptions() if options is None else options
        self.state: State2 = (
            State2()
            if self.options.initial_state is None
            else self.options.initial_state
        )
        self.main_command_buffer: CommandBuffer2 = (
            CommandBuffer2()
            if self.options.initial_main_command_buffer is None
            else self.options.initial_main_command_buffer
        )
        self.region_command_buffer: Optional[CommandBuffer2] = None
        self.block_command_buffer_stack: list[CommandBuffer2] = []
        self.block_state_stack: list[State2] = []
        self.step_and_repeat_command_buffer: Optional[CommandBuffer2] = None
        self.state_before_step_and_repeat: Optional[State2] = None
        self.macro_statement_buffer: Optional[StatementBuffer2] = None
        self.macro_eval_buffer: Optional[CommandBuffer2] = None
        self.macro_variable_buffer: dict[str, Decimal] = {}
        self.hooks: Parser2HooksBase = (
            Parser2Hooks() if self.options.hooks is None else self.options.hooks
        )
        self.current_token: Optional[Token] = None
        self.reached_program_stop: bool = False
        self.reached_optional_stop: bool = False
        self.reached_end_of_file: bool = False

        self.file_attributes = FileAttributes()
        self.aperture_attributes = ApertureAttributes()
        self.object_attributes = ObjectAttributes()

        self.macro_expressions = (
            Parser2ContextMacroExpressionFactories()
            if self.options.custom_macro_expression_factories is None
            else self.options.custom_macro_expression_factories
        )
        self.apertures: dict[ApertureID, Aperture2] = {
            REGION_OUTLINE_DEFAULT_APERTURE_ID: NoCircle2(
                diameter=Offset.NULL,
                hole_diameter=None,
            ),
        }

    def push_block_command_buffer(self) -> None:
        """Add new command buffer for block aperture draw commands."""
        self.block_command_buffer_stack.append(
            CommandBuffer2()
            if self.options.initial_block_command_buffer is None
            else self.options.initial_block_command_buffer.copy(),
        )

    def pop_block_command_buffer(self) -> CommandBuffer2:
        """Return latest block aperture command buffer and delete it from the stack."""
        if len(self.block_command_buffer_stack) == 0:
            raise ReferencedNotInitializedBlockBufferError(self.current_token)
        return self.block_command_buffer_stack.pop()

    def first_block_command_buffer(self) -> CommandBuffer2:
        """Return first (topmost) block aperture command buffer."""
        if len(self.block_command_buffer_stack) == 0:
            raise ReferencedNotInitializedBlockBufferError(self.current_token)
        return self.block_command_buffer_stack[-1]

    def push_block_state(self) -> None:
        """Add new command buffer for block aperture draw commands."""
        self.block_state_stack.append(self.state)

    def pop_block_state(self) -> State2:
        """Return latest block aperture command buffer and delete it from the stack."""
        if len(self.block_state_stack) == 0:
            raise ReferencedNotInitializedBlockBufferError(self.current_token)
        return self.block_state_stack.pop()

    def set_region_command_buffer(self) -> None:
        """Add new command buffer for block aperture draw commands."""
        self.region_command_buffer = (
            CommandBuffer2()
            if self.options.initial_region_command_buffer is None
            else self.options.initial_region_command_buffer.copy()
        )

    def unset_region_command_buffer(self) -> None:
        """Add new command buffer for block aperture draw commands."""
        self.region_command_buffer = None

    def get_region_command_buffer(self) -> CommandBuffer2:
        """Return latest block aperture command buffer and delete it from the stack."""
        if self.region_command_buffer is None:
            raise RegionNotInitializedError(self.current_token)
        return self.region_command_buffer

    def set_step_and_repeat_command_buffer(self) -> None:
        """Add new command buffer for block aperture draw commands."""
        self.step_and_repeat_command_buffer = (
            CommandBuffer2()
            if self.options.initial_region_command_buffer is None
            else self.options.initial_region_command_buffer.copy()
        )

    def unset_step_and_repeat_command_buffer(self) -> None:
        """Unset step and repeat command buffer."""
        self.step_and_repeat_command_buffer = None

    def get_step_and_repeat_command_buffer(self) -> CommandBuffer2:
        """Return step and repeat command buffer."""
        if self.step_and_repeat_command_buffer is None:
            raise StepAndRepeatNotInitializedError(self.current_token)
        return self.step_and_repeat_command_buffer

    def get_state_before_step_and_repeat(self) -> State2:
        """Return step and repeat command buffer."""
        if self.state_before_step_and_repeat is None:
            raise StepAndRepeatNotInitializedError(self.current_token)
        return self.state_before_step_and_repeat

    def unset_state_before_step_and_repeat(self) -> None:
        """Unset step and repeat command buffer."""
        self.state_before_step_and_repeat = None

    def set_state_before_step_and_repeat(self) -> None:
        """Add new command buffer for block aperture draw commands."""
        self.state_before_step_and_repeat = self.state

    def reset_state_to_pre_step_and_repeat(self) -> None:
        """Set state to state before step and repeat."""
        self.set_state(self.get_state_before_step_and_repeat())

    def get_macro_statement_buffer(self) -> StatementBuffer2:
        """Return macro statement buffer."""
        if self.macro_statement_buffer is None:
            raise MacroNotInitializedError(self.current_token)
        return self.macro_statement_buffer

    def set_macro_statement_buffer(self) -> None:
        """Add new command buffer for block aperture draw commands."""
        self.macro_statement_buffer = (
            StatementBuffer2()
            if self.options.initial_macro_statement_buffer is None
            else self.options.initial_macro_statement_buffer
        )

    def unset_macro_statement_buffer(self) -> None:
        """Unset step and repeat command buffer."""
        self.macro_statement_buffer = None

    def get_macro_eval_buffer(self) -> CommandBuffer2:
        """Return macro evaluation buffer."""
        if self.macro_eval_buffer is None:
            raise MacroNotInitializedError(self.current_token)
        return self.macro_eval_buffer

    def set_macro_eval_buffer(self) -> None:
        """Add new command buffer for block aperture draw commands."""
        self.macro_eval_buffer = (
            CommandBuffer2()
            if self.options.initial_macro_eval_buffer is None
            else self.options.initial_macro_eval_buffer
        )

    def unset_macro_eval_buffer(self) -> None:
        """Unset step and repeat command buffer."""
        self.macro_eval_buffer = None

    def skip_token(self) -> NoReturn:
        """Skip this token."""
        raise SkipTokenInterrupt

    def halt_parser(self) -> NoReturn:
        """Halt parsing process."""
        raise ExitParsingProcess2Interrupt

    def get_hooks(self) -> Parser2HooksBase:
        """Get hooks object."""
        return self.hooks

    def get_current_token(self) -> Optional[Token]:
        """Get current token object."""
        return self.current_token

    def set_current_token(self, token: Token) -> None:
        """Get current token object."""
        self.current_token = token

    def set_state(self, state: State2) -> None:
        """Set parser state."""
        self.state = state

    def add_command(self, __command: Command2) -> None:
        """Add draw command to command buffer."""
        if self.get_is_region():
            self.get_region_command_buffer().add_command(__command)
            return

        if self.get_is_aperture_block():
            self.first_block_command_buffer().add_command(__command)
            return

        if self.get_is_step_and_repeat():
            self.get_step_and_repeat_command_buffer().add_command(__command)
            return

        self.main_command_buffer.add_command(__command)

    def get_state(self) -> State2:
        """Get parser state."""
        return self.state

    def get_draw_units(self) -> Unit:
        """Get draw_units property value."""
        return self.get_state().get_draw_units()

    def set_draw_units(self, draw_units: Unit) -> None:
        """Set the draw_units property value."""
        return self.set_state(self.get_state().set_draw_units(draw_units))

    def get_coordinate_parser(self) -> CoordinateParser:
        """Get coordinate_parser property value."""
        return self.get_state().get_coordinate_parser()

    def set_coordinate_parser(self, coordinate_parser: CoordinateParser) -> None:
        """Set the coordinate_parser property value."""
        return self.set_state(
            self.get_state().set_coordinate_parser(coordinate_parser),
        )

    def get_polarity(self) -> Polarity:
        """Get polarity property value."""
        return self.get_state().get_polarity()

    def set_polarity(self, polarity: Polarity) -> None:
        """Set the polarity property value."""
        return self.set_state(self.get_state().set_polarity(polarity))

    def get_mirroring(self) -> Mirroring:
        """Get mirroring property value."""
        return self.get_state().get_mirroring()

    def set_mirroring(self, mirroring: Mirroring) -> None:
        """Set the mirroring property value."""
        return self.set_state(self.get_state().set_mirroring(mirroring))

    def get_rotation(self) -> Decimal:
        """Get rotation property value."""
        return self.get_state().get_rotation()

    def set_rotation(self, rotation: Decimal) -> None:
        """Set the rotation property value."""
        return self.set_state(self.get_state().set_rotation(rotation))

    def get_scaling(self) -> Decimal:
        """Get scaling property value."""
        return self.get_state().get_scaling()

    def set_scaling(self, scaling: Decimal) -> None:
        """Set the scaling property value."""
        return self.set_state(self.get_state().set_scaling(scaling))

    def get_is_output_image_negation_required(self) -> bool:
        """Get is_output_image_negation_required property value."""
        return self.get_state().get_is_output_image_negation_required()

    def set_is_output_image_negation_required(self, *, value: bool) -> None:
        """Set the is_output_image_negation_required property value."""
        return self.set_state(
            self.get_state().set_is_output_image_negation_required(value),
        )

    def get_image_name(self) -> Optional[str]:
        """Get image_name property value."""
        return self.get_state().get_image_name()

    def set_image_name(self, image_name: Optional[str]) -> None:
        """Set the image_name property value."""
        return self.set_state(self.get_state().set_image_name(image_name))

    def get_file_name(self) -> Optional[str]:
        """Get file_name property value."""
        return self.get_state().get_file_name()

    def set_file_name(self, file_name: Optional[str]) -> None:
        """Set the file_name property value."""
        return self.set_state(self.get_state().set_file_name(file_name))

    def get_axis_correspondence(self) -> AxisCorrespondence:
        """Get axis_correspondence property value."""
        return self.get_state().get_axis_correspondence()

    def set_axis_correspondence(self, axis_correspondence: AxisCorrespondence) -> None:
        """Set the axis_correspondence property value."""
        return self.set_state(
            self.get_state().set_axis_correspondence(axis_correspondence),
        )

    def get_draw_mode(self) -> DrawMode:
        """Get draw_mode property value."""
        return self.get_state().get_draw_mode()

    def set_draw_mode(self, draw_mode: DrawMode) -> None:
        """Set the draw_mode property value."""
        return self.set_state(self.get_state().set_draw_mode(draw_mode))

    def get_is_region(self) -> bool:
        """Get is_region property value."""
        return self.get_state().get_is_region()

    def set_is_region(self, is_region: bool) -> None:  # noqa: FBT001
        """Set the is_region property value."""
        return self.set_state(self.get_state().set_is_region(is_region))

    def get_is_aperture_block(self) -> bool:
        """Get is_aperture_block property value."""
        return self.get_state().get_is_aperture_block()

    def set_is_aperture_block(self, is_aperture_block: bool) -> None:  # noqa: FBT001
        """Set the is_aperture_block property value."""
        return self.set_state(
            self.get_state().set_is_aperture_block(is_aperture_block),
        )

    def get_aperture_block_id(self) -> Optional[ApertureID]:
        """Get is_aperture_block property value."""
        return self.get_state().get_aperture_block_id()

    def set_aperture_block_id(self, aperture_block_id: Optional[ApertureID]) -> None:
        """Set the is_aperture_block property value."""
        return self.set_state(
            self.get_state().set_aperture_block_id(aperture_block_id),
        )

    def get_is_multi_quadrant(self) -> bool:
        """Get is_aperture_block property value."""
        return self.get_state().get_is_multi_quadrant()

    def set_is_multi_quadrant(self, is_multi_quadrant: bool) -> None:  # noqa: FBT001
        """Set the is_aperture_block property value."""
        return self.set_state(
            self.get_state().set_is_multi_quadrant(is_multi_quadrant),
        )

    def get_is_step_and_repeat(self) -> bool:
        """Get is_step_and_repeat property value."""
        return self.get_state().get_is_step_and_repeat()

    def set_is_step_and_repeat(self, is_step_and_repeat: bool) -> None:  # noqa: FBT001
        """Set the is_step_and_repeat property value."""
        return self.set_state(
            self.get_state().set_is_step_and_repeat(is_step_and_repeat),
        )

    def get_x_repeat(self) -> int:
        """Get x_step property value."""
        return self.get_state().get_x_repeat()

    def set_x_repeat(self, x_repeat: int) -> None:
        """Set the x_repeat property value."""
        return self.set_state(self.get_state().set_x_repeat(x_repeat))

    def get_y_repeat(self) -> int:
        """Get y_step property value."""
        return self.get_state().get_y_repeat()

    def set_y_repeat(self, y_repeat: int) -> None:
        """Set the y_repeat property value."""
        return self.set_state(self.get_state().set_y_repeat(y_repeat))

    def get_x_step(self) -> Offset:
        """Get x_step property value."""
        return self.get_state().get_x_step()

    def set_x_step(self, x_step: Offset) -> None:
        """Set the x_step property value."""
        return self.set_state(self.get_state().set_x_step(x_step))

    def get_y_step(self) -> Offset:
        """Get y_step property value."""
        return self.get_state().get_y_step()

    def set_y_step(self, y_step: Offset) -> None:
        """Set the y_step property value."""
        return self.set_state(self.get_state().set_y_step(y_step))

    def get_current_position(self) -> Vector2D:
        """Get current_position property value."""
        return self.get_state().get_current_position()

    def set_current_position(self, current_position: Vector2D) -> None:
        """Set the current_position property value."""
        return self.set_state(
            self.get_state().set_current_position(current_position),
        )

    def get_current_aperture_id(self) -> Optional[ApertureID]:
        """Get current_aperture property value."""
        current_aperture_id = self.get_state().get_current_aperture_id()
        if current_aperture_id is None and self.get_is_region():
            return REGION_OUTLINE_DEFAULT_APERTURE_ID

        return current_aperture_id

    def set_current_aperture_id(self, current_aperture: Optional[ApertureID]) -> None:
        """Set the current_aperture property value."""
        return self.set_state(
            self.get_state().set_current_aperture_id(current_aperture),
        )

    def get_aperture(self, __key: ApertureID) -> Aperture2:
        """Get apertures property value."""
        try:
            return self.apertures[__key]
        except KeyError as e:
            raise ApertureNotDefined2Error(self.current_token) from e

    def set_aperture(self, __key: ApertureID, __value: Aperture2) -> None:
        """Set the apertures property value."""
        self.apertures[__key] = __value

    def get_macro(self, __key: str) -> ApertureMacro2:
        """Get macro property value."""
        try:
            return self.get_state().get_macro(__key)
        except KeyError as e:
            raise MacroNotDefinedError(self.current_token) from e

    def set_macro(self, __key: str, __value: ApertureMacro2) -> None:
        """Set the macro property value."""
        return self.set_state(self.get_state().set_macro(__key, __value))

    def set_reached_program_stop(self) -> None:
        """Set flag indicating that M00 token was reached."""
        self.reached_program_stop = True

    def get_reached_program_stop(self) -> bool:
        """Get flag indicating that M00 token was reached."""
        return self.reached_program_stop

    def set_reached_optional_stop(self) -> None:
        """Set flag indicating that M01 token was reached."""
        self.reached_optional_stop = True

    def get_reached_optional_stop(self) -> bool:
        """Get flag indicating that M01 token was reached."""
        return self.reached_optional_stop

    def set_reached_end_of_file(self) -> None:
        """Set flag indicating that M02 end of file was reached."""
        self.reached_end_of_file = True

    def get_reached_end_of_file(self) -> bool:
        """Get flag indicating that M02 end of file was reached."""
        return self.reached_end_of_file

    def get_file_attribute(self, key: str) -> Optional[str]:
        """Get file attributes property."""
        return self.file_attributes.get(key)

    def delete_file_attribute(self, key: str) -> None:
        """Get file attributes property."""
        self.file_attributes = self.file_attributes.delete(key)

    def set_file_attribute(self, key: str, value: Optional[str]) -> None:
        """Set file attributes property."""
        self.file_attributes = self.file_attributes.update(key, value)

    def get_aperture_attribute(self, key: str) -> Optional[str]:
        """Get aperture attributes property."""
        return self.aperture_attributes.get(key)

    def delete_aperture_attribute(self, key: str) -> None:
        """Delete aperture attributes property."""
        self.aperture_attributes = self.aperture_attributes.delete(key)

    def clear_aperture_attributes(self) -> None:
        """Clear aperture attributes property."""
        self.aperture_attributes = ApertureAttributes()

    def set_aperture_attribute(self, key: str, value: Optional[str]) -> None:
        """Set aperture attributes property."""
        self.aperture_attributes = self.aperture_attributes.update(key, value)

    def get_object_attribute(self, key: str) -> Optional[str]:
        """Get object attributes property."""
        return self.object_attributes.get(key)

    def delete_object_attribute(self, key: str) -> None:
        """Delete object attributes property."""
        self.object_attributes = self.object_attributes.delete(key)

    def set_object_attribute(self, key: str, value: Optional[str]) -> None:
        """Set object attributes property."""
        self.object_attributes = self.object_attributes.update(key, value)

    def clear_object_attributes(self) -> None:
        """Clear object attributes property."""
        self.object_attributes = ObjectAttributes()

push_block_command_buffer

push_block_command_buffer() -> None

Add new command buffer for block aperture draw commands.

Source code in src/pygerber/gerberx3/parser2/context2.py
def push_block_command_buffer(self) -> None:
    """Add new command buffer for block aperture draw commands."""
    self.block_command_buffer_stack.append(
        CommandBuffer2()
        if self.options.initial_block_command_buffer is None
        else self.options.initial_block_command_buffer.copy(),
    )

pop_block_command_buffer

pop_block_command_buffer() -> CommandBuffer2

Return latest block aperture command buffer and delete it from the stack.

Source code in src/pygerber/gerberx3/parser2/context2.py
def pop_block_command_buffer(self) -> CommandBuffer2:
    """Return latest block aperture command buffer and delete it from the stack."""
    if len(self.block_command_buffer_stack) == 0:
        raise ReferencedNotInitializedBlockBufferError(self.current_token)
    return self.block_command_buffer_stack.pop()

first_block_command_buffer

first_block_command_buffer() -> CommandBuffer2

Return first (topmost) block aperture command buffer.

Source code in src/pygerber/gerberx3/parser2/context2.py
def first_block_command_buffer(self) -> CommandBuffer2:
    """Return first (topmost) block aperture command buffer."""
    if len(self.block_command_buffer_stack) == 0:
        raise ReferencedNotInitializedBlockBufferError(self.current_token)
    return self.block_command_buffer_stack[-1]

push_block_state

push_block_state() -> None

Add new command buffer for block aperture draw commands.

Source code in src/pygerber/gerberx3/parser2/context2.py
def push_block_state(self) -> None:
    """Add new command buffer for block aperture draw commands."""
    self.block_state_stack.append(self.state)

pop_block_state

pop_block_state() -> State2

Return latest block aperture command buffer and delete it from the stack.

Source code in src/pygerber/gerberx3/parser2/context2.py
def pop_block_state(self) -> State2:
    """Return latest block aperture command buffer and delete it from the stack."""
    if len(self.block_state_stack) == 0:
        raise ReferencedNotInitializedBlockBufferError(self.current_token)
    return self.block_state_stack.pop()

set_region_command_buffer

set_region_command_buffer() -> None

Add new command buffer for block aperture draw commands.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_region_command_buffer(self) -> None:
    """Add new command buffer for block aperture draw commands."""
    self.region_command_buffer = (
        CommandBuffer2()
        if self.options.initial_region_command_buffer is None
        else self.options.initial_region_command_buffer.copy()
    )

unset_region_command_buffer

unset_region_command_buffer() -> None

Add new command buffer for block aperture draw commands.

Source code in src/pygerber/gerberx3/parser2/context2.py
def unset_region_command_buffer(self) -> None:
    """Add new command buffer for block aperture draw commands."""
    self.region_command_buffer = None

get_region_command_buffer

get_region_command_buffer() -> CommandBuffer2

Return latest block aperture command buffer and delete it from the stack.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_region_command_buffer(self) -> CommandBuffer2:
    """Return latest block aperture command buffer and delete it from the stack."""
    if self.region_command_buffer is None:
        raise RegionNotInitializedError(self.current_token)
    return self.region_command_buffer

set_step_and_repeat_command_buffer

set_step_and_repeat_command_buffer() -> None

Add new command buffer for block aperture draw commands.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_step_and_repeat_command_buffer(self) -> None:
    """Add new command buffer for block aperture draw commands."""
    self.step_and_repeat_command_buffer = (
        CommandBuffer2()
        if self.options.initial_region_command_buffer is None
        else self.options.initial_region_command_buffer.copy()
    )

unset_step_and_repeat_command_buffer

unset_step_and_repeat_command_buffer() -> None

Unset step and repeat command buffer.

Source code in src/pygerber/gerberx3/parser2/context2.py
def unset_step_and_repeat_command_buffer(self) -> None:
    """Unset step and repeat command buffer."""
    self.step_and_repeat_command_buffer = None

get_step_and_repeat_command_buffer

get_step_and_repeat_command_buffer() -> CommandBuffer2

Return step and repeat command buffer.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_step_and_repeat_command_buffer(self) -> CommandBuffer2:
    """Return step and repeat command buffer."""
    if self.step_and_repeat_command_buffer is None:
        raise StepAndRepeatNotInitializedError(self.current_token)
    return self.step_and_repeat_command_buffer

get_state_before_step_and_repeat

get_state_before_step_and_repeat() -> State2

Return step and repeat command buffer.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_state_before_step_and_repeat(self) -> State2:
    """Return step and repeat command buffer."""
    if self.state_before_step_and_repeat is None:
        raise StepAndRepeatNotInitializedError(self.current_token)
    return self.state_before_step_and_repeat

unset_state_before_step_and_repeat

unset_state_before_step_and_repeat() -> None

Unset step and repeat command buffer.

Source code in src/pygerber/gerberx3/parser2/context2.py
def unset_state_before_step_and_repeat(self) -> None:
    """Unset step and repeat command buffer."""
    self.state_before_step_and_repeat = None

set_state_before_step_and_repeat

set_state_before_step_and_repeat() -> None

Add new command buffer for block aperture draw commands.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_state_before_step_and_repeat(self) -> None:
    """Add new command buffer for block aperture draw commands."""
    self.state_before_step_and_repeat = self.state

reset_state_to_pre_step_and_repeat

reset_state_to_pre_step_and_repeat() -> None

Set state to state before step and repeat.

Source code in src/pygerber/gerberx3/parser2/context2.py
def reset_state_to_pre_step_and_repeat(self) -> None:
    """Set state to state before step and repeat."""
    self.set_state(self.get_state_before_step_and_repeat())

get_macro_statement_buffer

get_macro_statement_buffer() -> StatementBuffer2

Return macro statement buffer.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_macro_statement_buffer(self) -> StatementBuffer2:
    """Return macro statement buffer."""
    if self.macro_statement_buffer is None:
        raise MacroNotInitializedError(self.current_token)
    return self.macro_statement_buffer

set_macro_statement_buffer

set_macro_statement_buffer() -> None

Add new command buffer for block aperture draw commands.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_macro_statement_buffer(self) -> None:
    """Add new command buffer for block aperture draw commands."""
    self.macro_statement_buffer = (
        StatementBuffer2()
        if self.options.initial_macro_statement_buffer is None
        else self.options.initial_macro_statement_buffer
    )

unset_macro_statement_buffer

unset_macro_statement_buffer() -> None

Unset step and repeat command buffer.

Source code in src/pygerber/gerberx3/parser2/context2.py
def unset_macro_statement_buffer(self) -> None:
    """Unset step and repeat command buffer."""
    self.macro_statement_buffer = None

get_macro_eval_buffer

get_macro_eval_buffer() -> CommandBuffer2

Return macro evaluation buffer.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_macro_eval_buffer(self) -> CommandBuffer2:
    """Return macro evaluation buffer."""
    if self.macro_eval_buffer is None:
        raise MacroNotInitializedError(self.current_token)
    return self.macro_eval_buffer

set_macro_eval_buffer

set_macro_eval_buffer() -> None

Add new command buffer for block aperture draw commands.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_macro_eval_buffer(self) -> None:
    """Add new command buffer for block aperture draw commands."""
    self.macro_eval_buffer = (
        CommandBuffer2()
        if self.options.initial_macro_eval_buffer is None
        else self.options.initial_macro_eval_buffer
    )

unset_macro_eval_buffer

unset_macro_eval_buffer() -> None

Unset step and repeat command buffer.

Source code in src/pygerber/gerberx3/parser2/context2.py
def unset_macro_eval_buffer(self) -> None:
    """Unset step and repeat command buffer."""
    self.macro_eval_buffer = None

skip_token

skip_token() -> NoReturn

Skip this token.

Source code in src/pygerber/gerberx3/parser2/context2.py
def skip_token(self) -> NoReturn:
    """Skip this token."""
    raise SkipTokenInterrupt

halt_parser

halt_parser() -> NoReturn

Halt parsing process.

Source code in src/pygerber/gerberx3/parser2/context2.py
def halt_parser(self) -> NoReturn:
    """Halt parsing process."""
    raise ExitParsingProcess2Interrupt

get_hooks

get_hooks() -> Parser2HooksBase

Get hooks object.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_hooks(self) -> Parser2HooksBase:
    """Get hooks object."""
    return self.hooks

get_current_token

get_current_token() -> Optional[Token]

Get current token object.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_current_token(self) -> Optional[Token]:
    """Get current token object."""
    return self.current_token

set_current_token

set_current_token(token: Token) -> None

Get current token object.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_current_token(self, token: Token) -> None:
    """Get current token object."""
    self.current_token = token

set_state

set_state(state: State2) -> None

Set parser state.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_state(self, state: State2) -> None:
    """Set parser state."""
    self.state = state

add_command

add_command(__command: Command2) -> None

Add draw command to command buffer.

Source code in src/pygerber/gerberx3/parser2/context2.py
def add_command(self, __command: Command2) -> None:
    """Add draw command to command buffer."""
    if self.get_is_region():
        self.get_region_command_buffer().add_command(__command)
        return

    if self.get_is_aperture_block():
        self.first_block_command_buffer().add_command(__command)
        return

    if self.get_is_step_and_repeat():
        self.get_step_and_repeat_command_buffer().add_command(__command)
        return

    self.main_command_buffer.add_command(__command)

get_state

get_state() -> State2

Get parser state.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_state(self) -> State2:
    """Get parser state."""
    return self.state

get_draw_units

get_draw_units() -> Unit

Get draw_units property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_draw_units(self) -> Unit:
    """Get draw_units property value."""
    return self.get_state().get_draw_units()

set_draw_units

set_draw_units(draw_units: Unit) -> None

Set the draw_units property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_draw_units(self, draw_units: Unit) -> None:
    """Set the draw_units property value."""
    return self.set_state(self.get_state().set_draw_units(draw_units))

get_coordinate_parser

get_coordinate_parser() -> CoordinateParser

Get coordinate_parser property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_coordinate_parser(self) -> CoordinateParser:
    """Get coordinate_parser property value."""
    return self.get_state().get_coordinate_parser()

set_coordinate_parser

set_coordinate_parser(
    coordinate_parser: CoordinateParser,
) -> None

Set the coordinate_parser property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_coordinate_parser(self, coordinate_parser: CoordinateParser) -> None:
    """Set the coordinate_parser property value."""
    return self.set_state(
        self.get_state().set_coordinate_parser(coordinate_parser),
    )

get_polarity

get_polarity() -> Polarity

Get polarity property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_polarity(self) -> Polarity:
    """Get polarity property value."""
    return self.get_state().get_polarity()

set_polarity

set_polarity(polarity: Polarity) -> None

Set the polarity property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_polarity(self, polarity: Polarity) -> None:
    """Set the polarity property value."""
    return self.set_state(self.get_state().set_polarity(polarity))

get_mirroring

get_mirroring() -> Mirroring

Get mirroring property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_mirroring(self) -> Mirroring:
    """Get mirroring property value."""
    return self.get_state().get_mirroring()

set_mirroring

set_mirroring(mirroring: Mirroring) -> None

Set the mirroring property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_mirroring(self, mirroring: Mirroring) -> None:
    """Set the mirroring property value."""
    return self.set_state(self.get_state().set_mirroring(mirroring))

get_rotation

get_rotation() -> Decimal

Get rotation property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_rotation(self) -> Decimal:
    """Get rotation property value."""
    return self.get_state().get_rotation()

set_rotation

set_rotation(rotation: Decimal) -> None

Set the rotation property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_rotation(self, rotation: Decimal) -> None:
    """Set the rotation property value."""
    return self.set_state(self.get_state().set_rotation(rotation))

get_scaling

get_scaling() -> Decimal

Get scaling property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_scaling(self) -> Decimal:
    """Get scaling property value."""
    return self.get_state().get_scaling()

set_scaling

set_scaling(scaling: Decimal) -> None

Set the scaling property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_scaling(self, scaling: Decimal) -> None:
    """Set the scaling property value."""
    return self.set_state(self.get_state().set_scaling(scaling))

get_is_output_image_negation_required

get_is_output_image_negation_required() -> bool

Get is_output_image_negation_required property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_is_output_image_negation_required(self) -> bool:
    """Get is_output_image_negation_required property value."""
    return self.get_state().get_is_output_image_negation_required()

set_is_output_image_negation_required

set_is_output_image_negation_required(
    *, value: bool
) -> None

Set the is_output_image_negation_required property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_is_output_image_negation_required(self, *, value: bool) -> None:
    """Set the is_output_image_negation_required property value."""
    return self.set_state(
        self.get_state().set_is_output_image_negation_required(value),
    )

get_image_name

get_image_name() -> Optional[str]

Get image_name property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_image_name(self) -> Optional[str]:
    """Get image_name property value."""
    return self.get_state().get_image_name()

set_image_name

set_image_name(image_name: Optional[str]) -> None

Set the image_name property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_image_name(self, image_name: Optional[str]) -> None:
    """Set the image_name property value."""
    return self.set_state(self.get_state().set_image_name(image_name))

get_file_name

get_file_name() -> Optional[str]

Get file_name property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_file_name(self) -> Optional[str]:
    """Get file_name property value."""
    return self.get_state().get_file_name()

set_file_name

set_file_name(file_name: Optional[str]) -> None

Set the file_name property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_file_name(self, file_name: Optional[str]) -> None:
    """Set the file_name property value."""
    return self.set_state(self.get_state().set_file_name(file_name))

get_axis_correspondence

get_axis_correspondence() -> AxisCorrespondence

Get axis_correspondence property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_axis_correspondence(self) -> AxisCorrespondence:
    """Get axis_correspondence property value."""
    return self.get_state().get_axis_correspondence()

set_axis_correspondence

set_axis_correspondence(
    axis_correspondence: AxisCorrespondence,
) -> None

Set the axis_correspondence property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_axis_correspondence(self, axis_correspondence: AxisCorrespondence) -> None:
    """Set the axis_correspondence property value."""
    return self.set_state(
        self.get_state().set_axis_correspondence(axis_correspondence),
    )

get_draw_mode

get_draw_mode() -> DrawMode

Get draw_mode property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_draw_mode(self) -> DrawMode:
    """Get draw_mode property value."""
    return self.get_state().get_draw_mode()

set_draw_mode

set_draw_mode(draw_mode: DrawMode) -> None

Set the draw_mode property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_draw_mode(self, draw_mode: DrawMode) -> None:
    """Set the draw_mode property value."""
    return self.set_state(self.get_state().set_draw_mode(draw_mode))

get_is_region

get_is_region() -> bool

Get is_region property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_is_region(self) -> bool:
    """Get is_region property value."""
    return self.get_state().get_is_region()

set_is_region

set_is_region(is_region: bool) -> None

Set the is_region property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_is_region(self, is_region: bool) -> None:  # noqa: FBT001
    """Set the is_region property value."""
    return self.set_state(self.get_state().set_is_region(is_region))

get_is_aperture_block

get_is_aperture_block() -> bool

Get is_aperture_block property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_is_aperture_block(self) -> bool:
    """Get is_aperture_block property value."""
    return self.get_state().get_is_aperture_block()

set_is_aperture_block

set_is_aperture_block(is_aperture_block: bool) -> None

Set the is_aperture_block property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_is_aperture_block(self, is_aperture_block: bool) -> None:  # noqa: FBT001
    """Set the is_aperture_block property value."""
    return self.set_state(
        self.get_state().set_is_aperture_block(is_aperture_block),
    )

get_aperture_block_id

get_aperture_block_id() -> Optional[ApertureID]

Get is_aperture_block property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_aperture_block_id(self) -> Optional[ApertureID]:
    """Get is_aperture_block property value."""
    return self.get_state().get_aperture_block_id()

set_aperture_block_id

set_aperture_block_id(
    aperture_block_id: Optional[ApertureID],
) -> None

Set the is_aperture_block property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_aperture_block_id(self, aperture_block_id: Optional[ApertureID]) -> None:
    """Set the is_aperture_block property value."""
    return self.set_state(
        self.get_state().set_aperture_block_id(aperture_block_id),
    )

get_is_multi_quadrant

get_is_multi_quadrant() -> bool

Get is_aperture_block property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_is_multi_quadrant(self) -> bool:
    """Get is_aperture_block property value."""
    return self.get_state().get_is_multi_quadrant()

set_is_multi_quadrant

set_is_multi_quadrant(is_multi_quadrant: bool) -> None

Set the is_aperture_block property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_is_multi_quadrant(self, is_multi_quadrant: bool) -> None:  # noqa: FBT001
    """Set the is_aperture_block property value."""
    return self.set_state(
        self.get_state().set_is_multi_quadrant(is_multi_quadrant),
    )

get_is_step_and_repeat

get_is_step_and_repeat() -> bool

Get is_step_and_repeat property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_is_step_and_repeat(self) -> bool:
    """Get is_step_and_repeat property value."""
    return self.get_state().get_is_step_and_repeat()

set_is_step_and_repeat

set_is_step_and_repeat(is_step_and_repeat: bool) -> None

Set the is_step_and_repeat property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_is_step_and_repeat(self, is_step_and_repeat: bool) -> None:  # noqa: FBT001
    """Set the is_step_and_repeat property value."""
    return self.set_state(
        self.get_state().set_is_step_and_repeat(is_step_and_repeat),
    )

get_x_repeat

get_x_repeat() -> int

Get x_step property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_x_repeat(self) -> int:
    """Get x_step property value."""
    return self.get_state().get_x_repeat()

set_x_repeat

set_x_repeat(x_repeat: int) -> None

Set the x_repeat property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_x_repeat(self, x_repeat: int) -> None:
    """Set the x_repeat property value."""
    return self.set_state(self.get_state().set_x_repeat(x_repeat))

get_y_repeat

get_y_repeat() -> int

Get y_step property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_y_repeat(self) -> int:
    """Get y_step property value."""
    return self.get_state().get_y_repeat()

set_y_repeat

set_y_repeat(y_repeat: int) -> None

Set the y_repeat property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_y_repeat(self, y_repeat: int) -> None:
    """Set the y_repeat property value."""
    return self.set_state(self.get_state().set_y_repeat(y_repeat))

get_x_step

get_x_step() -> Offset

Get x_step property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_x_step(self) -> Offset:
    """Get x_step property value."""
    return self.get_state().get_x_step()

set_x_step

set_x_step(x_step: Offset) -> None

Set the x_step property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_x_step(self, x_step: Offset) -> None:
    """Set the x_step property value."""
    return self.set_state(self.get_state().set_x_step(x_step))

get_y_step

get_y_step() -> Offset

Get y_step property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_y_step(self) -> Offset:
    """Get y_step property value."""
    return self.get_state().get_y_step()

set_y_step

set_y_step(y_step: Offset) -> None

Set the y_step property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_y_step(self, y_step: Offset) -> None:
    """Set the y_step property value."""
    return self.set_state(self.get_state().set_y_step(y_step))

get_current_position

get_current_position() -> Vector2D

Get current_position property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_current_position(self) -> Vector2D:
    """Get current_position property value."""
    return self.get_state().get_current_position()

set_current_position

set_current_position(current_position: Vector2D) -> None

Set the current_position property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_current_position(self, current_position: Vector2D) -> None:
    """Set the current_position property value."""
    return self.set_state(
        self.get_state().set_current_position(current_position),
    )

get_current_aperture_id

get_current_aperture_id() -> Optional[ApertureID]

Get current_aperture property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_current_aperture_id(self) -> Optional[ApertureID]:
    """Get current_aperture property value."""
    current_aperture_id = self.get_state().get_current_aperture_id()
    if current_aperture_id is None and self.get_is_region():
        return REGION_OUTLINE_DEFAULT_APERTURE_ID

    return current_aperture_id

set_current_aperture_id

set_current_aperture_id(
    current_aperture: Optional[ApertureID],
) -> None

Set the current_aperture property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_current_aperture_id(self, current_aperture: Optional[ApertureID]) -> None:
    """Set the current_aperture property value."""
    return self.set_state(
        self.get_state().set_current_aperture_id(current_aperture),
    )

get_aperture

get_aperture(__key: ApertureID) -> Aperture2

Get apertures property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_aperture(self, __key: ApertureID) -> Aperture2:
    """Get apertures property value."""
    try:
        return self.apertures[__key]
    except KeyError as e:
        raise ApertureNotDefined2Error(self.current_token) from e

set_aperture

set_aperture(__key: ApertureID, __value: Aperture2) -> None

Set the apertures property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_aperture(self, __key: ApertureID, __value: Aperture2) -> None:
    """Set the apertures property value."""
    self.apertures[__key] = __value

get_macro

get_macro(__key: str) -> ApertureMacro2

Get macro property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_macro(self, __key: str) -> ApertureMacro2:
    """Get macro property value."""
    try:
        return self.get_state().get_macro(__key)
    except KeyError as e:
        raise MacroNotDefinedError(self.current_token) from e

set_macro

set_macro(__key: str, __value: ApertureMacro2) -> None

Set the macro property value.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_macro(self, __key: str, __value: ApertureMacro2) -> None:
    """Set the macro property value."""
    return self.set_state(self.get_state().set_macro(__key, __value))

set_reached_program_stop

set_reached_program_stop() -> None

Set flag indicating that M00 token was reached.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_reached_program_stop(self) -> None:
    """Set flag indicating that M00 token was reached."""
    self.reached_program_stop = True

get_reached_program_stop

get_reached_program_stop() -> bool

Get flag indicating that M00 token was reached.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_reached_program_stop(self) -> bool:
    """Get flag indicating that M00 token was reached."""
    return self.reached_program_stop

set_reached_optional_stop

set_reached_optional_stop() -> None

Set flag indicating that M01 token was reached.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_reached_optional_stop(self) -> None:
    """Set flag indicating that M01 token was reached."""
    self.reached_optional_stop = True

get_reached_optional_stop

get_reached_optional_stop() -> bool

Get flag indicating that M01 token was reached.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_reached_optional_stop(self) -> bool:
    """Get flag indicating that M01 token was reached."""
    return self.reached_optional_stop

set_reached_end_of_file

set_reached_end_of_file() -> None

Set flag indicating that M02 end of file was reached.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_reached_end_of_file(self) -> None:
    """Set flag indicating that M02 end of file was reached."""
    self.reached_end_of_file = True

get_reached_end_of_file

get_reached_end_of_file() -> bool

Get flag indicating that M02 end of file was reached.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_reached_end_of_file(self) -> bool:
    """Get flag indicating that M02 end of file was reached."""
    return self.reached_end_of_file

get_file_attribute

get_file_attribute(key: str) -> Optional[str]

Get file attributes property.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_file_attribute(self, key: str) -> Optional[str]:
    """Get file attributes property."""
    return self.file_attributes.get(key)

delete_file_attribute

delete_file_attribute(key: str) -> None

Get file attributes property.

Source code in src/pygerber/gerberx3/parser2/context2.py
def delete_file_attribute(self, key: str) -> None:
    """Get file attributes property."""
    self.file_attributes = self.file_attributes.delete(key)

set_file_attribute

set_file_attribute(key: str, value: Optional[str]) -> None

Set file attributes property.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_file_attribute(self, key: str, value: Optional[str]) -> None:
    """Set file attributes property."""
    self.file_attributes = self.file_attributes.update(key, value)

get_aperture_attribute

get_aperture_attribute(key: str) -> Optional[str]

Get aperture attributes property.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_aperture_attribute(self, key: str) -> Optional[str]:
    """Get aperture attributes property."""
    return self.aperture_attributes.get(key)

delete_aperture_attribute

delete_aperture_attribute(key: str) -> None

Delete aperture attributes property.

Source code in src/pygerber/gerberx3/parser2/context2.py
def delete_aperture_attribute(self, key: str) -> None:
    """Delete aperture attributes property."""
    self.aperture_attributes = self.aperture_attributes.delete(key)

clear_aperture_attributes

clear_aperture_attributes() -> None

Clear aperture attributes property.

Source code in src/pygerber/gerberx3/parser2/context2.py
def clear_aperture_attributes(self) -> None:
    """Clear aperture attributes property."""
    self.aperture_attributes = ApertureAttributes()

set_aperture_attribute

set_aperture_attribute(
    key: str, value: Optional[str]
) -> None

Set aperture attributes property.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_aperture_attribute(self, key: str, value: Optional[str]) -> None:
    """Set aperture attributes property."""
    self.aperture_attributes = self.aperture_attributes.update(key, value)

get_object_attribute

get_object_attribute(key: str) -> Optional[str]

Get object attributes property.

Source code in src/pygerber/gerberx3/parser2/context2.py
def get_object_attribute(self, key: str) -> Optional[str]:
    """Get object attributes property."""
    return self.object_attributes.get(key)

delete_object_attribute

delete_object_attribute(key: str) -> None

Delete object attributes property.

Source code in src/pygerber/gerberx3/parser2/context2.py
def delete_object_attribute(self, key: str) -> None:
    """Delete object attributes property."""
    self.object_attributes = self.object_attributes.delete(key)

set_object_attribute

set_object_attribute(
    key: str, value: Optional[str]
) -> None

Set object attributes property.

Source code in src/pygerber/gerberx3/parser2/context2.py
def set_object_attribute(self, key: str, value: Optional[str]) -> None:
    """Set object attributes property."""
    self.object_attributes = self.object_attributes.update(key, value)

clear_object_attributes

clear_object_attributes() -> None

Clear object attributes property.

Source code in src/pygerber/gerberx3/parser2/context2.py
def clear_object_attributes(self) -> None:
    """Clear object attributes property."""
    self.object_attributes = ObjectAttributes()

Parser2ContextMacroExpressionFactories dataclass

Collection of factories for all macro expressions.

Source code in src/pygerber/gerberx3/parser2/context2.py
@dataclass
class Parser2ContextMacroExpressionFactories:
    """Collection of factories for all macro expressions."""

    constant: Type[Constant2] = Constant2
    variable_name: Type[VariableName2] = VariableName2
    addition: Type[Addition2] = Addition2
    subtraction: Type[Subtraction2] = Subtraction2
    multiplication: Type[Multiplication2] = Multiplication2
    division: Type[Division2] = Division2
    negation: Type[Negation2] = Negation2
    positive: Type[Positive2] = Positive2

Parser2ContextOptions

Bases: FrozenGeneralModel

Options for Parser2Context.

Source code in src/pygerber/gerberx3/parser2/context2.py
class Parser2ContextOptions(FrozenGeneralModel):
    """Options for Parser2Context."""

    initial_state: Optional[State2] = Field(default=None)
    initial_main_command_buffer: Optional[CommandBuffer2] = Field(default=None)
    initial_region_command_buffer: Optional[CommandBuffer2] = Field(default=None)
    initial_block_command_buffer: Optional[CommandBuffer2] = Field(default=None)
    initial_macro_statement_buffer: Optional[StatementBuffer2] = Field(default=None)
    initial_macro_eval_buffer: Optional[CommandBuffer2] = Field(default=None)
    custom_macro_expression_factories: Optional[
        Parser2ContextMacroExpressionFactories
    ] = Field(
        default=None,
    )
    hooks: Optional[Parser2HooksBase] = Field(default=None)