Quote:
Originally Posted by pchrist7
Hi beckywc
Got it.
wonder if it can be done.
Will give it a try or two during the weekend.
|
You can do it.
Try playing with some variant of this
Code:
def evaluate(self, formatter, kwargs, mi, locals, val, is_read_pct, is_read_str,
is_reading_str, no_page_read_str):
try:
test_val = int(is_read_pct)
except:
return 'is_read_pct is not a number'
import re
mg = re.match('\s(\d+[-/]\d+[-/]\d\d\d\d).*?Last Page Read: location \d+ \((\d+)%\)', val, re.I + re.DOTALL);
if mg is None:
return no_page_read_str
date = mg.group(1)
pct = mg.group(2)
try:
f = int(pct)
if f >= test_val:
return date
return is_reading_str + ': ' + pct + '%'
except:
pass
return no_page_read_str
I haven't tried it, so it might not compile. Should be close.
I changed the regexp in the re(...) clause to carve out both the date and the percent. If it finds them, then the ifs below choose what to return.
Have fun.