View Single Post
Old 01-17-2011, 03:15 PM   #32
beckywc
Addict
beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.
 
beckywc's Avatar
 
Posts: 272
Karma: 1050426
Join Date: Feb 2010
Location: California
Device: iPad Mini w/Retina, Kindle 3, Kindle Fire HDX 8.9, & Asus Transformer
Quote:
Originally Posted by chaley View Post
As long as I am commenting.

Code:
		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
The line you added could be
Code:
		elif f > 0:
			return is_reading_str
		else:
because the if above has already removed all the cases that the clause after the 'and' would catch.
Trying to add Reading but keep getting an error after else. This is what I have thus far:

Spoiler:
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.
beckywc is offline   Reply With Quote