Mobileread
Python functions in database and calibre 5
#1  Terisa de morgan 09-26-2020, 01:02 PM
Hi,

I have some template functions in the database that are not python 3 compatibles (that pesky '<>'). Problem is, they give an error starting calibre 5 and I cannot modify them. Is there any way to modify them in calibre 5 or do I have to write down all the functions that fail, open the database in calibre 4, modify them and open again with calibre 5?
Reply 

#2  chaley 09-26-2020, 04:57 PM
Quote Terisa de morgan
Hi,

I have some template functions in the database that are not python 3 compatibles (that pesky '<>'). Problem is, they give an error starting calibre 5 and I cannot modify them. Is there any way to modify them in calibre 5 or do I have to write down all the functions that fail, open the database in calibre 4, modify them and open again with calibre 5?
No, there isn't a way to modify failing functions in calibre, be it 4 or 5. The assumption in the code is that the functions compile.

You can get the text of the functions using an sqlite data browser like this one. Open metadata.db and show the preferences table. The text of all of the functions are json-encoded in the row 'user_template_functions'.
Reply 

#3  Terisa de morgan 09-26-2020, 05:08 PM
Quote chaley
No, there isn't a way to modify failing functions in calibre, be it 4 or 5. The assumption in the code is that the functions compile.

You can get the text of the functions using an sqlite data browser like this one. Open metadata.db and show the preferences table. The text of all of the functions are json-encoded in the row 'user_template_functions'.
Thank you, I'll do that... and that assumption, when we are changing the compiler... is a bit heavy, from my POV. But no problem, I can update it in that way.
Reply 

#4  chaley 09-26-2020, 05:15 PM
Something that might help in the future: I am in process of implementing callable template functions. The new GPM parser/interpreter scheme already implemented makes these possible with good performance. The idea is to store a calibre GPM template as a pseudo user function. You can reference these functions using the new "call" expression. GPM now supports if-then-else and infix relationals so perhaps it will now be easier for you to use. And yes, I know that having the function name as the first argument is strange, but it fits in with the language scheme
Reply 

#5  capink 09-26-2020, 05:49 PM
Quote chaley
Something that might help in the future: I am in process of implementing callable template functions.
That would be a welcome addition. I was looking or something like this when I was working on the find duplicates plugin. Is there a time frame for this?
Reply 

#6  chaley 09-26-2020, 05:54 PM
Quote capink
That would be a welcome addition. I was looking or something like this when I was working on the find duplicates plugin. Is there a time frame for this?
Could be a week or two, probably not months. The code is mostly done. The issue is that Kovid is entirely (and rightly) consumed with the calibre 5 release. He will review the changes when he has time.
Reply 

#7  capink 09-26-2020, 06:06 PM
Quote chaley
Could be a week or two, probably not months. The code is mostly done. The issue is that Kovid is entirely (and rightly) consumed with the calibre 5 release. He will review the changes when he has time.
That's great
Reply 

#8  Terisa de morgan 09-27-2020, 02:52 AM
Quote chaley
Something that might help in the future: I am in process of implementing callable template functions. The new GPM parser/interpreter scheme already implemented makes these possible with good performance. The idea is to store a calibre GPM template as a pseudo user function. You can reference these functions using the new "call" expression. GPM now supports if-then-else and infix relationals so perhaps it will now be easier for you to use. And yes, I know that having the function name as the first argument is strange, but it fits in with the language scheme
Thank you, I'll give it a try when it appears in calibre.
Reply 

Today's Posts | Search this Thread | Login | Register