2to3: csv (with if python 3)
parent
2f542005d1
commit
28bb4b8647
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
@ -383,8 +385,10 @@ class FeedParser(FeedBase):
|
||||||
out = StringIO()
|
out = StringIO()
|
||||||
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 = [x[1].encode('utf-8') if isinstance(x[1], unicode) else x[1] for x in item] # str
|
if sys.version > '3':
|
||||||
#isinstance(x[1], basestring)] # bytes or str
|
row = [x[1] for x in item]
|
||||||
|
else:
|
||||||
|
row = [x[1].encode('utf-8') if isinstance(x[1], unicode) else x[1] for x in item]
|
||||||
c.writerow(row)
|
c.writerow(row)
|
||||||
out.seek(0)
|
out.seek(0)
|
||||||
return out.read()
|
return out.read()
|
||||||
|
|
Loading…
Reference in New Issue