mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-08-02 19:24:06 +00:00
This enables interactive state exploration of britney's internals for a given data set. Signed-off-by: Niels Thykier <niels@thykier.net>
33 lines
672 B
Python
33 lines
672 B
Python
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
|
|
|