|
![]() |
|
Thread Tools | Search this Thread |
![]() |
#16 |
Dead account. Bye
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 587
Karma: 668244
Join Date: Mar 2011
Device: none
|
|
![]() |
![]() |
![]() |
#17 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,339
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
![]() Go to preferences -> template functions. Enter: Function: names_to_sort Arg count: 1 Documentation: Given an author-like string, return the author-sort for it. Program code: Code:
def evaluate(self, formatter, kwargs, mi, locals, names): from calibre.ebooks.metadata import authors_to_sort_string, string_to_authors return authors_to_sort_string(string_to_authors(names)) Code:
{authors:names_to_sort()} Last edited by chaley; 03-20-2011 at 04:15 PM. Reason: Correct the function name |
|
![]() |
![]() |
Advert | |
|
![]() |
#18 |
Dead account. Bye
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 587
Karma: 668244
Join Date: Mar 2011
Device: none
|
![]() ![]() Thank you, chaley. I'll test later. Any hint about the & feature? |
![]() |
![]() |
![]() |
#19 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,339
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#20 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
Shouldn't the function in the template be "name_to_sort()"?
|
![]() |
![]() |
Advert | |
|
![]() |
#21 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,339
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
No. The input is a string containing 1 or more author's names. For example, assuming no tweaks are set, "A B" returns "B, A", and "A B & C D" returns B, A & D, C".
The inner function call, string_to_authors, breaks apart the input author string into a list of authors. The outer function, authors_to_author_sort, accepts a list of authors (the result of the inner function) and produces an author_sort string, which is the result of the template function. |
![]() |
![]() |
![]() |
#22 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
Quote:
|
|
![]() |
![]() |
![]() |
#23 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,339
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#24 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,339
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I have reread the pertinent posts, and I now think I understand what you mean by "the & feature".
To summarize, you want a column that contains names of people, mimicking the author column, including separate sort values. Such a column would be used for editors, translators, friends, and what-have-you, and would have several characteristics:
My thought is that such a column would be similar to a tags-like custom column (already multiple), but with the behavior indicated by lines 2-5. The required changes touch a large number of bits of code, but as I said above, probably doable. It is worth noting that such a column would create a new pool of names. This matters if a person is both an editor and an author. The standard searches would be role-based (author, editor, ???). A grouped search term could be made to amalgamate all the fields together for searching, but that isn't a perfect solution. For example, renaming the person in one role would not rename the same person in another role. The question: Is this work worth doing without the separate column and given the role-based behavior? |
![]() |
![]() |
![]() |
#25 |
Dead account. Bye
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 587
Karma: 668244
Join Date: Mar 2011
Device: none
|
Yes chaley, that's what I wanted: A tag like field but using & instead of comma and with all the associated author sorting stuff.
And also like in a brainstorm, you've pointed something I hadn't thought of: Creating just one people pool, it doesn't matter their "jobs". As you point out, the same person being an author AND a translator (or an editor, or whatever) at the same time can be quite possible. I think it would be really nice that Calibre only had this single "people-database", no matter in which field the name is used (canon Author or any other additional author-like custom column). But as you say I cannot tell if this improvement is worth the effort. (Maybe you can make a poll between Calibre coders). As a less radical change, maybe Author-like columns could be fully implemented but not making a single "people database", so "Christopher Tolkien" in Authors would be different from "Christopher Tolkien" as editor. I mean, if you rename the author "Christopher Tolkien" to "Tolkien junior", the editor would continue being "Christopher Tolkien". But again, I cannot tell if this improvement is worth the effort... |
![]() |
![]() |
![]() |
#26 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,339
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Items 1-5, with separate people-pools per column are now available in calibre's source trunk, and will be in the next release.
|
![]() |
![]() |
![]() |
#27 |
Member
![]() Posts: 21
Karma: 10
Join Date: Mar 2011
Device: Kindle
|
I am new to this type of,,, programming?... for lack of a better term atm,,
I was pointed to this thread to help me with a similar issue, Comparing series and author to find some duplicates I inadvertently created by copying author to series on a lot of books,,, I have been working to use the techniques in this thread to create a custom column that indicates this,, but I seem to be lacking,, I am trying the method using template functions, with this information Function: series_Sort Arg count: 1 Program code: def evaluate(self, formatter, kwargs, mi, locals, names): from calibre.ebooks.metadata import series_sort_string, author_series_sort return series_sort_string(author_series_sort(names)) The custom column is {test:series_sort()} and I get the error Exception file"<String>",line 5, in evaluate:importError: cannot import name series_sort_string Now,, I basically understand when I copied over from the example above and just subbed in series and author I messed it up,, Can someone help me fix this, or point me to where I can find the correct arguments/syntax,, This thread when it starts assumes a level of knowledge within the template functions/syntax/arguments,, that I don't currently have,, I will work on this but in the mean time I will just bug you all :P Thanks, Collin |
![]() |
![]() |
![]() |
#28 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,339
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
You should follow the example in post 8, substituting series and authors for the two fields in that template.
|
![]() |
![]() |
![]() |
#29 |
Member
![]() Posts: 21
Karma: 10
Join Date: Mar 2011
Device: Kindle
|
Well,, I did that,, and it only gave me "yes" responses,, here is the syntax
column lookup name and heading are test,, made from other column, yes/no answers with show checkmarks,, {#test:'strcmp(field('#series'), field('#author'), 'No', 'Yes', 'No')'} tried {#test:'strcmp(field('#series'), field('#authors'), 'No', 'Yes', 'No')'} too,,, didn't know if it had an s,, did I do something wrong? |
![]() |
![]() |
![]() |
#30 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,339
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
The lookup names for series & authors do not have # in front of them. That character is used to indicate that the item is a a custom column.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Borders - Select books for $5 each | jbcohen | Deals and Resources (No Self-Promotion or Affiliate Links) | 8 | 12-25-2010 05:53 PM |
25% off on select books @ Kobo Books | eric11210 | Deals and Resources (No Self-Promotion or Affiliate Links) | 16 | 10-31-2010 11:33 AM |
Opus ask me to select the language everytime I turn it on | tokio2 | Bookeen | 2 | 09-17-2010 11:11 AM |
Kobo Books: $2 Off Select Titles | Acreo Aeneas | Deals and Resources (No Self-Promotion or Affiliate Links) | 6 | 09-02-2010 09:35 AM |
Sync only select books | Carenza | Calibre | 2 | 08-10-2010 05:16 PM |