View Single Post
Old 01-17-2011, 04:50 PM   #34
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Thumbs up

Quote:
Originally Posted by beckywc View Post
Trying to add Reading but keep getting an error after else. This is what I have thus far:

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:
			return is_reading_str
		else:
			return is_not_read_str
	except:
		pass
	return no_page_read_str
I know it is something I'm doing wrong your help would be greatly appreciated.
Use the source from the above code block. I fixed the indents on the else and the return.

When doing python functions, spacing and indenting is critical. You must get it exactly right. Copying and pasting code from other than code blocks is almost certain to get it wrong.
chaley is offline   Reply With Quote