Add compatibility with PyQt5 and python3.

PyQt5 is used by calibre since version 2.0.

Python3 is used by calibre since version 5.0.
This commit is contained in:
ibu ☉ radempa 2020-12-26 11:36:52 +00:00
parent fad3ed537f
commit 208bcae522

View file

@ -2,13 +2,17 @@ __license__ = 'GPL 3'
__copyright__ = '2012, Ruben Pollan <meskio@sindominio.net>' __copyright__ = '2012, Ruben Pollan <meskio@sindominio.net>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import urllib2 try:
from contextlib import closing from urllib.parse import quote
except:
import json from urllib2 import quote
try:
from PyQt5.Qt import QUrl
except:
from PyQt4.Qt import QUrl from PyQt4.Qt import QUrl
from contextlib import closing
import json
from calibre import browser from calibre import browser
from calibre.gui2 import open_url from calibre.gui2 import open_url
from calibre.gui2.store import StorePlugin from calibre.gui2.store import StorePlugin
@ -30,7 +34,7 @@ class TheAnarchistLibraryStore(BasicStoreConfig, StorePlugin):
d.exec_() d.exec_()
def search(self, query, max_results=10, timeout=60): def search(self, query, max_results=10, timeout=60):
url = 'http://theanarchistlibrary.org/search?fmt=json&query=' + urllib2.quote(query) url = 'http://theanarchistlibrary.org/search?fmt=json&query=' + quote(query)
br = browser() br = browser()