Hi Chaley
I got ambicious. Tried to modify the function code. Want to learn.
Got a weird idea that f > 0 and f < test_val should return Reading,
tried with elif since python apparently doesn't have "case"
Calibre startup time went from 1-2 seconds to several minuttes.
Did up params from to 6, changed the column def to include Reading as last parm
code:
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) and (f < test_val):
return is_reading_str
else:
return is_not_read_str
except:
pass
return no_page_read_str
No big deal, I'm just trying to learn by doing
Cheers,
EDIT: Slow down was not caused by the edit above.
The minute I removed and other column showing the % read spead was back.
Sorry.
Last edited by pchrist7; 01-17-2011 at 09:23 AM.
|