morss: fix csv output encoding

master
pictuga 2020-04-09 19:05:50 +02:00
parent 78cea10ead
commit b0f80c6d3c
1 changed files with 7 additions and 7 deletions

View File

@ -150,15 +150,15 @@ class ParserBase(object):
c = csv.writer(out, dialect=csv.excel) c = csv.writer(out, dialect=csv.excel)
for item in self.items: for item in self.items:
row = [getattr(item, x) for x in item.dic] c.writerow([getattr(item, x) for x in item.dic])
if encoding != 'unicode':
row = [x.encode(encoding) if isinstance(x, unicode) else x for x in row]
c.writerow(row)
out.seek(0) out.seek(0)
return out.read() out = out.read()
if encoding != 'unicode':
out = out.encode(encoding)
return out
def tohtml(self, **k): def tohtml(self, **k):
return self.convert(FeedHTML).tostring(**k) return self.convert(FeedHTML).tostring(**k)