|  01-10-2016, 03:09 PM | #721 | 
| Ex-Helpdesk Junkie            Posts: 19,421 Karma: 85400180 Join Date: Nov 2012 Location: The Beaten Path, USA, Roundworld, This Side of Infinity Device: Kindle Touch fw5.3.7 (Wifi only) | 
			
			@chaley -- merge into the OP?
		 | 
|   |   | 
|  01-10-2016, 03:54 PM | #722 | 
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | |
|   |   | 
|  01-10-2016, 04:04 PM | #723 | 
| Ex-Helpdesk Junkie            Posts: 19,421 Karma: 85400180 Join Date: Nov 2012 Location: The Beaten Path, USA, Roundworld, This Side of Infinity Device: Kindle Touch fw5.3.7 (Wifi only) | 
			
			I want to but I can't. Why don't you do it instead?    | 
|   |   | 
|  01-19-2016, 12:31 AM | #724 | 
| Enthusiast  Posts: 35 Karma: 10 Join Date: Feb 2011 Device: Kindle Paperwhite, Kobo Aura One | 
			
			Don't know how long this has been going on, but fetch annotations is no longer updating my Read Status column or comments column. I have a Kindle DX and a Paper White (separate libraries for each) and Calibre is not updating from either one. I am using Calibre 2.49 on Mac OS 10.10.5. I hope someone can help me get this functioning again. | 
|   |   | 
|  03-20-2016, 12:00 PM | #725 | 
| Member  Posts: 16 Karma: 24 Join Date: Jun 2009 Device: Kindle Paperwhite 1 | 
			
			I apologise since this is probably an FAQ, or at least previously answered, but I'm getting information overload from both this thread and the python docs. For my Kindle plugboard I have used a line straight off the Calibre docs for years: {series}{series_index:0>3s| – | – }{title}. But since that hardcodes three digits, it fails since I occasionally use decimal series IDs. (omnibuses, short story collections, or other things that are not *actually* part of the series proper, but do have a *place* in the order). These then omit leading zeroes and sort out of sequence. So another one mentioned in the docs is 0>5.2f -- five digits, 2 after the decimal point, if I read that correctly. That would work, but at the cost of more zeroes on my screen than I really want (since fractional indices are rare). I could do 4.1, which is better (I have never needed more than 9 sub-indices, and I could reindex the ones where I've used hundredths). But what I *really* would want is to have 3 digits with leading zeroes normally, and *add* the decimals (ideally to the same 2 digit precision as in calibre itself) _only when needed_. So 001, 002, 003, 003.01, 003.50, 004, etc. Is this possible or a pipedream? Looking at the python docs, I think it would almost have to involve something more than a simple format-string, which I think would make it impossible to do in calibre? Last edited by JJanssen; 03-20-2016 at 12:00 PM. Reason: missed period. | 
|   |   | 
|  03-20-2016, 03:47 PM | #726 | 
| Ex-Helpdesk Junkie            Posts: 19,421 Karma: 85400180 Join Date: Nov 2012 Location: The Beaten Path, USA, Roundworld, This Side of Infinity Device: Kindle Touch fw5.3.7 (Wifi only) | 
			
			You *could* do it using a format specifier stored in another custom column. You'd need to run a calibre-debug script periodically to recalculate the format specifiers. Reason: a mere template cannot know the metadata for other book records. And you need to know if there are other books in the series with a decimal series_index.  ... chaley wrote a calibre-debug script for a case like this, I will see if I can track it down for you. EDIT: Here it is: https://www.mobileread.com/forums/sho....php?p=2916772 Last edited by eschwartz; 03-20-2016 at 03:51 PM. | 
|   |   | 
|  03-20-2016, 06:13 PM | #727 | |
| Member  Posts: 16 Karma: 24 Join Date: Jun 2009 Device: Kindle Paperwhite 1 | Quote: 
 I'll look at it in detail once I have a) a test library set up and b) backups and c) some time   | |
|   |   | 
|  03-27-2016, 11:55 AM | #728 | 
| Member  Posts: 16 Karma: 24 Join Date: Jun 2009 Device: Kindle Paperwhite 1 | 
			
			So, after a false start or two (I accidentally the spaces in the path with a \, also accidentally the destination column) I have a script that reliably puts something useful in the #format_str field of my database. It's not quite the one that I want, but that's an implementation detail that will be easily solved in a few lines of python. I wanted to have the workflow working before I go there. But how do I use that column in my plugboard? If I want to replace "{series}{series_index:0>4.1f| – | – }{title}", my obvious naive approach would be "{series}{series_index:{format_str}| – | – }{title}", , or with added #, but it doesn't like that. My perusal of this thread hasn't found it yet either. Since this is obviously a Solved Problem, can someone point me at the solution? Edit: I was in the python mood anyway, so here's my extra few lines, based on the very nice script by chaley: Spoiler: 
 Last edited by JJanssen; 03-27-2016 at 12:24 PM. | 
|   |   | 
|  03-27-2016, 12:50 PM | #729 | 
| Ex-Helpdesk Junkie            Posts: 19,421 Karma: 85400180 Join Date: Nov 2012 Location: The Beaten Path, USA, Roundworld, This Side of Infinity Device: Kindle Touch fw5.3.7 (Wifi only) | 
			
			Use general program mode, with the finish_formatting() function.   (GPM is better for these complex cases, although you "could" make do with TPM.) | 
