Merge pull request #156 from Azy8BsKXVko/fix_muting
[rainbowstream.git] / rainbowstream / py3patch.py
... / ...
CommitLineData
1import sys
2
3# Library compatibility
4if sys.version[0] == "2":
5 from HTMLParser import HTMLParser
6 from urllib2 import URLError
7else:
8 from html.parser import HTMLParser
9 from urllib.error import URLError
10
11unescape = HTMLParser().unescape
12# According to https://github.com/python/cpython/blob/master/Lib/html/parser.py#L547 ,
13# in python 3.5 maybe I should use
14# from html import unescape
15# but it is a far-future story:)
16
17
18# Function compatibility
19# xrange, raw_input, map ,unicde
20if sys.version[0] == "2":
21 lmap = lambda f, a: map(f, a)
22 str2u = lambda x: x.decode('utf-8')
23 u2str = lambda x: x.encode('utf-8')
24else:
25 xrange = range
26 raw_input = input
27 lmap = lambda f, a: list(map(f, a))
28 str2u = u2str = lambda x: x