本文整理汇总了Python中IPython.nbformat.current.NotebookNode.html方法的典型用法代码示例。如果您正苦于以下问题:Python NotebookNode.html方法的具体用法?Python NotebookNode.html怎么用?Python NotebookNode.html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython.nbformat.current.NotebookNode
的用法示例。
在下文中一共展示了NotebookNode.html方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_cell
# 需要导入模块: from IPython.nbformat.current import NotebookNode [as 别名]
# 或者: from IPython.nbformat.current.NotebookNode import html [as 别名]
def run_cell(self, cell):
'''
Run a notebook cell and update the output of that cell in-place.
'''
if _debugging: logging.debug('Running cell:\n%s\n', cell.input)
self.shell.execute(cell.input)
reply = self.shell.get_msg()
status = reply['content']['status']
if status == 'error':
logging.info('Cell raised uncaught exception: \n%s', '\n'.join(reply['content']['traceback']))
else:
if _debugging: logging.debug('Cell returned')
outs = list()
while True:
try:
msg = self.iopub.get_msg(timeout=1)
if msg['msg_type'] == 'status':
if msg['content']['execution_state'] == 'idle':
break
except Empty:
# execution state should return to idle before the queue becomes empty,
# if it doesn't, something bad has happened
logging.warn('Execution state did not return to idle')
raise
content = msg['content']
msg_type = msg['msg_type']
out = NotebookNode(output_type=msg_type)
if 'execution_count' in content:
cell['prompt_number'] = content['execution_count']
out.prompt_number = content['execution_count']
if msg_type in ['status', 'pyin']:
continue
elif msg_type == 'stream':
out.stream = content['name']
out.html = RClansiconv(content['data'])
elif msg_type in ('display_data', 'pyout'):
for mime, data in content['data'].items():
try:
attr = self.MIME_MAP[mime]
except KeyError:
logging.warning('unhandled mime type: %s' % mime)
raise NotImplementedError('unhandled mime type: %s' % mime)
if attr == 'text':
if _debugging: logging.info(data)
setattr(out, attr, RClansiconv(data))
else:
setattr(out, attr, data)
elif msg_type == 'pyerr':
logging.info('Received an exception: ' + content['ename'])
out.ename = content['ename']
out.evalue = content['evalue']
out.traceback = content['traceback']
out.html = RClansiconv('\n'.join(out.traceback))
else:
raise NotImplementedError('unhandled iopub message: %s' % msg_type)
outs.append(out)
cell['outputs'] = outs