From ac89a3c36505bebff68305eb8e315482cba860fd Mon Sep 17 00:00:00 2001 From: Paulo Henrique Silva Date: Wed, 14 Jan 2015 14:31:03 -0200 Subject: Fix for cases whee the coordinate precision is decreased. If we parse a file with 5.5 INCH format and ask to write it back as 2.4 INCH we are going to loose precision and write_gerber_value was not handling these cases write. --- gerber/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gerber') diff --git a/gerber/utils.py b/gerber/utils.py index 0f0c07c..64cd6ed 100644 --- a/gerber/utils.py +++ b/gerber/utils.py @@ -140,12 +140,15 @@ def write_gerber_value(value, format=(2, 5), zero_suppression='trailing'): # Suppression... if zero_suppression == 'trailing': - while digits[-1] == '0': + while digits and digits[-1] == '0': digits.pop() else: - while digits[0] == '0': + while digits and digits[0] == '0': digits.pop(0) + if not digits: + return '0' + return ''.join(digits) if not negative else ''.join(['-'] + digits) -- cgit