From 208bcae522b211a4dbe1062d108e87dd6e8a2053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ibu=20=E2=98=89=20radempa?= Date: Sat, 26 Dec 2020 11:36:52 +0000 Subject: [PATCH] Add compatibility with PyQt5 and python3. PyQt5 is used by calibre since version 2.0. Python3 is used by calibre since version 5.0. --- .../theanarchistlibrary_plugin.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/theanarchistlibrary_store/theanarchistlibrary_plugin.py b/theanarchistlibrary_store/theanarchistlibrary_plugin.py index 4ee9dce..3b9ff3e 100644 --- a/theanarchistlibrary_store/theanarchistlibrary_plugin.py +++ b/theanarchistlibrary_store/theanarchistlibrary_plugin.py @@ -2,13 +2,17 @@ __license__ = 'GPL 3' __copyright__ = '2012, Ruben Pollan ' __docformat__ = 'restructuredtext en' -import urllib2 +try: + from urllib.parse import quote +except: + from urllib2 import quote +try: + from PyQt5.Qt import QUrl +except: + from PyQt4.Qt import QUrl + from contextlib import closing - import json - -from PyQt4.Qt import QUrl - from calibre import browser from calibre.gui2 import open_url from calibre.gui2.store import StorePlugin @@ -30,7 +34,7 @@ class TheAnarchistLibraryStore(BasicStoreConfig, StorePlugin): d.exec_() 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()