summaryrefslogtreecommitdiff
path: root/gerber/utils.py
diff options
context:
space:
mode:
authorPaulo Henrique Silva <ph.silva@gmail.com>2015-01-14 14:31:03 -0200
committerPaulo Henrique Silva <ph.silva@gmail.com>2015-01-14 14:31:03 -0200
commitac89a3c36505bebff68305eb8e315482cba860fd (patch)
treeb24843afa282c27876c0df627103f08cebcb1638 /gerber/utils.py
parenta9b5a17c534247fe5c82c82b945305f3855b8bef (diff)
downloadgerbonara-ac89a3c36505bebff68305eb8e315482cba860fd.tar.gz
gerbonara-ac89a3c36505bebff68305eb8e315482cba860fd.tar.bz2
gerbonara-ac89a3c36505bebff68305eb8e315482cba860fd.zip
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.
Diffstat (limited to 'gerber/utils.py')
-rw-r--r--gerber/utils.py7
1 files changed, 5 insertions, 2 deletions
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)