]>
jfr.im git - z_archive/twitter.git/blob - twitter/util.py
2 Internal utility functions.
4 `htmlentitydecode` came from here:
5 http://wiki.python.org/moin/EscapingHtml
12 from html
.entities
import name2codepoint
15 from htmlentitydefs
import name2codepoint
17 def htmlentitydecode(s
):
19 '&(%s);' % '|'.join(name2codepoint
),
20 lambda m
: unichr(name2codepoint
[m
.group(1)]), s
)
22 def smrt_input(globals_
, locals_
, ps1
=">>> ", ps2
="... "):
29 inputs
.append(input(prompt
))
31 ret
= eval('\n'.join(inputs
), globals_
, locals_
)
38 def printNicely(string
):
39 if hasattr(sys
.stdout
, 'buffer'):
40 sys
.stdout
.buffer.write(string
.encode('utf8'))
43 print(string
.encode('utf8'))
45 __all__
= ["htmlentitydecode", "smrt_input"]