summaryrefslogtreecommitdiff
path: root/gerbonara/gerber/cam.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2022-01-29 21:05:31 +0100
committerjaseg <git@jaseg.de>2022-01-29 21:05:31 +0100
commitd5bbfade80f1927f2512b9f5bbb723255ec8926d (patch)
tree394ccd1bde86490c6df7e16f2d536534c41b30d3 /gerbonara/gerber/cam.py
parent1304847afe223661a574c0cd16d9a915c2bfa19f (diff)
downloadgerbonara-d5bbfade80f1927f2512b9f5bbb723255ec8926d.tar.gz
gerbonara-d5bbfade80f1927f2512b9f5bbb723255ec8926d.tar.bz2
gerbonara-d5bbfade80f1927f2512b9f5bbb723255ec8926d.zip
Fix IPC-356 tests
Diffstat (limited to 'gerbonara/gerber/cam.py')
-rw-r--r--gerbonara/gerber/cam.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/gerbonara/gerber/cam.py b/gerbonara/gerber/cam.py
index 83155bd..51612f4 100644
--- a/gerbonara/gerber/cam.py
+++ b/gerbonara/gerber/cam.py
@@ -80,12 +80,16 @@ class FileSettings:
def format_ipc_number(self, value, digits, key='', sign=False):
if value is None:
- return ' ' * (digits + 1 + len(key))
+ return ' ' * (digits + int(bool(sign)) + len(key))
if isinstance(value, Enum):
value = value.value
+ num = format(round(value), f'{"+" if sign else ""}0{digits+int(bool(sign))}d')
- return key + format(round(value), f'{"+" if sign else ""}0{digits+1}d')
+ if len(num) > digits + int(bool(sign)):
+ raise ValueError('Error: Number {num} to wide for IPC-356 field of width {digits}')
+
+ return key + num
def format_ipc_length(self, value, digits, key='', unit=None, sign=False):
if value is not None: