From 242f4033c661d70c0d2722050370307f4d9b678a Mon Sep 17 00:00:00 2001 From: jaseg Date: Sat, 22 Jan 2022 19:26:48 +0100 Subject: Make excellon tests pass --- gerbonara/gerber/rs274x.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gerbonara/gerber/rs274x.py') diff --git a/gerbonara/gerber/rs274x.py b/gerbonara/gerber/rs274x.py index e986225..42e4230 100644 --- a/gerbonara/gerber/rs274x.py +++ b/gerbonara/gerber/rs274x.py @@ -464,7 +464,7 @@ class GerberParser: '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_definition': fr"ADD(?P\d+)(?PC|R|O|P|{NAME})(?P,[^,%]*)?$", 'aperture_macro': fr"AM(?P{NAME})\*(?P[^%]*)", 'region_start': r'G36', 'region_end': r'G37', @@ -536,7 +536,12 @@ class GerberParser: for name, le_regex in self.STATEMENT_REGEXES.items(): if (match := le_regex.match(line)): - getattr(self, f'_parse_{name}')(match.groupdict()) + try: + getattr(self, f'_parse_{name}')(match.groupdict()) + except: + print('Original line was:', line) + print(' match:', match) + raise line = line[match.end(0):] break @@ -627,7 +632,7 @@ class GerberParser: def _parse_aperture_definition(self, match): # number, shape, modifiers - modifiers = [ float(val) for val in match['modifiers'].split('X') ] if match['modifiers'].strip() else [] + modifiers = [ float(val) for val in match['modifiers'].strip(' ,').split('X') ] if match['modifiers'] else [] aperture_classes = { 'C': apertures.CircleAperture, -- cgit