Quote:
Originally Posted by readin
Thank you chaley, that works beautifully. 
|
You are welcome. It is fun to work with people who do their homework.
Quote:
I am now using the has_ebook() function you provided as follows:
Preferences > Look and Feel > Column coloring:
Advanced Rule for <All Columns>:
Code:
program:
test(has_ebook(), '', 'red')
|
You should combine the test into the function, assuming that you don't have some other use for it. Something like this should work.
Code:
def evaluate(self, formatter, kwargs, mi, locals, color):
import re
fmt_data = mi._proxy_metadata.db_approx_formats
fmt_data = ','.join(v.upper() for v in fmt_data)
return '' if re.search('EPUB|MOBI|PDF', fmt_data) is None else color
Be sure to set the number of parameters to 1.
Given that it returns 'color' without change, you could use the same function for an icon simply by passing 'foo.png' instead of 'red'.
Quote:
Using these two methods -- a template for composed icons, and a function for coloring books red -- is probably much more efficient than using a bunch of basic rules, especially because I will be adding a few more icons and ebook formats to them.
|
Yes, that is certain. Combining basic rules into one advanced rule is a win simply starting to evaluate a rule costs something. If you can avoid complexity so much the better.