Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 06-03-2014, 08:25 PM   #511
alphane
Member
alphane began at the beginning.
 
alphane's Avatar
 
Posts: 23
Karma: 10
Join Date: Apr 2014
Location: France
Device: PB622
Quote:
You keep giving us the Template and Destination, but you fail to give us format and device. Have you selected Format: ePub an Device: save_to_disk? Also did you save the plugboard?
I had to delay solving my plugboard problem, sorry for giving no earlier answer...

Anyhow, the format I save is indeed epub and the device is save_to_disk and, of course, I saved the plugboard. But I have another peace of information. It did not appear earlier to me as I am more often downloading my ebooks on device via Dropbox. But the plugboard works fine when Device is PB622 (my device). Only when Device is save_to_disk does it not work.

So am I the only one or does it not work for save_to_disk and others don't bother?
alphane is offline   Reply With Quote
Old 07-03-2014, 08:02 AM   #512
Accel
Junior Member
Accel began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Sep 2013
Location: Moscow, Russia
Device: iPad
Angry invalid conversion specification

I wrote template for new column to table view:
Code:
{author_sort:re(, ([^\s.])[^\s.]*(?:(?:$|\s|\.)+),, \1. }
but receive an "TEMPLATE ERROR: invalid conversion specification"
Anybody know why? What's wrong?
Accel is offline   Reply With Quote
Old 07-03-2014, 10:46 AM   #513
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
Posts: 6,538
Karma: 10990232
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
You have three () commas in that template. Commas separate arguments in the function. re() takes three arguments -- val, pattern, replacement -- and the first is inferred as author_sort from the template. (val is only used in general and template program mode, not single-function mode which is what we are using here). You have also left args 1 & 3 empty.

More on this in the calibre template tutorial: http://manual.calibre-ebook.com/template_lang.html

Function reference: http://manual.calibre-ebook.com/template_ref.html

Try:
Code:
{author_sort:re(([^\s.])[^\s.]*(?:(?:$|\s|\.)+), \1. }

Last edited by eschwartz; 07-03-2014 at 10:48 AM.
eschwartz is offline   Reply With Quote
Old 07-03-2014, 08:20 PM   #514
Accel
Junior Member
Accel began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Sep 2013
Location: Moscow, Russia
Device: iPad
Thumbs down TEMPLATE ERROR: invalid conversion specification

Quote:
Originally Posted by eschwartz View Post
You have three () commas in that template. Commas separate arguments in the function. re() takes three arguments -- val, pattern, replacement -- and the first is inferred as author_sort from the template. (val is only used in general and template program mode, not single-function mode which is what we are using here). You have also left args 1 & 3 empty.
There is another formula and had the same result: ERROR
Of course, I read the manual. And did some help script on Python,
but still need help.
Why this template have an ERROR?

Spoiler:
Code:
# coding: utf-8

# if you have Python
# just run in terminal 'python re4calibre.py'

import re

print '\n'
print '\t For help use Online regex tester and debugger http://regex101.com/#python'


pattern = ur', ([^\s.])[^\s.]*(?:(?:$|\s|\.)+)'

replacement = ur', \1. '

str1 = u'Wood, Sir John & Vivekananda & Krisna, R. O. & Ball, Harry'
str2 = u'Wood, Sir & Warner, Brother'
str3 = u'Vivekanda & Shivananda'
str4 = u'Wood, Sir John & Vivekananda & McDonalds, G. B. & Warner, Brother & Braun'
str5 = u'Wood, Sir & McDonalds, Alex Jonathan'

print '\n'

print '\t1. '+str1+' -->'
print '\t   '+re.sub(pattern, replacement, str1, flags=re.I)
print '\t2. '+str2+' -->'
print '\t   '+re.sub(pattern, replacement, str2, flags=re.I)
print '\t3. '+str3+' -->'
print '\t   '+re.sub(pattern, replacement, str3, flags=re.I)
print '\t4. '+str4+' -->'
print '\t   '+re.sub(pattern, replacement, str4, flags=re.I)
print '\t5. '+str5+' -->'
print '\t   '+re.sub(pattern, replacement, str5, flags=re.I)

print '\n'
print 'Copy template for Calibre column:'
print '{author_sort:re('+pattern+','+replacement+')}'
print '\n'
Attached Files
File Type: zip re4calibre.zip (1.0 KB, 21 views)
Accel is offline   Reply With Quote
Old 07-03-2014, 08:36 PM   #515
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
Posts: 6,538
Karma: 10990232
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
I just noticed the closing parenthesis in re() was missing too. There seems to be few problems, really.

What are you trying to do?

EDIT: It looks like you want to abbreviate all author first names?

"Wood, Sir John" becomes "Wood, S. John"
but
"Ball, Harry" becomes "Ball, H."

Last edited by eschwartz; 07-03-2014 at 11:24 PM.
eschwartz is offline   Reply With Quote
Old 07-03-2014, 11:24 PM   #516
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
Posts: 6,538
Karma: 10990232
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
You will need to escape the comma as "\," (but in the python script, since the pattern was quoted, escaping wasn't necessary).

It still errors, I'm not sure why, but it is more complex than it needs to be, so...

Try this template, which I rewrote from scratch:

Code:
{author_sort:re(\, (\w)\w*,\, \1.)}
Explanation:

Search for:
comma, space, letter (captured), letters. [Stop at the first non-letter value.]

Replace with:
comma, space, captured first letter, period

Last edited by eschwartz; 07-03-2014 at 11:29 PM.
eschwartz is offline   Reply With Quote
Old 07-04-2014, 10:27 AM   #517
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,653
Karma: 1137414
Join Date: Jan 2010
Location: France
Device: Many android devices
@eschartz: this call to re is a prime candidate for template program mode. There are too many ways that the single function mode parser can get confused by the embedded parens and commas. Using TPM eliminates all of that.
chaley is offline   Reply With Quote
Old 07-07-2014, 04:51 PM   #518
Accel
Junior Member
Accel began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Sep 2013
Location: Moscow, Russia
Device: iPad
Quote:
Originally Posted by chaley View Post
There are too many ways that the single function mode parser can get confused by the embedded parens and commas. Using TPM eliminates all of that.
What is this TPM?
May be you can help me to write template that make from 'Doyle, Arthur Conan' --> Doyle, A. C. ?
Accel is offline   Reply With Quote
Old 07-07-2014, 05:06 PM   #519
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,653
Karma: 1137414
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by Accel View Post
What is this TPM?
May be you can help me to write template that make from 'Doyle, Arthur Conan' --> Doyle, A. C. ?
TPM is Template Program Mode.

A template that produces what you want for the example you provided is
Code:
{author_sort:'re($, '([, ]+)(\w)\w*', '\1\2.')'}
I don't know it it will produce the right answer in all cases.
chaley is offline   Reply With Quote
Old 07-07-2014, 05:49 PM   #520
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
Posts: 6,538
Karma: 10990232
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by chaley View Post
TPM is Template Program Mode.

A template that produces what you want for the example you provided is
Code:
{author_sort:'re($, '([, ]+)(\w)\w*', '\1\2.')'}
I don't know it it will produce the right answer in all cases.
It truncates everything after the first word. Including the second author's first name (since it includes "& LN,[...]").

This should work, though:

Code:
program:

re(
	field('author_sort'),
	'(\w)\w+\b(?!,)',
	'\1.'
)

At some point I thought I'd try list_re to fix your example.

But I discovered this:

Code:
program:

list_re(
	field('author_sort'),
	'&',
	'(.*)',
	'\1'
)
gave me "LN1&FN1&LN2&FN2" -- isn't it supposed to search for "(.*)" and replace with "\1" on each list element where "&" is the separator? I cannot imagine what I might be doing wrong. But this looks completely crazy.

Last edited by eschwartz; 07-07-2014 at 05:56 PM.
eschwartz is offline   Reply With Quote
Old 07-08-2014, 08:34 AM   #521
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,653
Karma: 1137414
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by eschwartz View Post

At some point I thought I'd try list_re to fix your example.

But I discovered this:

Code:
program:

list_re(
	field('author_sort'),
	'&',
	'(.*)',
	'\1'
)
gave me "LN1&FN1&LN2&FN2" -- isn't it supposed to search for "(.*)" and replace with "\1" on each list element where "&" is the separator? I cannot imagine what I might be doing wrong. But this looks completely crazy.
It works fine for me. The names come out exactly as they went in, except that the spaces are gone from around the &. I have no idea why you are seeing what you are seeing.

BTW: a better fix would be to use the new function list_re_group so you can separate the identification of which names to include from the munging of the names.
chaley is offline   Reply With Quote
Old 07-08-2014, 03:30 PM   #522
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
Posts: 6,538
Karma: 10990232
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Hmm, weird.

Anyway, I thought the only thing list_re_group() did was to apply templates and stuff to replacements in a list -- I just realized you can limit what gets passed to the re_group with a separator AND a regex.

P.S. The documentation for all three functions you added is a little weird, indented plus list_re_group is referred to as list_re (the second one???) in template_ref.html.

The indents I believe are because the documentation builder does hierarchical bulleted lists when it sees tabs. You indented with tabs, which is usually reasonable. All of Kovid's functions are indented with four spaces.

https://bugs.launchpad.net/calibre/+bug/1339296
eschwartz is offline   Reply With Quote
Old 07-16-2014, 02:08 AM   #523
BetterRed
null operator
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 3,623
Karma: 2183656
Join Date: Mar 2012
Location: NSW Australia
Device: none
How can the Series number be shown in Roman Numerals in the Book Jacket.

The setting in Look & Feel does not appear to have any effect on the Book Jacket. So wondered if it's possible to overcome with something in

Code:
%CALIBRE_CONFIG_DIRECTORY%\resources\catalog\template.xhtml
See this thread for discussion Roman Numerals for series and on book jacket

BR

Last edited by BetterRed; 07-16-2014 at 02:12 AM.
BetterRed is online now   Reply With Quote
Old 08-24-2014, 10:48 AM   #524
nynaevelan
eBook Junkie
nynaevelan ought to be getting tired of karma fortunes by now.nynaevelan ought to be getting tired of karma fortunes by now.nynaevelan ought to be getting tired of karma fortunes by now.nynaevelan ought to be getting tired of karma fortunes by now.nynaevelan ought to be getting tired of karma fortunes by now.nynaevelan ought to be getting tired of karma fortunes by now.nynaevelan ought to be getting tired of karma fortunes by now.nynaevelan ought to be getting tired of karma fortunes by now.nynaevelan ought to be getting tired of karma fortunes by now.nynaevelan ought to be getting tired of karma fortunes by now.nynaevelan ought to be getting tired of karma fortunes by now.
 
nynaevelan's Avatar
 
Posts: 1,449
Karma: 1459924
Join Date: May 2010
Location: USA
Device: Kindle Fire 6 2014, Kindle PW2, Galaxy Note 3
Hi All:

I have been having trouble with a save_to_disk plugboard that does not seem to be working but I cannot figure out why.
Code:
This is my plugboard:  {#purchased1:.7} - {title_sort} - {author} - {tags}
For whatever reason it is not working. Could I have some conflicting setup that is overriding the plugboard or maybe something is wrong with it??
nynaevelan is offline   Reply With Quote
Old 08-25-2014, 02:37 AM   #525
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
Posts: 6,538
Karma: 10990232
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by nynaevelan View Post
Hi All:

I have been having trouble with a save_to_disk plugboard that does not seem to be working but I cannot figure out why.
Code:
This is my plugboard:  {#purchased1:.7} - {title_sort} - {author} - {tags}
For whatever reason it is not working. Could I have some conflicting setup that is overriding the plugboard or maybe something is wrong with it??
What are you getting instead?

(The template itself is valid.)

I cannot think of anything that would override Preferences ==> Import/Export ==> Saving books to disk.
eschwartz is offline   Reply With Quote
Reply

Tags
custom column

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
custom column i need a little help shinken Calibre 3 09-15-2010 03:41 AM
Using Custom Metadata in Save Template EJvdH Calibre 1 07-02-2010 06:06 AM
Accessories Decalgirl Kindle 2 custom skin template srmalloy Amazon Kindle 6 04-09-2010 09:55 PM
Donations for Custom Recipes ddavtian Calibre 5 01-23-2010 04:54 PM
Help understanding custom recipes andersent Calibre 0 12-17-2009 02:37 PM


All times are GMT -4. The time now is 06:05 PM.


MobileRead.com is a privately owned, operated and funded community.