Commit acf692cd authored by Yusei Tahara's avatar Yusei Tahara

erp5_data_notebook: Support _repr_html_. Object such as pandas' DataFrame is...

erp5_data_notebook: Support _repr_html_. Object such as pandas' DataFrame is rendered as HTML in Jupyter.
parent 113ea42c
......@@ -176,6 +176,9 @@ def matplotlib_post_run(data_list):
class Displayhook(object):
def hook(self, value):
if value is not None:
if getattr(value, '_repr_html_', None) is not None:
self.result = {'data':{'text/html':value._repr_html_()}, 'metadata':{}}
else:
self.result = repr(value)
def pre_run(self):
self.old_hook = sys.displayhook
......@@ -481,7 +484,10 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
displayhook_result = {"data":{}, "metadata":{}}
if displayhook.result is not None:
if isinstance(displayhook.result, str):
displayhook_result["data"]["text/plain"] = displayhook.result
elif isinstance(displayhook.result, dict):
displayhook_result = displayhook.result
result = {
'result_string': output,
'print_result': {"data":{"text/plain":output}, "metadata":{}},
......
......@@ -46,13 +46,12 @@
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W:312, 10: Use of exec (exec-used)</string>
<string>W:355, 10: Use of exec (exec-used)</string>
<string>W:368, 10: Use of exec (exec-used)</string>
<string>W:453, 6: No exception type(s) specified (bare-except)</string>
<string>W:706, 6: Use of exec (exec-used)</string>
<string>W:932, 2: Redefining name \'IFrame\' from outer scope (line 4) (redefined-outer-name)</string>
<string>W: 18, 0: Unused log imported from Products.ERP5Type.Log (unused-import)</string>
<string>W:390, 10: Use of exec (exec-used)</string>
<string>W:433, 10: Use of exec (exec-used)</string>
<string>W:446, 10: Use of exec (exec-used)</string>
<string>W:539, 6: No exception type(s) specified (bare-except)</string>
<string>W:851, 6: Use of exec (exec-used)</string>
<string>W:1086, 2: Redefining name \'IFrame\' from outer scope (line 4) (redefined-outer-name)</string>
</tuple>
</value>
</item>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment