morss: fix csv output encoding
parent
78cea10ead
commit
b0f80c6d3c
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue