3434
3535
3636# %% auto 0
37- __all__ = ['CaptureShell' , 'format_exc' , 'render_outputs' , 'find_output' , 'out_exec' , 'out_stream' , 'out_error' , 'exec_nb ' ,
38- 'SmartCompleter' ]
37+ __all__ = ['CaptureShell' , 'format_exc' , 'NbResult' , ' render_outputs' , 'find_output' , 'out_exec' , 'out_stream' , 'out_error' ,
38+ 'exec_nb' , ' SmartCompleter' ]
3939
4040# %% ../nbs/02_shell.ipynb
4141class _CustDisplayHook (DisplayHook ):
@@ -102,6 +102,9 @@ def format_exc(e):
102102 "Format exception `e` as a string list"
103103 return traceback .format_exception (type (e ), e , e .__traceback__ )
104104
105+ # %% ../nbs/02_shell.ipynb
106+ class NbResult (list ): pass
107+
105108# %% ../nbs/02_shell.ipynb
106109def _out_stream (text , name ): return dict (name = name , output_type = 'stream' , text = text .splitlines (True ))
107110def _out_exc (e ):
@@ -122,13 +125,15 @@ def _mk_out(data, meta, output_type='display_data'):
122125 return dict (data = fd , metadata = meta , output_type = output_type )
123126
124127def _out_nb (o , fmt ):
125- res = []
128+ res = NbResult ()
126129 if o .stdout : res .append (_out_stream (o .stdout , 'stdout' ))
127130 if o .stderr : res .append (_out_stream (o .stderr , 'stderr' ))
128131 if o .exception : res .append (_out_exc (o .exception ))
129132 r = o .result .result
133+ if hasattr (r , '__ft__' ): r = r .__ft__ ()
134+ res .result = r
130135 for x in o .display_objects : res .append (_mk_out (x .data , x .metadata ))
131- if r is not None and not o .quiet :
136+ if r is not None and not o .quiet and not isinstance_str ( r , 'FT' ) :
132137 res .append (_mk_out (* fmt .format (r ), 'execute_result' ))
133138 if 'execution_count' not in o : o ['execution_count' ]= None
134139 for p in res :
0 commit comments