Add Repeat Hole Stmt and fix UnitStmt parsing
* Repeat hole support (with no real parsing, just a copy) * Fix UnitStmt to works even when a ,TZ or ,LZ information is not provided.
This commit is contained in:
parent
137c73f3e4
commit
0f36084aad
2 changed files with 25 additions and 3 deletions
|
|
@ -204,8 +204,7 @@ class ExcellonParser(object):
|
|||
self.statements.append(DrillModeStmt())
|
||||
self.state = 'DRILL'
|
||||
|
||||
elif (('INCH' in line or 'METRIC' in line) and
|
||||
('LZ' in line or 'TZ' in line)):
|
||||
elif 'INCH' in line or 'METRIC' in line:
|
||||
stmt = UnitStmt.from_excellon(line)
|
||||
self.units = stmt.units
|
||||
self.zero_suppression = stmt.zero_suppression
|
||||
|
|
@ -244,6 +243,10 @@ class ExcellonParser(object):
|
|||
self.active_tool = self.tools[stmt.tool]
|
||||
self.statements.append(stmt)
|
||||
|
||||
elif line[0] == 'R' and self.state != 'HEADER':
|
||||
stmt = RepeatHoleStmt.from_excellon(line, self._settings())
|
||||
self.statements.append(stmt)
|
||||
|
||||
elif line[0] in ['X', 'Y']:
|
||||
stmt = CoordinateStmt.from_excellon(line, self._settings())
|
||||
x = stmt.x
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ __all__ = ['ExcellonTool', 'ToolSelectionStmt', 'CoordinateStmt',
|
|||
'RewindStopStmt', 'EndOfProgramStmt', 'UnitStmt',
|
||||
'IncrementalModeStmt', 'VersionStmt', 'FormatStmt', 'LinkToolStmt',
|
||||
'MeasuringModeStmt', 'RouteModeStmt', 'DrillModeStmt', 'AbsoluteModeStmt',
|
||||
'UnknownStmt',
|
||||
'RepeatHoleStmt', 'UnknownStmt',
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -280,6 +280,22 @@ class CoordinateStmt(ExcellonStatement):
|
|||
return '<Coordinate Statement: %s>' % coord_str
|
||||
|
||||
|
||||
class RepeatHoleStmt(ExcellonStatement):
|
||||
|
||||
@classmethod
|
||||
def from_excellon(cls, line, settings):
|
||||
return cls(line)
|
||||
|
||||
def __init__(self, line):
|
||||
self.line = line
|
||||
|
||||
def to_excellon(self, settings):
|
||||
return self.line
|
||||
|
||||
def __str__(self):
|
||||
return '<Repeat Hole: %s>' % self.line
|
||||
|
||||
|
||||
class CommentStmt(ExcellonStatement):
|
||||
|
||||
@classmethod
|
||||
|
|
@ -478,6 +494,9 @@ class UnknownStmt(ExcellonStatement):
|
|||
def to_excellon(self, settings=None):
|
||||
return self.stmt
|
||||
|
||||
def __str__(self):
|
||||
return "<UnknownStmt: %s >" % self.stmt
|
||||
|
||||
|
||||
def pairwise(iterator):
|
||||
""" Iterate over list taking two elements at a time.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue