diff options
author | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2015-02-15 02:20:02 -0500 |
---|---|---|
committer | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2015-02-15 02:20:02 -0500 |
commit | 5cf1fa74b42eb8feaab23078bef6f31f6d647c33 (patch) | |
tree | 5758024d03d41fb9c8010314bbdb4f8f597db333 /gerber/excellon.py | |
parent | 5e23d07bcb5103b4607c6ad591a2a547c97ee1f6 (diff) | |
download | gerbonara-5cf1fa74b42eb8feaab23078bef6f31f6d647c33.tar.gz gerbonara-5cf1fa74b42eb8feaab23078bef6f31f6d647c33.tar.bz2 gerbonara-5cf1fa74b42eb8feaab23078bef6f31f6d647c33.zip |
Tests and bugfixes
Diffstat (limited to 'gerber/excellon.py')
-rwxr-xr-x | gerber/excellon.py | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/gerber/excellon.py b/gerber/excellon.py index 79a6e1f..87eaf03 100755 --- a/gerber/excellon.py +++ b/gerber/excellon.py @@ -95,11 +95,27 @@ class ExcellonFile(CamFile): ymax = max(y + radius, ymax)
return ((xmin, xmax), (ymin, ymax))
- def report(self):
- """ Print drill report
+ def report(self, filename=None):
+ """ Print or save drill report
"""
- pass
-
+ toolfmt = ' T%%02d %%%d.%df %%d\n' % self.settings.format
+ rprt = 'Excellon Drill Report\n\n'
+ if self.filename is not None:
+ rprt += 'NC Drill File: %s\n\n' % self.filename
+ rprt += 'Drill File Info:\n\n'
+ rprt += (' Data Mode %s\n' % 'Absolute'
+ if self.settings.notation == 'absolute' else 'Incremental')
+ rprt += (' Units %s\n' % 'Inches'
+ if self.settings.units == 'inch' else 'Millimeters')
+ rprt += '\nTool List:\n\n'
+ rprt += ' Code Size Hits\n'
+ rprt += ' --------------------------\n'
+ for tool in self.tools.itervalues():
+ rprt += toolfmt % (tool.number, tool.diameter, tool.hit_count)
+ if filename is not None:
+ with open(filename, 'w') as f:
+ f.write(rprt)
+ return rprt
def write(self, filename):
with open(filename, 'w') as f:
@@ -195,7 +211,7 @@ class ExcellonParser(object): self.state = 'DRILL'
elif line[:3] == 'M30':
- stmt = EndOfProgramStmt.from_excellon(line)
+ stmt = EndOfProgramStmt.from_excellon(line, self._settings())
self.statements.append(stmt)
elif line[:3] == 'G00':
@@ -230,8 +246,9 @@ class ExcellonParser(object): stmt = FormatStmt.from_excellon(line)
self.statements.append(stmt)
- elif line[:4] == 'G90':
+ elif line[:3] == 'G90':
self.statements.append(AbsoluteModeStmt())
+ self.notation = 'absolute'
elif line[0] == 'T' and self.state == 'HEADER':
tool = ExcellonTool.from_excellon(line, self._settings())
|