Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
searx-engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
searx-engine
Commits
0969e50c
Commit
0969e50c
authored
Dec 01, 2017
by
Adam Tauber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] convert json engine result attributes to string - closes #1006
parent
a065fcdc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
json_engine.py
searx/engines/json_engine.py
+11
-2
utils.py
searx/utils.py
+12
-0
No files found.
searx/engines/json_engine.py
View file @
0969e50c
...
...
@@ -2,6 +2,7 @@ from collections import Iterable
from
json
import
loads
from
sys
import
version_info
from
searx.url_utils
import
urlencode
from
searx.utils
import
to_string
if
version_info
[
0
]
==
3
:
unicode
=
str
...
...
@@ -111,14 +112,22 @@ def response(resp):
content
=
query
(
result
,
content_query
)[
0
]
except
:
content
=
""
results
.
append
({
'url'
:
url
,
'title'
:
title
,
'content'
:
content
})
results
.
append
({
'url'
:
to_string
(
url
),
'title'
:
to_string
(
title
),
'content'
:
to_string
(
content
),
})
else
:
for
url
,
title
,
content
in
zip
(
query
(
json
,
url_query
),
query
(
json
,
title_query
),
query
(
json
,
content_query
)
):
results
.
append
({
'url'
:
url
,
'title'
:
title
,
'content'
:
content
})
results
.
append
({
'url'
:
to_string
(
url
),
'title'
:
to_string
(
title
),
'content'
:
to_string
(
content
),
})
if
not
suggestion_query
:
return
results
...
...
searx/utils.py
View file @
0969e50c
...
...
@@ -7,6 +7,7 @@ import re
from
babel.dates
import
format_date
from
codecs
import
getincrementalencoder
from
imp
import
load_source
from
numbers
import
Number
from
os.path
import
splitext
,
join
from
random
import
choice
import
sys
...
...
@@ -336,3 +337,14 @@ def new_hmac(secret_key, url):
return
hmac
.
new
(
bytes
(
secret_key
),
url
,
hashlib
.
sha256
)
.
hexdigest
()
else
:
return
hmac
.
new
(
bytes
(
secret_key
,
'utf-8'
),
url
,
hashlib
.
sha256
)
.
hexdigest
()
def
to_string
(
obj
):
if
isinstance
(
obj
,
basestring
):
return
obj
if
isinstance
(
obj
,
Number
):
return
unicode
(
obj
)
if
hasattr
(
obj
,
'__str__'
):
return
obj
.
__str__
()
if
hasattr
(
obj
,
'__repr__'
):
return
obj
.
__repr__
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment