Quote:
Originally Posted by davidfor
The beta does not appear to be loading user created template functions. I should have two. One is used in a plugboard and I noticed errors when updating my device. When I checked, the template function was not displayed in the list in the preferences. I do not see any errors as calibre starts. And I can see the "user_template_functions" entry in the preferences table in the database.
|
It works for me.
I assume we are talking about python functions, not stored templates.
Some things to try to help me figure out what is going on.
- If you send me your metadata.db then I can try it. If willing then send it to calibre_test at charleshaley dot org.
- What is in the the database preference? Mine contains stuff like this. In reality there are no embedded newlines. EDIT: It is critical that the fourth string in an entry start with either "def" or "program:".
Spoiler:
[
[
"myFunc3",
"foo\t",
4,
"def evaluate(self, formatter, kwargs, mi, locals, val, is_read_pct, \n\t\t\t\tis_reading_str, no_page_read_str):\n\ttry:\n\t\ttest_val = int(is_read_pct)\n\texcept:\n\t\treturn 'is_read_pct is not a number'\n\n\timport re\n\tpattern = u'.*(\\d+[-/]\\d+[-/]\\d+).*?Derni\u00e8re page lue : Emplacement \\d+ \\((\\d+)%\\)'\n\tmg = re.match(pattern, val, re.U + re.I + re.DOTALL);\n\tif mg is None:\n\t\treturn no_page_read_str\n\tdate = mg.group(1)\n\tpct = mg.group(2)\n\ttry:\n\t\tf = int(pct)\n\t\tif f > test_val:\n\t\t\treturn date\n\t\telif f > 0:\n\t\t\treturn is_reading_str + ': ' + pct + '%'\n\texcept:\n\t\tpass\n\treturn no_page_read_str"
],
[
"myFunc2",
"",
-1,
"def evaluate(self, formatter, kwargs, mi, locals):\n\timport re\n\ttags = mi.get('tags')\n\tv = 0\n\tif tags:\n\t\tfor t in tags:\n\t\t\tm = re.match('recommended\\..*\\.([\\d.]+)', t)\n\t\t\tif m:\n\t\t\t\tv = v + int(m.group(1))\n\treturn v"
]
]
- What happens if you create the example function 'my_ifempty()' shown in the bottom of the help text of the preferences editor? I copied the information exactly as shown and it worked.
- There is a "plugin tweak" (a non-listed tweak) named enable_template_debug_printing. If you set it to True then function bodies will be printed when calibre starts up.