summaryrefslogtreecommitdiff
path: root/gerber/utils.py
diff options
context:
space:
mode:
authorPaulo Henrique Silva <ph.silva@gmail.com>2014-12-15 23:35:01 -0200
committerPaulo Henrique Silva <ph.silva@gmail.com>2014-12-15 23:44:12 -0200
commit4bb2e5f8a047d10dafcbc9f841571ac753a439da (patch)
treee80bc47252dcf84491977f3c15be3846c2e0d992 /gerber/utils.py
parent29deffcf77e963ae81aec9f8cbc61b029f3052d5 (diff)
downloadgerbonara-4bb2e5f8a047d10dafcbc9f841571ac753a439da.tar.gz
gerbonara-4bb2e5f8a047d10dafcbc9f841571ac753a439da.tar.bz2
gerbonara-4bb2e5f8a047d10dafcbc9f841571ac753a439da.zip
Fix parsing for very short (less 20 lines) files.
Diffstat (limited to 'gerber/utils.py')
-rw-r--r--gerber/utils.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/gerber/utils.py b/gerber/utils.py
index 56b675f..0f0c07c 100644
--- a/gerber/utils.py
+++ b/gerber/utils.py
@@ -201,9 +201,14 @@ def detect_file_format(filename):
File format. either 'excellon' or 'rs274x'
"""
- # Read the first 20 lines
+ # Read the first 20 lines (if possible)
+ lines = []
with open(filename, 'r') as f:
- lines = [next(f) for x in xrange(20)]
+ try:
+ for i in range(20):
+ lines.append(f.readline())
+ except StopIteration:
+ pass
# Look for
for line in lines: