Fix parsing for very short (less 20 lines) files.

This commit is contained in:
Paulo Henrique Silva 2014-12-15 23:35:01 -02:00
parent 29deffcf77
commit 4bb2e5f8a0

View file

@ -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: