mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 23:10:17 +00:00
80e72cfa27
Switch csv library to backports.csv as the implementation is closer to the python 3 one. Add a test case covering the problem. Run tests with unicode_literals from future Fix unicode encode errors with unicode characters - Use `backports.csv` instead of `unicodecsv` - Use StringIO instead of cStringIO - Clean-up some Python 2 specific code
49 lines
833 B
Python
49 lines
833 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
tablib.compat
|
|
~~~~~~~~~~~~~
|
|
|
|
Tablib compatiblity module.
|
|
|
|
"""
|
|
|
|
import sys
|
|
|
|
is_py3 = (sys.version_info[0] > 2)
|
|
|
|
|
|
|
|
try:
|
|
from collections import OrderedDict
|
|
except ImportError:
|
|
from tablib.packages.ordereddict import OrderedDict
|
|
|
|
|
|
if is_py3:
|
|
from io import BytesIO
|
|
from tablib.packages import markup3 as markup
|
|
import tablib.packages.dbfpy3 as dbfpy
|
|
|
|
import csv
|
|
from io import StringIO
|
|
# py3 mappings
|
|
|
|
ifilter = filter
|
|
unicode = str
|
|
bytes = bytes
|
|
basestring = str
|
|
xrange = range
|
|
|
|
else:
|
|
from cStringIO import StringIO as BytesIO
|
|
from StringIO import StringIO
|
|
from tablib.packages import markup
|
|
from itertools import ifilter
|
|
|
|
from backports import csv
|
|
import tablib.packages.dbfpy as dbfpy
|
|
|
|
unicode = unicode
|
|
xrange = xrange
|