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