View Single Post
Old 08-13-2014, 10:29 AM   #82
kacir
Wizard
kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.
 
kacir's Avatar
 
Posts: 3,463
Karma: 10684861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
I use AutoKey program for automating certain tasks.
One example is searching for author in Calibre in such a way that it doesn't matter whether I have firstname lastname or lastname, firstname.

Program that is run when I press F2 in my AutoKey is:
Code:
#### Beginning of the Script for F2 hotkey ####
import re

contents = clipboard.get_clipboard()

# re.sub(pattern, repl, string, count=0, flags=0)
output = re.sub(r'([^ ,]*),? (.*)', r'authors:"\1" and authors:"\2"', contents)

keyboard.send_keys(output)
#### End of the Script for F2 hotkey ####
It works in a simple way:
I find somewhere (Calibre itself, or Internet or any text) name of the author, I copy the name such as:
Hugo, Victor
to the clipboard, then I go to Calibre, position cursor to the Search bar and press F2. I get the following
authors:"Hugo" and authors:"Victor"
Well, I *used* to get that. In Beta when I use this script, I get
authors.;hugo; and authors.;victor;
In any other program where I can enter text this works OK.

My system:
Spoiler:

kacir@Petra:~ > calibre-debug -g
calibre 1.205 isfrozen: True is64bit: True
Linux-3.11.0-12-generic-x86_64-with-debian-wheezy-sid Linux ('64bit', 'ELF')
('Linux', '3.11.0-12-generic', '#19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013')
Python 2.7.8
Linux: ('debian', 'wheezy/sid', '')


I can (and probably will) find a workaround by extending my script from four lines to eight ;-), but this behavior might indicate some problem.

I used to have this tiny hack built into Calibre as modification to the "find similar books" function, and I have even tried to persuade you to put it into main trunk.
kacir is offline   Reply With Quote