Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Commit 37add49

Browse files
author
jodiew
committed
Add kernel inspect hook
1 parent 9b570a8 commit 37add49

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

jupyter/seq_kernel/kernel.py

+15
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,18 @@ def do_execute(self, code, silent, store_history=True, user_expressions=None, al
6363

6464
return {'status': 'ok', 'execution_count': self.execution_count,
6565
'payload': [], 'user_expressions': {}}
66+
67+
def _get_object(self, code, cursor_pos):
68+
# TODO: Get the correct section of code to be inspected
69+
left = code[:cursor_pos].rsplit(' ', 1)[-1]
70+
right = code[cursor_pos:].split(' ', 1)[0]
71+
return left + right
72+
73+
def do_inspect(self, code, cursor_pos, detail_level=0):
74+
data = self.seqwrapper.inspect(self._get_object(code, cursor_pos), detail_level)
75+
return {
76+
'status': 'ok',
77+
'found': True,
78+
'data': data,
79+
'metadata': {}
80+
}

jupyter/seq_kernel/wrapper.py

+6
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ def __init__(self):
1313

1414
def exec(self, code):
1515
self._exec_fn(self.handle, code.encode('utf-8'))
16+
17+
def inspect(self, request_object, detail_level):
18+
# TODO: Inspect the requested object and return the doc and/or source
19+
return {
20+
'text/plain': f'Hello, World! {request_object} {detail_level}'
21+
}

0 commit comments

Comments
 (0)