summaryrefslogtreecommitdiff
path: root/gerberex/rs274x.py
diff options
context:
space:
mode:
authoropiopan <opiopan@gmail.com>2019-03-21 22:00:32 +0900
committeropiopan <opiopan@gmail.com>2019-03-21 22:00:32 +0900
commit9febca7da6a730b3b3ca3a54129a9f88e5c44d14 (patch)
tree3f260096ab0c40eca527195630ab004208b4ee78 /gerberex/rs274x.py
downloadgerbonara-9febca7da6a730b3b3ca3a54129a9f88e5c44d14.tar.gz
gerbonara-9febca7da6a730b3b3ca3a54129a9f88e5c44d14.tar.bz2
gerbonara-9febca7da6a730b3b3ca3a54129a9f88e5c44d14.zip
initial commit
Diffstat (limited to 'gerberex/rs274x.py')
-rw-r--r--gerberex/rs274x.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/gerberex/rs274x.py b/gerberex/rs274x.py
new file mode 100644
index 0000000..e9d82cd
--- /dev/null
+++ b/gerberex/rs274x.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright 2019 Hiroshi Murayama <opiopan@gmail.com>
+
+import gerber.rs274x
+from gerberex.statements import (AMParamStmt, AMParamStmtEx)
+
+class GerberFile(gerber.rs274x.GerberFile):
+ @classmethod
+ def from_gerber_file(cls, gerber_file):
+ if not isinstance(gerber_file, gerber.rs274x.GerberFile):
+ raise Exception('only gerber.rs274x.GerberFile object is specified')
+
+ def swap_statement(statement):
+ if isinstance(statement, AMParamStmt) and not isinstance(statement, AMParamStmtEx):
+ return AMParamStmtEx.from_stmt(statement)
+ else:
+ return statement
+ statements = [swap_statement(statement) for statement in gerber_file.statements]
+ return cls(statements, gerber_file.settings, gerber_file.primitives,\
+ gerber_file.apertures, gerber_file.filename)
+
+ def __init__(self, statements, settings, primitives, apertures, filename=None):
+ super(GerberFile, self).__init__(statements, settings, primitives, apertures, filename)