Quote:
Originally Posted by chaley
As long as I am commenting.
Code:
f = int(mg.group(1))
if f >= test_val:
return is_read_str
elif (f > 0) and (f < test_val):
return is_reading_str
else:
return is_not_read_str
The line you added could be
Code:
elif f > 0:
return is_reading_str
else:
because the if above has already removed all the cases that the clause after the 'and' would catch.
|
Trying to add Reading but keep getting an error after else. This is what I have thus far:
Spoiler:
def evaluate(self, formatter, kwargs, mi, locals, val, is_read_pct, is_read_str,
is_not_read_str, no_page_read_str, is_reading_str):
try:
test_val = int(is_read_pct)
except:
return 'is_read_pct is not a number'
import re
mg = re.match('.*last page read: location \d+ \((\d+)%\)', val, re.I + re.DOTALL);
if mg is None:
return no_page_read_str
try:
f = int(mg.group(1))
if f >= test_val:
return is_read_str
elif f > 0:
return is_reading_str
else:
return is_not_read_str
except:
pass
return no_page_read_str
I know it is something I'm doing wrong your help would be greatly appreciated.