]>
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
14 from htmlentitydefs
import name2codepoint
16 def htmlentitydecode(s
):
18 '&(%s);' % '|'.join(name2codepoint
),
19 lambda m
: chr(name2codepoint
[m
.group(1)]), s
)
21 def smrt_input(globals_
, locals_
, ps1
=">>> ", ps2
="... "):
28 inputs
.append(input(prompt
))
30 ret
= eval('\n'.join(inputs
), globals_
, locals_
)
37 def printNicely(string
):
38 if hasattr(sys
.stdout
, 'buffer'):
39 sys
.stdout
.buffer.write(string
.encode('utf8'))
42 print(string
.encode('utf8'))
44 __all__
= ["htmlentitydecode", "smrt_input"]