From c08457f7addf2001f07fac5d30091b33b3ddcb0c Mon Sep 17 00:00:00 2001 From: C4dmium <41113988+MarinMikael@users.noreply.github.com> Date: Thu, 1 Aug 2019 22:26:06 +0900 Subject: Update excellon_statements.py --- gerber/excellon_statements.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'gerber') diff --git a/gerber/excellon_statements.py b/gerber/excellon_statements.py index bcf35e4..2c50ef9 100644 --- a/gerber/excellon_statements.py +++ b/gerber/excellon_statements.py @@ -23,6 +23,7 @@ Excellon Statements import re import uuid +import itertools from .utils import (parse_gerber_value, write_gerber_value, decimal_string, inch, metric) @@ -151,8 +152,7 @@ class ExcellonTool(ExcellonStatement): tool : Tool An ExcellonTool representing the tool defined in `line` """ - commands = re.split('([BCFHSTZ])', line)[1:] - commands = [(command, value) for command, value in pairwise(commands)] + commands = pairwise(re.split('([BCFHSTZ])', line)[1:]) args = {} args['id'] = id nformat = settings.format @@ -973,6 +973,7 @@ def pairwise(iterator): e.g. [1, 2, 3, 4, 5, 6] ==> [(1, 2), (3, 4), (5, 6)] """ - itr = iter(iterator) - while True: - yield tuple([next(itr) for i in range(2)]) + a, b = itertools.tee(iterator) + itr = zip(itertools.islice(a, 0, None, 2), itertools.islice(b, 1, None, 2)) + for elem in itr: + yield elem -- cgit