optimize a bit (more to come)
This commit is contained in:
parent
9d02c6ae36
commit
1b8b6a435e
|
@ -186,31 +186,31 @@ class Logger:
|
||||||
done = False
|
done = False
|
||||||
found_first_line_that_matches = False
|
found_first_line_that_matches = False
|
||||||
while not done:
|
while not done:
|
||||||
line = f.readline().decode('utf-8')
|
line = f.readline()
|
||||||
if line:
|
if line:
|
||||||
line = helpers.from_one_line(line)
|
line = helpers.from_one_line(line)
|
||||||
splitted_line = line.split(':')
|
splitted_line = line.split(':')
|
||||||
if len(splitted_line) > 2:
|
if len(splitted_line) > 2:
|
||||||
if splitted_line:
|
# line[0] is date, line[1] is type of message
|
||||||
# line[0] is date, line[1] is type of message
|
# line[2:] is message
|
||||||
# line[2:] is message
|
date = splitted_line[0]
|
||||||
date = splitted_line[0]
|
date = time.localtime(float(date))
|
||||||
# eg. 2005
|
# eg. 2005
|
||||||
line_year = int(time.strftime('%Y', time.localtime(float(date))))
|
line_year = int(time.strftime('%Y', date))
|
||||||
# (01 - 12)
|
# (01 - 12)
|
||||||
line_month = int(time.strftime('%m', time.localtime(float(date))))
|
line_month = int(time.strftime('%m', date))
|
||||||
# (01 - 31)
|
# (01 - 31)
|
||||||
line_day = int(time.strftime('%d', time.localtime(float(date))))
|
line_day = int(time.strftime('%d', date))
|
||||||
|
|
||||||
# now check if that line is one of the lines we want
|
# now check if that line is one of the lines we want
|
||||||
# (if it is in the date we want)
|
# (if it is in the date we want)
|
||||||
if line_year == year and line_month == month and line_day == day:
|
if line_year == year and line_month == month and line_day == day:
|
||||||
if found_first_line_that_matches is False:
|
if found_first_line_that_matches is False:
|
||||||
found_first_line_that_matches = True
|
found_first_line_that_matches = True
|
||||||
lines.append(splitted_line)
|
lines.append(splitted_line)
|
||||||
else:
|
else:
|
||||||
if found_first_line_that_matches:
|
if found_first_line_that_matches: # we had a match before
|
||||||
done = True
|
done = True # but no more. so we're done with that date
|
||||||
|
|
||||||
else:
|
else:
|
||||||
done = True
|
done = True
|
||||||
|
|
Loading…
Reference in New Issue