from textwrap import dedent
kernel
The latest documentation for implementing a wrapper kernel is here, but the current code deviates from those instructions (which call for inheriting from kernelbase.Kernel), instead inheriting from the IPython kernel implementation, IPythonKernel.
For a diagram of the main dependencies among the principal nbstata modules, click here.
PyStataKernel
PyStataKernel (**kwargs)
A jupyter kernel based on pystata
Config and Stata initialization
Stata is initialized during the execution of the first cell (in PyStataKernel.do_execute
below) so that any configuration errors can be displayed in the notebook.
PyStataKernel.init_session
PyStataKernel.init_session ()
Stata code execution (and error display)
print_stata_error
print_stata_error (text)
"""\
print_stata_error(dedent( output prior to error
error message
error code
"""))
output prior to error
error message
error code
"1": "5 + 1"}) _user_expressions({
{'1': {'status': 'ok', 'data': {'text/plain': '6'}, 'metadata': {}}}
"1": "sam"}) _user_expressions({
sam not found
Invalid Stata '[%fmt] [=]exp' display expression: sam
{'1': {'status': 'error',
'traceback': [],
'ename': 'Stata user expression error',
'evalue': "sam not found\n\nInvalid Stata '[%fmt] [=]exp' display expression: sam"}}
PyStataKernel.post_do_hook
PyStataKernel.post_do_hook ()
PyStataKernel.do_execute
PyStataKernel.do_execute (code, silent, store_history=True, user_expressions=None, allow_stdin=False)
Execute Stata code cell
Other kernel capabilities
PyStataKernel.do_inspect
PyStataKernel.do_inspect (code, cursor_pos, detail_level=0, omit_sections=())
Display Stata ‘describe’ output (regardless of cursor position)
PyStataKernel.do_complete
PyStataKernel.do_complete (code, cursor_pos)
Provide context-aware tab-autocomplete suggestions
PyStataKernel.do_is_complete
PyStataKernel.do_is_complete (code)
Overrides IPythonKernel with kernelbase default
PyStataKernel.do_history
PyStataKernel.do_history (hist_access_type, output, raw, session=None, start=None, stop=None, n=None, pattern=None, unique=False)
Overrides IPythonKernel with kernelbase default