add info and colored
[rainbowstream.git] / rainbowstream / py3patch.py
1 import sys
2
3 # Library compatibility
4 # StringIO module
5 try:
6 from StringIO import StringIO, BytesIO
7 except:
8 from io import StringIO, BytesIO
9
10 # HTMLParser module
11 if sys.version[0] == "2":
12 from HTMLParser import HTMLParser
13 else:
14 from html.parser import HTMLParser
15 unescape = HTMLParser().unescape
16 # According to https://github.com/python/cpython/blob/master/Lib/html/parser.py#L547 ,
17 # in python 3.5 maybe I should use
18 # from html import unescape
19 # but it is a far-future story:)
20
21
22 # Function compatibility
23 # xrange, raw_input, map ,unicde
24 if sys.version[0] == "2":
25 lmap = lambda f, a: map(f, a)
26 str2u = lambda x: x.decode('utf-8')
27 u2str = lambda x: x.encode('utf-8')
28 else:
29 xrange = range
30 raw_input = input
31 lmap = lambda f, a: list(map(f, a))
32 str2u = u2str = lambda x: x