Merge pull request #104 from MarinMikael/allow_float_fmt_and_fix_3.7

Allow float fmt and fix 3.7
This commit is contained in:
Paulo Henrique Silva 2019-11-25 11:30:53 -03:00 committed by GitHub
commit 2e32abef6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View file

@ -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

View file

@ -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