View Single Post
Old 11-02-2011, 04:42 PM   #1
allison1
Junior Member
allison1 began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Oct 2011
Device: kindle
help with Read_Status2 column tweaking

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.
allison1 is offline   Reply With Quote