summaryrefslogtreecommitdiff
path: root/gerber/excellon_statements.py
diff options
context:
space:
mode:
authorPaulo Henrique Silva <ph.silva@gmail.com>2019-11-25 15:45:47 -0300
committerGitHub <noreply@github.com>2019-11-25 15:45:47 -0300
commit0a45f0ae5770f5975d0f1c85d38cc737a00cc4d1 (patch)
tree4cc45b51f961285ac43ba429a174778f39bd86cc /gerber/excellon_statements.py
parentc87bad8dedc0ea2a52171840d24451e2117c8325 (diff)
parent2830fd268dbcdc52fdf67221a00e3a72cb4e9cb9 (diff)
downloadgerbonara-0a45f0ae5770f5975d0f1c85d38cc737a00cc4d1.tar.gz
gerbonara-0a45f0ae5770f5975d0f1c85d38cc737a00cc4d1.tar.bz2
gerbonara-0a45f0ae5770f5975d0f1c85d38cc737a00cc4d1.zip
Merge branch 'master' into patch-1
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