summaryrefslogtreecommitdiff
path: root/gerber/parser.py
diff options
context:
space:
mode:
authorhamiltonkibbe <hamilton.kibbe@gmail.com>2014-09-25 00:09:32 -0400
committerhamiltonkibbe <hamilton.kibbe@gmail.com>2014-09-25 00:09:32 -0400
commitd3af7515eb559d4178f7f11537deb395f878b8db (patch)
tree6244b2baf018370e2e913c9865c4aa0fea9609a4 /gerber/parser.py
parentbd38028b01fdb6701195f023adfc72820a6f5ce5 (diff)
parent10d09512382df7ad512b5a528b6fe390373cd59d (diff)
downloadgerbonara-d3af7515eb559d4178f7f11537deb395f878b8db.tar.gz
gerbonara-d3af7515eb559d4178f7f11537deb395f878b8db.tar.bz2
gerbonara-d3af7515eb559d4178f7f11537deb395f878b8db.zip
Merge pull request #1 from hamiltonkibbe/context_refactor
Move evaluate methods to GerberContext class
Diffstat (limited to 'gerber/parser.py')
-rw-r--r--gerber/parser.py48
1 files changed, 1 insertions, 47 deletions
diff --git a/gerber/parser.py b/gerber/parser.py
index 5dc3a73..8f89211 100644
--- a/gerber/parser.py
+++ b/gerber/parser.py
@@ -242,7 +242,7 @@ class GerberParser(object):
for stmt in self._parse(data):
self.statements.append(stmt)
if self.ctx:
- self._evaluate(stmt)
+ self.ctx.evaluate(stmt)
def dump_json(self):
stmts = {"statements": [stmt.__dict__ for stmt in self.statements]}
@@ -361,49 +361,3 @@ class GerberParser(object):
return (match.groupdict(), data[match.end(0):])
return ({}, None)
-
-
- # really this all belongs in another class - the GerberContext class
- def _evaluate(self, stmt):
- if isinstance(stmt, (CommentStmt, UnknownStmt, EofStmt)):
- return
-
- elif isinstance(stmt, ParamStmt):
- self._evaluate_param(stmt)
-
- elif isinstance(stmt, CoordStmt):
- self._evaluate_coord(stmt)
-
- elif isinstance(stmt, ApertureStmt):
- self._evaluate_aperture(stmt)
-
- else:
- raise Exception("Invalid statement to evaluate")
-
- def _evaluate_param(self, stmt):
- if stmt.param == "FS":
- self.ctx.set_coord_format(stmt.zero, stmt.x, stmt.y)
- self.ctx.set_coord_notation(stmt.notation)
- elif stmt.param == "MO:":
- self.ctx.set_coord_unit(stmt.mo)
- elif stmt.param == "IP:":
- self.ctx.set_image_polarity(stmt.ip)
- elif stmt.param == "LP:":
- self.ctx.set_level_polarity(stmt.lp)
- elif stmt.param == "AD":
- self.ctx.define_aperture(stmt.d, stmt.shape, stmt.modifiers)
-
- def _evaluate_coord(self, stmt):
-
- if stmt.function in ("G01", "G1", "G02", "G2", "G03", "G3"):
- self.ctx.set_interpolation(stmt.function)
-
- if stmt.op == "D01":
- self.ctx.stroke(stmt.x, stmt.y)
- elif stmt.op == "D02":
- self.ctx.move(stmt.x, stmt.y)
- elif stmt.op == "D03":
- self.ctx.flash(stmt.x, stmt.y)
-
- def _evaluate_aperture(self, stmt):
- self.ctx.set_aperture(stmt.d)