diff options
author | Dalf <alex@al-f.net> | 2020-08-06 17:42:46 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2020-09-10 10:39:04 +0200 |
commit | 1022228d950c2a809ed613df1a515d9a6cafda7c (patch) | |
tree | d792dddea1a5b278b018ed4e024cd13340d5c1b1 /searx/results.py | |
parent | 272158944bf13503e2597018fc60a00baddec660 (diff) | |
download | searxng-1022228d950c2a809ed613df1a515d9a6cafda7c.tar.gz searxng-1022228d950c2a809ed613df1a515d9a6cafda7c.zip |
Drop Python 2 (1/n): remove unicode string and url_utils
Diffstat (limited to 'searx/results.py')
-rw-r--r-- | searx/results.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/searx/results.py b/searx/results.py index df2e3e78d..51af32fd0 100644 --- a/searx/results.py +++ b/searx/results.py @@ -1,14 +1,11 @@ import re -import sys from collections import defaultdict from operator import itemgetter from threading import RLock +from urllib.parse import urlparse, unquote from searx import logger from searx.engines import engines -from searx.url_utils import urlparse, unquote -if sys.version_info[0] == 3: - basestring = str CONTENT_LEN_IGNORED_CHARS_REGEX = re.compile(r'[,;:!?\./\\\\ ()-_]', re.M | re.U) WHITESPACE_REGEX = re.compile('( |\t|\n)+', re.M | re.U) @@ -16,7 +13,7 @@ WHITESPACE_REGEX = re.compile('( |\t|\n)+', re.M | re.U) # return the meaningful length of the content for a result def result_content_len(content): - if isinstance(content, basestring): + if isinstance(content, str): return len(CONTENT_LEN_IGNORED_CHARS_REGEX.sub('', content)) else: return 0 @@ -161,11 +158,11 @@ class ResultContainer(object): self._number_of_results.append(result['number_of_results']) else: # standard result (url, title, content) - if 'url' in result and not isinstance(result['url'], basestring): + if 'url' in result and not isinstance(result['url'], str): logger.debug('result: invalid URL: %s', str(result)) - elif 'title' in result and not isinstance(result['title'], basestring): + elif 'title' in result and not isinstance(result['title'], str): logger.debug('result: invalid title: %s', str(result)) - elif 'content' in result and not isinstance(result['content'], basestring): + elif 'content' in result and not isinstance(result['content'], str): logger.debug('result: invalid content: %s', str(result)) else: self._merge_result(result, standard_result_count + 1) |