summaryrefslogtreecommitdiff
path: root/tablib/compat.py
blob: 48e00819c199a2e566f4a950f98fb2d866f2ff7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- 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
    import tablib.packages.xlwt3 as xlwt
    from tablib.packages import markup3 as markup
    from tablib.packages import openpyxl3 as openpyxl

    # py3 mappings
    ifilter = filter
    xrange = range
    unicode = str
    bytes = bytes
    basestring = str

else:
    from cStringIO import StringIO as BytesIO
    import tablib.packages.xlwt as xlwt
    from tablib.packages import markup
    from itertools import ifilter
    from tablib.packages import openpyxl

    # py2 mappings
    xrange = xrange
    unicode = unicode
    bytes = str
    basestring = basestring