Allow 3 digits on Excellon tool selection

Fritzing uses more than 2 digits for tool in their Excellons. To comply
with that, I check specifically for 3 or less digits and use as tool
number, more than that we treat as the standard (2 for tool and 2 for
compensation index)
refactor
Paulo Henrique Silva 2015-04-27 03:58:39 -03:00
rodzic e34e1078b6
commit 21d963d244
2 zmienionych plików z 10 dodań i 2 usunięć

Wyświetl plik

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

Wyświetl plik

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