summaryrefslogtreecommitdiff
path: root/gerber/utils.py
diff options
context:
space:
mode:
authorPaulo Henrique Silva <ph.silva@gmail.com>2015-10-14 15:37:02 -0300
committerPaulo Henrique Silva <ph.silva@gmail.com>2015-10-14 15:37:02 -0300
commit944c8329222b8c1166a4952df0ca553cbec71505 (patch)
treec9b4263852cf6e8a2f4003ac746011424d1edc69 /gerber/utils.py
parentb81c9d4bf96845ced3495eb158ec3a3c9e4dce3d (diff)
parent10d9028e1fdf7431baee73c7f1474d2134bac5fa (diff)
downloadgerbonara-944c8329222b8c1166a4952df0ca553cbec71505.tar.gz
gerbonara-944c8329222b8c1166a4952df0ca553cbec71505.tar.bz2
gerbonara-944c8329222b8c1166a4952df0ca553cbec71505.zip
Merge pull request #41 from curtacircuitos/read_from_memory
Read from memory
Diffstat (limited to 'gerber/utils.py')
-rw-r--r--gerber/utils.py20
1 files changed, 5 insertions, 15 deletions
diff --git a/gerber/utils.py b/gerber/utils.py
index df26516..1c0af52 100644
--- a/gerber/utils.py
+++ b/gerber/utils.py
@@ -201,30 +201,20 @@ def decimal_string(value, precision=6, padding=False):
return int(floatstr)
-def detect_file_format(filename):
+def detect_file_format(data):
""" Determine format of a file
Parameters
----------
- filename : string
- Filename of the file to read.
+ data : string
+ string containing file data.
Returns
-------
format : string
- File format. either 'excellon' or 'rs274x'
+ File format. 'excellon' or 'rs274x' or 'unknown'
"""
-
- # Read the first 20 lines (if possible)
- lines = []
- with open(filename, 'r') as f:
- try:
- for i in range(20):
- lines.append(f.readline())
- except StopIteration:
- pass
-
- # Look for
+ lines = data.split('\n')
for line in lines:
if 'M48' in line:
return 'excellon'