summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gerber/excellon_statements.py9
-rw-r--r--gerber/tests/test_excellon_statements.py3
2 files changed, 10 insertions, 2 deletions
diff --git a/gerber/excellon_statements.py b/gerber/excellon_statements.py
index 53ea951..95347d1 100644
--- a/gerber/excellon_statements.py
+++ b/gerber/excellon_statements.py
@@ -234,9 +234,14 @@ class ToolSelectionStmt(ExcellonStatement):
"""
line = line[1:]
compensation_index = None
- tool = int(line[:2])
- if len(line) > 2:
+
+ # up to 3 characters for tool number (Frizting uses that)
+ if len(line) <= 3:
+ tool = int(line)
+ else:
+ tool = int(line[:2])
compensation_index = int(line[2:])
+
return cls(tool, compensation_index)
def __init__(self, tool, compensation_index=None):
diff --git a/gerber/tests/test_excellon_statements.py b/gerber/tests/test_excellon_statements.py
index 2da7c15..ada5194 100644
--- a/gerber/tests/test_excellon_statements.py
+++ b/gerber/tests/test_excellon_statements.py
@@ -111,6 +111,9 @@ def test_toolselection_factory():
stmt = ToolSelectionStmt.from_excellon('T0223')
assert_equal(stmt.tool, 2)
assert_equal(stmt.compensation_index, 23)
+ stmt = ToolSelectionStmt.from_excellon('T042')
+ assert_equal(stmt.tool, 42)
+ assert_equal(stmt.compensation_index, None)
def test_toolselection_dump():
""" Test ToolSelectionStmt to_excellon()