Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 11-02-2011, 05: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
Old 11-03-2011, 06:05 AM   #2
chaley
"chaley", not "charley"
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: 5,898
Karma: 1216548
Join Date: Jan 2010
Location: France
Device: Many android devices
Setting a composite column to hierarchical requires that the lookup name be typed by hand into the box in preferences -> tags browser. Composite columns are not included in the drop-down list. I will look at fixing this.

The composite column type must be "column built from other columns, behaves like tags".

I tested whether composite columns can display as hierarchical, and it works.

The following function returns one of two values, based on whether the database ID is odd.
Code:
def evaluate(self, formatter, kwargs, mi, locals):
	if (mi.id % 2) == 1:
		return 'foo.bar'
	return 'foo.mumble'
I created a composite tags-like columns named #comp2, and called the function in its template.
Code:
program: myFunction()
The attached screen shot shows that the column is being displayed as hierarchical.
Attached Thumbnails
Click image for larger version

Name:	Clipboard01.jpg
Views:	37
Size:	9.3 KB
ID:	78566  
chaley is offline   Reply With Quote
Old 11-03-2011, 07:48 PM   #3
allison1
Junior Member
allison1 began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Oct 2011
Device: kindle
Quote:
The composite column type must be "column built from other columns, behaves like tags".
That's what I'm missing. Will work on it tomorrow, and let you know how it went.
allison1 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Q: multi-column PDF to single column mobi format converstion auburn1975 Calibre 7 01-28-2012 07:11 PM
Rebuild ePub after tweaking hollowayhouse Conversion 8 08-05-2011 09:09 PM
Tweaking Samsung E65 Sidd Which one should I buy? 1 07-14-2011 07:48 AM
Table of contents - tweaking webfolk Calibre 26 11-05-2010 06:21 PM
pdf to lrf with 2 column and 1 column pages in same file danielwille Sony Reader 3 11-12-2008 11:57 AM


All times are GMT -4. The time now is 07:13 PM.


MobileRead.com is a privately owned, operated and funded community.