aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/livestreamer/packages/flashmedia/compat.py
blob: 739e2860573ff7e45733118644e26e6b9cbf3503 (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
import os
import sys

is_py2 = (sys.version_info[0] == 2)
is_py3 = (sys.version_info[0] == 3)
is_win32 = os.name == "nt"

if is_py2:
    _str = str
    str = unicode

    def bytes(b=None, enc="ascii"):
        if b is None:
            return ""
        elif isinstance(b, list) or isinstance(b, tuple):
            return "".join([chr(i) for i in b])
        else:
            return _str(b)

    from StringIO import StringIO as BytesIO

elif is_py3:
    bytes = bytes
    str = str
    from io import BytesIO


try:
    from collections import OrderedDict
except ImportError:
    from .ordereddict import OrderedDict

__all__ = ["is_py2", "is_py3", "is_win32", "str", "bytes", "BytesIO", "OrderedDict"]