summaryrefslogtreecommitdiff
path: root/gerber/common.py
diff options
context:
space:
mode:
authorGarret Fick <garret@ficksworkshop.com>2016-07-17 10:42:03 +0800
committerGarret Fick <garret@ficksworkshop.com>2016-07-17 10:42:03 +0800
commit0dded38353e1d650458f6401aea37a4aadaf28ff (patch)
treea297c26c7cbb6b1c7d7a9cbe4eb4639b203fba53 /gerber/common.py
parentd0e9018da0d7c51c2195f641c9189f85378df3e8 (diff)
parentd1598b46c91ee36719460d49d7ba2ed5ecd0ef45 (diff)
downloadgerbonara-0dded38353e1d650458f6401aea37a4aadaf28ff.tar.gz
gerbonara-0dded38353e1d650458f6401aea37a4aadaf28ff.tar.bz2
gerbonara-0dded38353e1d650458f6401aea37a4aadaf28ff.zip
Merge in negative soldermask. Still required further changes to support negatives for shapes that dont exist in the merge source
Diffstat (limited to 'gerber/common.py')
-rw-r--r--gerber/common.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/gerber/common.py b/gerber/common.py
index 1659e3b..f8979dc 100644
--- a/gerber/common.py
+++ b/gerber/common.py
@@ -17,9 +17,11 @@
from . import rs274x
from . import excellon
+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 +37,15 @@ 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)
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 +62,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)