E-book viewer: Fix a regression that broke adding of new lookup sources. Fixes #1992278 [Could not add extra lookup sources](https://bugs.launchpad.net/calibre/+bug/1992278)

This commit is contained in:
Kovid Goyal 2022-10-09 20:23:07 +05:30
parent a1d2209fc7
commit 25c0b827c4
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -32,6 +32,15 @@ def lookup_lang():
return ans return ans
special_processors = {}
def special_processor(func):
special_processors[func.__name__] = func
return func
@special_processor
def google_dictionary(word): def google_dictionary(word):
ans = f'https://www.google.com/search?q=define:{word}' ans = f'https://www.google.com/search?q=define:{word}'
lang = lookup_lang() lang = lookup_lang()
@ -44,7 +53,7 @@ vprefs.defaults['lookup_locations'] = [
{ {
'name': 'Google dictionary', 'name': 'Google dictionary',
'url': 'https://www.google.com/search?q=define:{word}', 'url': 'https://www.google.com/search?q=define:{word}',
'special_processor': google_dictionary, 'special_processor': 'google_dictionary',
'langs': [], 'langs': [],
}, },
@ -393,7 +402,7 @@ class Lookup(QWidget):
def special_processor(self): def special_processor(self):
idx = self.source_box.currentIndex() idx = self.source_box.currentIndex()
if idx > -1: if idx > -1:
return self.source_box.itemData(idx).get('special_processor') return special_processors.get(self.source_box.itemData(idx).get('special_processor'))
@property @property
def query_is_up_to_date(self): def query_is_up_to_date(self):