I'm trying to tweak the Read Status 2 column - get rid of the percent read, and update the date completed, to make the date hierarchical in the tag browser. I've never tried to mess with python before today (no, yesterday, I started this yesterday afternoon) but here's what i've got:
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+).*?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)
n = date.split('/')
year = n[2]
month = n[0]
yemo = year + '.' + month
try:
f = int(pct)
if f > test_val:
return is_read_str + ' ' + yemo
elif f > 0:
return is_reading_str
except:
pass
return no_page_read_str
It's working - in that I'm getting the column values that I expect, but they aren't actually nesting. I see 2 possible problems.
1: I don't really know how to set the tags as nesting (I think it's just being added under Preferences/Look and Feel/Tag Browser). I'm currently trying several different combinations of Read_Status2, read status2, etc... or
2: The output isn't really a string that calibre recognizes as nesting tags.
Any feedback on my modifications, or on possible solutions would be *greatly* appreciated.
note: yemo looks like an excess variable to me, I was hoping that might change the text string of the output so it might work.