summaryrefslogtreecommitdiff
path: root/gerber/excellon_statements.py
diff options
context:
space:
mode:
authorPaulo Henrique Silva <ph.silva@gmail.com>2019-11-25 23:46:31 -0300
committerGitHub <noreply@github.com>2019-11-25 23:46:31 -0300
commit25b82c988578482fbb57f80d3d30bdf985a9a885 (patch)
tree2a6f89a2e0278072b2a69733820a78e1ba017797 /gerber/excellon_statements.py
parent9cc42d9b7752603ae409e7c95a8cb5bec4d7b5b2 (diff)
parentcee1fcff3ac8c15e8888dd0d4738c3c7f1db196d (diff)
downloadgerbonara-25b82c988578482fbb57f80d3d30bdf985a9a885.tar.gz
gerbonara-25b82c988578482fbb57f80d3d30bdf985a9a885.tar.bz2
gerbonara-25b82c988578482fbb57f80d3d30bdf985a9a885.zip
Merge branch 'master' into script
Diffstat (limited to 'gerber/excellon_statements.py')
-rw-r--r--gerber/excellon_statements.py11
1 files changed, 6 insertions, 5 deletions
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