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
3d6c6795
Commit
3d6c6795
authored
Nov 21, 2017
by
Adam Tauber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] resurrect csv output in py2
parent
9ab85364
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
utils.py
searx/utils.py
+13
-9
No files found.
searx/utils.py
View file @
3d6c6795
...
...
@@ -29,6 +29,9 @@ except:
if
sys
.
version_info
[
0
]
==
3
:
unichr
=
chr
unicode
=
str
IS_PY2
=
False
else
:
IS_PY2
=
True
logger
=
logger
.
getChild
(
'utils'
)
...
...
@@ -159,19 +162,20 @@ class UnicodeWriter:
self
.
encoder
=
getincrementalencoder
(
encoding
)()
def
writerow
(
self
,
row
):
unicode_row
=
[]
for
col
in
row
:
if
type
(
col
)
==
str
or
type
(
col
)
==
unicode
:
unicode_row
.
append
(
col
.
encode
(
'utf-8'
)
.
strip
())
else
:
unicode_row
.
append
(
col
)
self
.
writer
.
writerow
([
x
.
decode
(
'utf-8'
)
if
hasattr
(
x
,
'decode'
)
else
x
for
x
in
unicode_row
])
if
IS_PY2
:
row
=
[
s
.
encode
(
"utf-8"
)
if
hasattr
(
s
,
'encode'
)
else
s
for
s
in
row
]
self
.
writer
.
writerow
(
row
)
# Fetch UTF-8 output from the queue ...
data
=
self
.
queue
.
getvalue
()
.
strip
(
'
\x00
'
)
data
=
self
.
queue
.
getvalue
()
if
IS_PY2
:
data
=
data
.
decode
(
"utf-8"
)
# ... and reencode it into the target encoding
data
=
self
.
encoder
.
encode
(
data
)
# write to the target stream
self
.
stream
.
write
(
data
.
decode
(
'utf-8'
))
if
IS_PY2
:
self
.
stream
.
write
(
data
)
else
:
self
.
stream
.
write
(
data
.
decode
(
"utf-8"
))
# empty queue
self
.
queue
.
truncate
(
0
)
...
...
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