From 4f076d7b769b0f488888d268a9a199b7545afdd7 Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Sun, 26 Oct 2014 17:59:57 -0400 Subject: Merge aperture fixses from upstream --- gerber/gerber_statements.py | 8 ++++---- gerber/rs274x.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gerber/gerber_statements.py b/gerber/gerber_statements.py index 44eeee0..e392ec5 100644 --- a/gerber/gerber_statements.py +++ b/gerber/gerber_statements.py @@ -308,9 +308,6 @@ class ADParamStmt(ParamStmt): d = int(stmt_dict.get('d')) shape = stmt_dict.get('shape') modifiers = stmt_dict.get('modifiers') - if modifiers is not None: - modifiers = [[float(x) for x in m.split('X')] - for m in modifiers.split(',')] return cls(param, d, shape, modifiers) def __init__(self, param, d, shape, modifiers): @@ -339,7 +336,10 @@ class ADParamStmt(ParamStmt): ParamStmt.__init__(self, param) self.d = d self.shape = shape - self.modifiers = modifiers + if modifiers is not None: + self.modifiers = [[x for x in m.split("X")] for m in modifiers.split(",")] + else: + self.modifiers = [] def to_gerber(self, settings): return '%ADD{0}{1},{2}*%'.format(self.d, self.shape, diff --git a/gerber/rs274x.py b/gerber/rs274x.py index 739c253..f18a35d 100644 --- a/gerber/rs274x.py +++ b/gerber/rs274x.py @@ -118,7 +118,7 @@ class GerberParser(object): NUMBER = r"[\+-]?\d+" DECIMAL = r"[\+-]?\d+([.]?\d+)?" STRING = r"[a-zA-Z0-9_+\-/!?<>”’(){}.\|&@# :]+" - NAME = "[a-zA-Z_$][a-zA-Z_$0-9]+" + NAME = r"[a-zA-Z_$][a-zA-Z_$0-9]+" FUNCTION = r"G\d{2}" COORD_OP = r"D[0]?[123]" @@ -128,10 +128,10 @@ class GerberParser(object): IP = r"(?PIP)(?P(POS|NEG))" LP = r"(?PLP)(?P(D|C))" AD_CIRCLE = r"(?PAD)D(?P\d+)(?PC)[,](?P[^,]*)" - AD_RECT = r"(?PAD)D(?P\d+)(?PR)[,](?P[^,]*)" + AD_RECT = r"(?PAD)D(?P\d+)(?PR)[,]?(?P[^,]+)?" AD_OBROUND = r"(?PAD)D(?P\d+)(?PO)[,](?P[^,]*)" AD_POLY = r"(?PAD)D(?P\d+)(?PP)[,](?P[^,]*)" - AD_MACRO = r"(?PAD)D(?P\d+)+(?P{name})[,](?P[^,]*)".format(name=NAME) + AD_MACRO = r"(?PAD)D(?P\d+)(?P{name})[,]?(?P[^,]+)?".format(name=NAME) AM = r"(?PAM)(?P{name})\*(?P.*)".format(name=NAME) # begin deprecated @@ -140,7 +140,7 @@ class GerberParser(object): LN = r"(?PLN)(?P.*)" # end deprecated - PARAMS = (FS, MO, IP, LP, AD_CIRCLE, AD_RECT, AD_OBROUND, AD_MACRO, AD_POLY, AM, OF, IN, LN) + PARAMS = (FS, MO, IP, LP, AD_CIRCLE, AD_RECT, AD_OBROUND, AD_POLY, AD_MACRO, AM, OF, IN, LN) PARAM_STMT = [re.compile(r"%{0}\*%".format(p)) for p in PARAMS] COORD_STMT = re.compile(( -- cgit