diff options
author | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2014-10-11 13:12:21 -0400 |
---|---|---|
committer | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2014-10-11 13:12:21 -0400 |
commit | 62c689be172a7a06d76fd4b69c3443f3ec053765 (patch) | |
tree | 8297ff4e0a4fd3e37d7511280d20c2d01a79ac7f /gerber/excellon.py | |
parent | ae3bbff8b0849e0b49dc139396d7f8c57334a7b8 (diff) | |
download | gerbonara-62c689be172a7a06d76fd4b69c3443f3ec053765.tar.gz gerbonara-62c689be172a7a06d76fd4b69c3443f3ec053765.tar.bz2 gerbonara-62c689be172a7a06d76fd4b69c3443f3ec053765.zip |
Doc update
Diffstat (limited to 'gerber/excellon.py')
-rwxr-xr-x | gerber/excellon.py | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/gerber/excellon.py b/gerber/excellon.py index 1a498dc..f5d6c29 100755 --- a/gerber/excellon.py +++ b/gerber/excellon.py @@ -30,6 +30,15 @@ import math def read(filename):
""" Read data from filename and return an ExcellonFile
+ Parameters
+ ----------
+ filename : string
+ Filename of file to parse
+
+ Returns
+ -------
+ file : :class:`gerber.excellon.ExcellonFile`
+ An ExcellonFile created from the specified file.
"""
detected_settings = detect_excellon_format(filename)
settings = FileSettings(**detected_settings)
@@ -75,6 +84,14 @@ class ExcellonFile(CamFile): def render(self, ctx, filename=None):
""" Generate image of file
+
+ Parameters
+ ----------
+ ctx : :class:`gerber.render.GerberContext`
+ GerberContext subclass used for rendering the image
+
+ filename : string <optional>
+ If provided, the rendered image will be saved to `filename`
"""
for tool, pos in self.hits:
ctx.drill(pos[0], pos[1], tool.diameter)
@@ -89,7 +106,7 @@ class ExcellonFile(CamFile): class ExcellonParser(object):
""" Excellon File Parser
-
+
Parameters
----------
settings : FileSettings or dict-like
@@ -129,15 +146,15 @@ class ExcellonParser(object): ymin = y if y < ymin else ymin
ymax = y if y > ymax else ymax
return ((xmin, xmax), (ymin, ymax))
-
+
@property
def hole_sizes(self):
return [stmt.diameter for stmt in self.statements if isinstance(stmt, ExcellonTool)]
-
+
@property
def hole_count(self):
return len(self.hits)
-
+
def parse(self, filename):
with open(filename, 'r') as f:
for line in f:
@@ -316,7 +333,7 @@ def detect_excellon_format(filename): # Bail out here if we got everything....
if detected_format is not None and detected_zeros is not None:
return {'format': detected_format, 'zero_suppression': detected_zeros}
-
+
# Otherwise score each option and pick the best candidate
else:
scores = {}
@@ -338,4 +355,3 @@ def _layer_size_score(size, hole_count, hole_area): hole_score = (hole_percentage - 0.25) ** 2
size_score = (board_area - 8) **2
return hole_score * size_score
-
\ No newline at end of file |