summaryrefslogtreecommitdiff
path: root/gerber
diff options
context:
space:
mode:
authorPaulo Henrique Silva <ph.silva@gmail.com>2019-11-25 23:35:43 -0300
committerGitHub <noreply@github.com>2019-11-25 23:35:43 -0300
commit7125380c1ad7bdc09646c538928a48c9f559b505 (patch)
tree250b6e40166f553a1123ab7ac2e866e5080ac64e /gerber
parent37dfd86368d080534eeefec9f726cae9e5f03e7e (diff)
parenta40de7b827d308c0dd20dd77d948afb316cfc551 (diff)
downloadgerbonara-7125380c1ad7bdc09646c538928a48c9f559b505.tar.gz
gerbonara-7125380c1ad7bdc09646c538928a48c9f559b505.tar.bz2
gerbonara-7125380c1ad7bdc09646c538928a48c9f559b505.zip
Merge branch 'master' into outline
Diffstat (limited to 'gerber')
-rw-r--r--gerber/excellon_statements.py11
-rw-r--r--gerber/utils.py4
2 files changed, 10 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
diff --git a/gerber/utils.py b/gerber/utils.py
index 817a36e..3d39df9 100644
--- a/gerber/utils.py
+++ b/gerber/utils.py
@@ -123,6 +123,10 @@ def write_gerber_value(value, format=(2, 5), zero_suppression='trailing'):
value : string
The specified value as a Gerber/Excellon-formatted string.
"""
+
+ if format[0] == float:
+ return "%f" %value
+
# Format precision
integer_digits, decimal_digits = format
MAX_DIGITS = integer_digits + decimal_digits