summaryrefslogtreecommitdiff
path: root/searx/plugins
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2016-11-30 18:43:03 +0100
committerAdam Tauber <asciimoo@gmail.com>2017-05-15 12:02:30 +0200
commit52e615dede8538c36f569d2cf07835427a9a0db6 (patch)
treeac65990c72156def2d49e81d981f0b3beda4fd2e /searx/plugins
parent46a2c63f8e1c3819cceff2d61fe9106051e8ecee (diff)
downloadsearxng-52e615dede8538c36f569d2cf07835427a9a0db6.tar.gz
searxng-52e615dede8538c36f569d2cf07835427a9a0db6.zip
[enh] py3 compatibility
Diffstat (limited to 'searx/plugins')
-rw-r--r--searx/plugins/__init__.py5
-rw-r--r--searx/plugins/doai_rewrite.py2
-rw-r--r--searx/plugins/https_rewrite.py5
-rw-r--r--searx/plugins/self_info.py4
-rw-r--r--searx/plugins/tracker_url_remover.py2
5 files changed, 12 insertions, 6 deletions
diff --git a/searx/plugins/__init__.py b/searx/plugins/__init__.py
index 011d36260..46c1f8918 100644
--- a/searx/plugins/__init__.py
+++ b/searx/plugins/__init__.py
@@ -14,9 +14,12 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
(C) 2015 by Adam Tauber, <asciimoo@gmail.com>
'''
-from sys import exit
+from sys import exit, version_info
from searx import logger
+if version_info[0] == 3:
+ unicode = str
+
logger = logger.getChild('plugins')
from searx.plugins import (doai_rewrite,
diff --git a/searx/plugins/doai_rewrite.py b/searx/plugins/doai_rewrite.py
index a6e15ae5a..95efa8f9b 100644
--- a/searx/plugins/doai_rewrite.py
+++ b/searx/plugins/doai_rewrite.py
@@ -1,6 +1,6 @@
from flask_babel import gettext
import re
-from urlparse import urlparse, parse_qsl
+from searx.url_utils import urlparse, parse_qsl
regex = re.compile(r'10\.\d{4,9}/[^\s]+')
diff --git a/searx/plugins/https_rewrite.py b/searx/plugins/https_rewrite.py
index 8b4c9784e..4462c86bc 100644
--- a/searx/plugins/https_rewrite.py
+++ b/searx/plugins/https_rewrite.py
@@ -16,14 +16,17 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
'''
import re
-from urlparse import urlparse
+import sys
from lxml import etree
from os import listdir, environ
from os.path import isfile, isdir, join
from searx.plugins import logger
from flask_babel import gettext
from searx import searx_dir
+from searx.url_utils import urlparse
+if sys.version_info[0] == 3:
+ unicode = str
name = "HTTPS rewrite"
description = gettext('Rewrite HTTP links to HTTPS if possible')
diff --git a/searx/plugins/self_info.py b/searx/plugins/self_info.py
index a2aeda98e..8d6c661ad 100644
--- a/searx/plugins/self_info.py
+++ b/searx/plugins/self_info.py
@@ -22,7 +22,7 @@ default_on = True
# Self User Agent regex
-p = re.compile('.*user[ -]agent.*', re.IGNORECASE)
+p = re.compile(b'.*user[ -]agent.*', re.IGNORECASE)
# attach callback to the post search hook
@@ -31,7 +31,7 @@ p = re.compile('.*user[ -]agent.*', re.IGNORECASE)
def post_search(request, search):
if search.search_query.pageno > 1:
return True
- if search.search_query.query == 'ip':
+ if search.search_query.query == b'ip':
x_forwarded_for = request.headers.getlist("X-Forwarded-For")
if x_forwarded_for:
ip = x_forwarded_for[0]
diff --git a/searx/plugins/tracker_url_remover.py b/searx/plugins/tracker_url_remover.py
index 68a004e33..a84012828 100644
--- a/searx/plugins/tracker_url_remover.py
+++ b/searx/plugins/tracker_url_remover.py
@@ -17,7 +17,7 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
from flask_babel import gettext
import re
-from urlparse import urlunparse
+from searx.url_utils import urlunparse
regexes = {re.compile(r'utm_[^&]+&?'),
re.compile(r'(wkey|wemail)[^&]+&?'),