View Single Post
Old 04-05-2011, 05:32 PM   #18
PapaJohn
Enthusiast
PapaJohn began at the beginning.
 
Posts: 35
Karma: 10
Join Date: Feb 2011
Device: Kindle Paperwhite, Kobo Aura One
Hi pchrist7
This is the code I am using:
Code:
def evaluate(self, formatter, kwargs, mi, locals, val, is_read_pct,  
				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)
	try:
		f = int(pct)
		if f > test_val:
			return date
		elif f > 0:
			return is_reading_str + ': ' + pct + '%'
	except:
		pass
	return no_page_read_str
And the template for the Read Status Column:
Code:
{comments:kindle_read_status(95,Reading,Not Read)}
I don't recall making any changes.
Cheers
PapaJohn is offline   Reply With Quote