aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/livestreamer/compat.py
blob: 48a6718b614bff73d627100bcb7e67dcfff9329b (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
#!/usr/bin/env python

import sys

is_py2 = (sys.version_info[0] == 2)
is_py3 = (sys.version_info[0] == 3)

if is_py2:
    str = unicode

    def bytes(b, enc="ascii"):
        return str(b)

elif is_py3:
    str = str
    bytes = bytes

try:
    import urllib.request as urllib
except ImportError:
    import urllib2 as urllib

try:
    from urllib.parse import urlparse, parse_qs
except ImportError:
    from urlparse import urlparse, parse_qs