View Single Post
Old 10-15-2011, 03:41 AM   #4
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,738
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Just for fun, I wrote the custom template function to do this job.

Code:
Function name: myListMerge (or whatever you want)
Argument count: 5
Program code:
def evaluate(self, formatter, kwargs, mi, locals, tags, shelf, genre, length, character):
	r = set([t.strip() for t in tags.split(',') if t.strip()])
	r |= set([t.strip() for t in shelf.split(',') if t.strip()])
	r -= set([t.strip() for t in genre.split(',') if t.strip()])
	r -= set([t.strip() for t in length.split(',') if t.strip()])
	r -= set([t.strip() for t in character.split(',') if t.strip()])
	return ', '.join(sorted(r))
You would use it like
Code:
{:'myListMerge(field('tags'), field('#shelf'), field('#genre'), field('#length'), field('#character'))'}
In fact, I don't suggest that you use it unless you understand it, otherwise you won't be able to maintain it. I did it because I was curious.
chaley is offline   Reply With Quote