|   |   | 
|  03-27-2016, 04:19 PM | #730 | |
| Member  Posts: 16 Karma: 24 Join Date: Jun 2009 Device: Kindle Paperwhite 1 | Quote: 
 Edit: Ah, I think I've got it. Add more tabs, then paste. Edit2: nope, that still chokes on anything more than 1 line. Edit3: The most obvious way to go seemed to be: Code: program:
	f_s = field('#format_str')
	f_s.format(str(field('series_index'))
	return f_sCode: program:
	str(field('#format_str').format(field('series_index')))Which also doesn't work. The only moderately complex one I;ve gotten to give me anything was one from the docs: Code: program:
    strcat(
        re(field('series'), '([^\s])[^\s]+(\s|$)', '\1'),
        finish_formatting(field('series_index'), '0>2s', ' - ', ' - '),
        field('title')
    )Last edited by JJanssen; 03-27-2016 at 05:00 PM. | |
|   |   | 
|  03-27-2016, 04:29 PM | #731 | 
| Ex-Helpdesk Junkie            Posts: 19,421 Karma: 85400180 Join Date: Nov 2012 Location: The Beaten Path, USA, Roundworld, This Side of Infinity Device: Kindle Touch fw5.3.7 (Wifi only) | 
			
			You can simply include the GPM template directly in the plugboard definition. Right-click and there will be an option to use the Template Editor. (When saved, it appears as if it is one line, but internally linebreaks are still saved as '\n' -- also, linebreaks may help you read it but they don't affect the parsing.) Again, you just need to feed finish_formatting() with the formatting specification in the custom column. Code: {series_index:0>5.2f| – | – }Code: finish_formatting(field('#series_index'), field('#format_str'), ' – ', ' – ')Last edited by eschwartz; 03-27-2016 at 06:43 PM. Reason: series ==> series_index | 
|   |   | 
|  03-27-2016, 06:21 PM | #732 | ||
| Member  Posts: 16 Karma: 24 Join Date: Jun 2009 Device: Kindle Paperwhite 1 | Quote: 
 Quote: 
 Code: program:
strcat(
	field('series'),
	finish_formatting(field('series_index'), field('#format_str'), ' – ', ' – '),
	field('title')
)Hardcoding a format..... right. wait. What that function expects is apparently "05.1f", not "{0:05.1f}". So it might work if I simplified the generating script a little. Yup. That does the trick. So just for documentation purposes, here's my working setup: Spoiler: 
 So, wow, that was definitely one of those cases where I was looking for the issue in all the wrong places. Sorry for trying your patience! And definitely thanks for pointing me in the right direction. Last edited by JJanssen; 05-01-2016 at 06:45 AM. Reason: I accidentally the plugboard template wrong. | ||
|   |   | 
|  03-27-2016, 06:41 PM | #733 | 
| Ex-Helpdesk Junkie            Posts: 19,421 Karma: 85400180 Join Date: Nov 2012 Location: The Beaten Path, USA, Roundworld, This Side of Infinity Device: Kindle Touch fw5.3.7 (Wifi only) | 
			
			Reducing the number of custom columns will definitely have *some* performance impact, although how much in the grand scheme of things   ??? P.S. Change: Code: cache = init_cache(library_path = '/Users/jasper/Documents/Calibre Test Library/') Code: from calibre.utils.config import prefs cache = init_cache(library_path = prefs['library_path'])   Last edited by eschwartz; 03-27-2016 at 06:53 PM. | 
|   |   | 
|  03-27-2016, 06:48 PM | #734 | ||
| Member  Posts: 16 Karma: 24 Join Date: Jun 2009 Device: Kindle Paperwhite 1 | Quote: 
  Quote: 
 Last edited by JJanssen; 03-27-2016 at 06:55 PM. | ||
|   |   | 
|  03-27-2016, 06:53 PM | #735 | 
| Ex-Helpdesk Junkie            Posts: 19,421 Karma: 85400180 Join Date: Nov 2012 Location: The Beaten Path, USA, Roundworld, This Side of Infinity Device: Kindle Touch fw5.3.7 (Wifi only) | 
			
			Sure.   It's a trick I saw used elsewhere, which makes for much more reusable code (and which I should've used back when someone was having a lot of trouble editing an attached python script  ). Also, noticing your edits, you seemed to be slightly confused at first what GPM is. It isn't python, it is a cut-down mini-language that compiles to python and is documented in the calibre manual. You can however define new functions in python. | 
|   |   | 
|  | 
| Tags | 
| custom column, tag, tags | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Should composite columns appear in Grouped Searches? | ownedbycats | Library Management | 3 | 02-13-2021 03:43 PM | 
| Having problems with composite columns and save/send templates | Trel | Calibre | 4 | 09-26-2016 03:21 PM | 
| Tooltips for narrow columns | theducks | Library Management | 7 | 03-16-2015 10:58 PM | 
| Techniques to use plugboards, custom columns and templates | kovidgoyal | Library Management | 0 | 01-26-2011 04:21 PM |