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

refactor
Paulo Henrique Silva 2014-12-15 23:35:01 -02:00
rodzic 29deffcf77
commit 4bb2e5f8a0
1 zmienionych plików z 7 dodań i 2 usunięć

Wyświetl plik

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