summaryrefslogtreecommitdiff
path: root/gerbonara/gerber/rs274x.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2022-01-22 19:26:48 +0100
committerjaseg <git@jaseg.de>2022-01-22 19:26:48 +0100
commit242f4033c661d70c0d2722050370307f4d9b678a (patch)
tree9076a1d0f45a76c49a465f74903071671006b6de /gerbonara/gerber/rs274x.py
parent7cf41c6a72e52a63b4f4d4497732a72d6623eec8 (diff)
downloadgerbonara-242f4033c661d70c0d2722050370307f4d9b678a.tar.gz
gerbonara-242f4033c661d70c0d2722050370307f4d9b678a.tar.bz2
gerbonara-242f4033c661d70c0d2722050370307f4d9b678a.zip
Make excellon tests pass
Diffstat (limited to 'gerbonara/gerber/rs274x.py')
-rw-r--r--gerbonara/gerber/rs274x.py11
1 files changed, 8 insertions, 3 deletions
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<rotation>{NUMBER})",
'mirror_image': r"MI(A(?P<a>0|1))?(B(?P<b>0|1))?",
'scale_factor': fr"SF(A(?P<a>{DECIMAL}))?(B(?P<b>{DECIMAL}))?",
- 'aperture_definition': fr"ADD(?P<number>\d+)(?P<shape>C|R|O|P|{NAME})[,]?(?P<modifiers>[^,%]*)",
+ 'aperture_definition': fr"ADD(?P<number>\d+)(?P<shape>C|R|O|P|{NAME})(?P<modifiers>,[^,%]*)?$",
'aperture_macro': fr"AM(?P<name>{NAME})\*(?P<macro>[^%]*)",
'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,