Advanced Custom Icon with two requirements
First I would like to say HELP! Please and thank you. And I apologize for the long post up front.
I have been searching for the answer to this for four days now and I finally realized that I am not going to be able to figure this out on my own. I have read and reread almost every forum I could find and even spent a day searching Python. For those of you who understand this, well, my hats off to you...really, I mean that!
Here is what I need/want/pray to the powers that be for, I am trying to create a custom icon that will appear when two conditions are met that will appear in its own column.
Now my problem is that I have too many people - 'authors' in over a hundred different libraries. I use Calibre as a CMS...please don't ask, it's complicated but how I use it works the same way as someone using it for books, only with a LOT of books, or in my case files that are PDF's, RTF's, DOC's,...you get the idea.
So, I have a bazillion books with thousands of people-authors. What I wanted to do was to find a way when I am uploading the new files to tell me if the author - person is already in the database, any of the databases at the same time when uploaded to one of the three upload libraries.
The column I would like to reflect with an icon is called 'SA', I have the 'Authors' column, naturally, and another that is called 'New'.
I would like for the 'SA' - #same_account -Column to show the icon if:
1. The 'New' Column is true. (This is a yes/no column) - #new
2. And if the 'Author' column matches any author in any database.
The first part was easy enough to do in the Column Icons section, but the problem arises when I try to match the authors, now what I initially did was to add a rule that said if the 'Author' column 'has' and then I added some names with the & separator and it worked fabulously.
I did my happy dance and then I formatted my csv file with all of the people-authors that I have and simply copy and pasted them into the new rule I created...This is where the problem occurred. I have too many authors it would not allow all of them to be entered.
Well, bah! That won't work. So I checked into the advanced rule. Thus began my four day journey into frustration. I thought it would be so simple as I am not completely unintelligent.
Python, along with the Calibre manual teased me relentlessly, telling me I could add an 'or' statement with as many values as I like, but not once did it show me how to format the code to do so, as well as other statements, 'with', 'and', etc. Okay in python's and Calibre's defense they do show the format but it's like trying to decipher hieroglyphics before the discovery of the Rosetta Stone.
Google was not my friend.
I did, however, managed to figure out the code for the 'New' Column which is:
program:
b = field('#new');
contains(b, 'Y', 'redbarrel.png', '')
Don't know if that is the correct format but it worked, only those that were selected as 'New' got the icon. Awesome! Now I just need the other part of the code. So here is where I beg prettily for help.
Now I tried a plethora of variations of the only two codes that I found on other posts:
program:
a = field('authors');
contains(a, 'John Doe', 'tincan.png', 'redcheck.png')
This statement worked well by itself but I could not add two lines or more than one author name, because really, let's face it. I was doing it completely wrong. Apparently you cant add two Program statements to the same rule. I understand you can somehow compare the field('author') to a .csv list (or perhaps another file format), but again with the teasing. I feel like I am on some kind of a ten step program. Step 1. Admit you have a problem....Well, I admit it.
If someone could help me. I would so appreciate any assistance (the code to make it work would be awesome!) Oh I also learned how to make a list:
lists1 = ['John Doe' , 'Jane Doe', 'Farmer John']
This could represent the authors but I have no idea what to do with it, but I made it!
Please help me! Thanks in advance.
|