View Single Post
Old 01-27-2011, 11:50 AM   #172
pchrist7
Addict
pchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animals
 
pchrist7's Avatar
 
Posts: 385
Karma: 6514
Join Date: Aug 2010
Location: Denmark
Device: Kindle 3 3G+Wifi
Kindle_read_status_2

Quote:
Originally Posted by nynaevelan View Post
Thanks for taking the time to consider this.
Hi Again
No problem
This helps ME to expand my knowledge, when time & energy allows.
( had weird brain farts over this simple change. Not my day ?)

OK - IF I have understood your request correctly, I suggest you create a new python template function, and a new custom column. Then You don't loose what you have.

Follow the instruction in the original post, BUT change the step instructions with the ones listed below !!!

The link to the original instructions:
http://www.mobileread.com/forums/sho...31#post1353631

Replace the Original instruction step # with the following:

step 2: kindle_read_status_2

step 3: 5

step 4:
Code:
Check if the associated field contains a kindle annotation for percent read. 
If not, return no_page_read_str. 
If so, then compare that percent against is_read_pct. 
If the val is larger, then return is_read_str, 
if the val is >0 and < is_read_pct return is_reading_str. 
Otherwise return is_not_read_str. 

One usage: {comments:kindle_read_status(90,Read,Reading,Not Read)} 

( use the above when defining your custom column ) 

90 goes into variable is_read_pct. IF pct_read > 90 the book is "read" The text returned is
Read goes into the variable is_read_str. This ex. returns the text Read
Reading goes into variable is_reading_str. IF pct_read >0 book the text "Reading" is shown with the percentage shown as well.
Not Read goes into variable no_page_read_str. IF none of the above catch, then "Not Read" is shown.

Feel free to change the %, the text strings to suit your needs. 
Remember: Do this in the custom column definition.
step 5:
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)
	try:
		f = int(pct)
		if f > test_val:
			return is_read_str
		elif f > 0:
			return is_reading_str + ': ' + pct + '%'
	except:
		pass
	return no_page_read_str
step 9:
Lookup name: read_status2
Column Heading: Read Status2
Column type: Column built from other columns
Template:
Code:
{comments:kindle_read_status_2(90,Read,Reading,Not Read)}
REMEMBER to to do steps 10 to 13 !!
Or this won't work

IF this doesn't work, please try to delete the NEW costum column, and the NEW python template. Restart Calibre and try once more.

Hope this helps you with wishes. And it ain't even Xmas for quite a while

Last edited by pchrist7; 04-26-2011 at 09:30 AM. Reason: Make it work for K2, KDX. Year was 4 digits and gave problems for these readers
pchrist7 is offline   Reply With Quote