summaryrefslogtreecommitdiff
path: root/gerber/gerber.py
diff options
context:
space:
mode:
authorHamilton Kibbe <ham@hamiltonkib.be>2014-09-29 13:35:10 -0400
committerHamilton Kibbe <ham@hamiltonkib.be>2014-09-29 13:35:10 -0400
commit1cb7856e88ce3d8ff7e725e9840b512b7d799e8d (patch)
tree137981618455d4556ad0366e502d260c7e4272c2 /gerber/gerber.py
parentc60a858c9c28b99bea270bc63bd6126fcb3ee20b (diff)
downloadgerbonara-1cb7856e88ce3d8ff7e725e9840b512b7d799e8d.tar.gz
gerbonara-1cb7856e88ce3d8ff7e725e9840b512b7d799e8d.tar.bz2
gerbonara-1cb7856e88ce3d8ff7e725e9840b512b7d799e8d.zip
Add CNC base classes and settings class
Diffstat (limited to 'gerber/gerber.py')
-rw-r--r--gerber/gerber.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/gerber/gerber.py b/gerber/gerber.py
index 949037b..eb5821c 100644
--- a/gerber/gerber.py
+++ b/gerber/gerber.py
@@ -27,6 +27,9 @@ This module provides an RS-274-X class and parser
import re
import json
from .statements import *
+from .cnc import CncFile, FileSettings
+
+
def read(filename):
@@ -35,7 +38,7 @@ def read(filename):
return GerberParser().parse(filename)
-class GerberFile(object):
+class GerberFile(CncFile):
""" A class representing a single gerber file
The GerberFile class represents a single gerber file.
@@ -68,9 +71,8 @@ class GerberFile(object):
"""
def __init__(self, statements, settings, filename=None):
- self.filename = filename
+ super(GerberFile, self).__init__(settings, filename)
self.statements = statements
- self.settings = settings
@property
def comments(self):
@@ -90,7 +92,8 @@ class GerberFile(object):
def bounds(self):
xbounds = [0.0, 0.0]
ybounds = [0.0, 0.0]
- for stmt in [stmt for stmt in self.statements if isinstance(stmt, CoordStmt)]:
+ for stmt in [stmt for stmt in self.statements
+ if isinstance(stmt, CoordStmt)]:
if stmt.x is not None and stmt.x < xbounds[0]:
xbounds[0] = stmt.x
if stmt.x is not None and stmt.x > xbounds[1]:
@@ -169,7 +172,7 @@ class GerberParser(object):
EOF_STMT = re.compile(r"(?P<eof>M02)\*")
def __init__(self):
- self.settings = {}
+ self.settings = FileSettings()
self.statements = []
def parse(self, filename):
@@ -240,13 +243,13 @@ class GerberParser(object):
if param:
if param["param"] == "FS":
stmt = FSParamStmt.from_dict(param)
- self.settings = {'zero_suppression': stmt.zero_suppression,
- 'format': stmt.format,
- 'notation': stmt.notation}
+ self.settings.zero_suppression = stmt.zero_suppression
+ self.settings.format = stmt.format
+ self.settings.notation = stmt.notation
yield stmt
elif param["param"] == "MO":
stmt = MOParamStmt.from_dict(param)
- self.settings['units'] = stmt.mode
+ self.settings.units = stmt.mode
yield stmt
elif param["param"] == "IP":
yield IPParamStmt.from_dict(param)