fix document
[rainbowstream.git] / rainbowstream / py3patch.py
CommitLineData
c3bab4ef 1import sys
2
95baa044 3# Library compatibility
c3bab4ef 4# StringIO module
5try:
77f1d210 6 from StringIO import StringIO, BytesIO
c3bab4ef 7except:
77f1d210 8 from io import StringIO, BytesIO
c3bab4ef 9
b2cde062 10# HTMLParser module
3f6bfc20 11if sys.version[0] == "2":
b2cde062 12 from HTMLParser import HTMLParser
3f6bfc20
O
13else:
14 from html.parser import HTMLParser
15unescape = 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:)
b2cde062 20
95baa044
O
21
22# Function compatibility
23# xrange, raw_input, map ,unicde
3f6bfc20
O
24if sys.version[0] == "2":
25 lmap = lambda f, a: map(f, a)
7c437a0f
O
26 str2u = lambda x: x.decode('utf-8')
27 u2str = lambda x: x.encode('utf-8')
3f6bfc20 28else:
13e6b275 29 xrange = range
c3bab4ef 30 raw_input = input
422dd385 31 lmap = lambda f, a: list(map(f, a))
7c437a0f 32 str2u = u2str = lambda x: x