summaryrefslogtreecommitdiff
path: root/gerber/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'gerber/common.py')
-rw-r--r--gerber/common.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/gerber/common.py b/gerber/common.py
index 1659e3b..04b6423 100644
--- a/gerber/common.py
+++ b/gerber/common.py
@@ -17,9 +17,12 @@
from . import rs274x
from . import excellon
+from . import ipc356
+from .exceptions import ParseError
from .utils import detect_file_format
+
def read(filename):
""" Read a gerber or excellon file and return a representative object.
@@ -35,14 +38,17 @@ def read(filename):
ExcellonFile. Returns None if file is not an Excellon or Gerber file.
"""
with open(filename, 'rU') as f:
- data = f.read()
+ data = f.read()
fmt = detect_file_format(data)
if fmt == 'rs274x':
return rs274x.read(filename)
elif fmt == 'excellon':
return excellon.read(filename)
+ elif fmt == 'ipc_d_356':
+ return ipc356.read(filename)
else:
- raise TypeError('Unable to detect file format')
+ raise ParseError('Unable to detect file format')
+
def loads(data):
""" Read gerber or excellon file contents from a string and return a
@@ -59,7 +65,7 @@ def loads(data):
CncFile object representing the file, either GerberFile or
ExcellonFile. Returns None if file is not an Excellon or Gerber file.
"""
-
+
fmt = detect_file_format(data)
if fmt == 'rs274x':
return rs274x.loads(data)