This enables interactive state exploration of britney's internals for a given data set. Signed-off-by: Niels Thykier <niels@thykier.net>ubuntu/rebased
parent
8d5805b8de
commit
35aed10291
@ -0,0 +1,32 @@
|
|||||||
|
import code
|
||||||
|
|
||||||
|
|
||||||
|
class SubInterpreterExit(SystemExit):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def console_quit():
|
||||||
|
raise SubInterpreterExit()
|
||||||
|
|
||||||
|
|
||||||
|
def run_python_console(britney_obj):
|
||||||
|
console_locals = {
|
||||||
|
'britney': britney_obj,
|
||||||
|
'__name__': '__console__',
|
||||||
|
'__doc__': None,
|
||||||
|
'quit': console_quit,
|
||||||
|
'exit': console_quit,
|
||||||
|
}
|
||||||
|
console = code.InteractiveConsole(locals=console_locals)
|
||||||
|
banner = """\
|
||||||
|
Interactive python (REPL) shell in britney.
|
||||||
|
|
||||||
|
Locals available
|
||||||
|
* britney: Instance of the Britney object.
|
||||||
|
* quit()/exit(): leave this REPL console.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
console.interact(banner=banner, exitmsg='')
|
||||||
|
except SubInterpreterExit:
|
||||||
|
pass
|
||||||
|
|
Loading…
Reference in new issue