From 4101815b2fac78be67c1cd8d8c6520d41dcac7cf Mon Sep 17 00:00:00 2001 From: jaseg Date: Sun, 23 Jan 2022 21:19:51 +0100 Subject: Fix more bugs --- gerbonara/gerber/rs274x.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'gerbonara/gerber/rs274x.py') diff --git a/gerbonara/gerber/rs274x.py b/gerbonara/gerber/rs274x.py index db93fb5..2e04d13 100644 --- a/gerbonara/gerber/rs274x.py +++ b/gerbonara/gerber/rs274x.py @@ -470,7 +470,13 @@ class GraphicsState: def set_interpolation_mode(self, mode): if self.interpolation_mode != mode: self.interpolation_mode = mode - yield {InterpMode.LINEAR: 'G01', InterpMode.CIRCULAR_CW: 'G02', InterpMode.CIRCULAR_CCW: 'G03'}[mode] + yield self.interpolation_mode_statement() + + def interpolation_mode_statement(self): + return { + InterpMode.LINEAR: 'G01', + InterpMode.CIRCULAR_CW: 'G02', + InterpMode.CIRCULAR_CCW: 'G03'}[self.interpolation_mode] class GerberParser: @@ -489,18 +495,18 @@ class GerberParser: 'allegro_format_spec': r"FS(?P(L|T|D))?(?P(A|I))[NG0-9]*X(?P[0-7][0-7])Y(?P[0-7][0-7])[DM0-9]*\*MO(?PIN|MM)", 'unit_mode': r"MO(?P(MM|IN))", 'format_spec': r"FS(?P(L|T|D))?(?P(A|I))[NG0-9]*X(?P[0-7][0-7])Y(?P[0-7][0-7])[DM0-9]*", - 'allegro_legacy_params': r'IR(?P[0-9]+)\*IP(?P(POS|NEG))\*OF(A(?P{DECIMAL}))?(B(?P{DECIMAL}))?\*MI(A(?P0|1))?(B(?P0|1))?\*SF(A(?P{DECIMAL}))?(B(?P{DECIMAL}))?', + 'allegro_legacy_params': fr'^IR(?P[0-9]+)\*IP(?P(POS|NEG))\*OF(A(?P{DECIMAL}))?(B(?P{DECIMAL}))?\*MI(A(?P0|1))?(B(?P0|1))?\*SF(A(?P{DECIMAL}))?(B(?P{DECIMAL}))?', 'load_polarity': r"LP(?P(D|C))", # FIXME LM, LR, LS 'load_name': r"LN(?P.*)", 'offset': fr"OF(A(?P{DECIMAL}))?(B(?P{DECIMAL}))?", 'include_file': r"IF(?P.*)", - 'image_name': r"IN(?P.*)", - 'axis_selection': r"AS(?PAXBY|AYBX)", - 'image_polarity': r"IP(?P(POS|NEG))", - 'image_rotation': fr"IR(?P{NUMBER})", - 'mirror_image': r"MI(A(?P0|1))?(B(?P0|1))?", - 'scale_factor': fr"SF(A(?P{DECIMAL}))?(B(?P{DECIMAL}))?", + 'image_name': r"^IN(?P.*)", + 'axis_selection': r"^AS(?PAXBY|AYBX)", + 'image_polarity': r"^IP(?P(POS|NEG))", + 'image_rotation': fr"^IR(?P{NUMBER})", + 'mirror_image': r"^MI(A(?P0|1))?(B(?P0|1))?", + 'scale_factor': fr"^SF(A(?P{DECIMAL}))?(B(?P{DECIMAL}))?", 'aperture_definition': fr"ADD(?P\d+)(?PC|R|O|P|{NAME})(?P,[^,%]*)?$", 'aperture_macro': fr"AM(?P{NAME})\*(?P[^%]*)", 'siemens_garbage': r'^ICAS$', @@ -810,7 +816,7 @@ class GerberParser: mirror = bool(int(match['ma'] or '0')), bool(int(match['mb'] or '1')) if mirror != (False, False): warnings.warn('Deprecated MI (mirror image) statement found. This deprecated since rev. I1 (Dec 2012).', DeprecationWarning) - self.graphics_state.mirror = mirror + self.graphics_state.image_mirror = mirror def _parse_scale_factor(self, match): a = float(match['sa']) if match['sa'] else 1.0 -- cgit