execnb 0.1.11__py3-none-any.whl → 0.1.13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- execnb/__init__.py +1 -1
- execnb/_modidx.py +2 -1
- execnb/shell.py +22 -15
- {execnb-0.1.11.dist-info → execnb-0.1.13.dist-info}/METADATA +19 -6
- execnb-0.1.13.dist-info/RECORD +10 -0
- {execnb-0.1.11.dist-info → execnb-0.1.13.dist-info}/WHEEL +1 -1
- execnb-0.1.11.dist-info/RECORD +0 -10
- {execnb-0.1.11.dist-info → execnb-0.1.13.dist-info}/entry_points.txt +0 -0
- {execnb-0.1.11.dist-info → execnb-0.1.13.dist-info/licenses}/LICENSE +0 -0
- {execnb-0.1.11.dist-info → execnb-0.1.13.dist-info}/top_level.txt +0 -0
execnb/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.1.
|
1
|
+
__version__ = "0.1.13"
|
execnb/_modidx.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Autogenerated by nbdev
|
2
2
|
|
3
|
-
d = { 'settings': { 'branch': '
|
3
|
+
d = { 'settings': { 'branch': 'main',
|
4
4
|
'doc_baseurl': '/execnb/',
|
5
5
|
'doc_host': 'https://AnswerDotAI.github.io',
|
6
6
|
'git_url': 'https://github.com/AnswerDotAI/execnb/',
|
@@ -35,6 +35,7 @@ d = { 'settings': { 'branch': 'master',
|
|
35
35
|
'execnb.shell.CaptureShell.set_path': ('shell.html#captureshell.set_path', 'execnb/shell.py'),
|
36
36
|
'execnb.shell.ExecutionInfo.__repr__': ('shell.html#executioninfo.__repr__', 'execnb/shell.py'),
|
37
37
|
'execnb.shell.ExecutionResult.__repr__': ('shell.html#executionresult.__repr__', 'execnb/shell.py'),
|
38
|
+
'execnb.shell.NbResult': ('shell.html#nbresult', 'execnb/shell.py'),
|
38
39
|
'execnb.shell.SmartCompleter': ('shell.html#smartcompleter', 'execnb/shell.py'),
|
39
40
|
'execnb.shell.SmartCompleter.__call__': ('shell.html#smartcompleter.__call__', 'execnb/shell.py'),
|
40
41
|
'execnb.shell.SmartCompleter.__init__': ('shell.html#smartcompleter.__init__', 'execnb/shell.py'),
|
execnb/shell.py
CHANGED
@@ -7,7 +7,7 @@ from __future__ import annotations
|
|
7
7
|
|
8
8
|
from fastcore.utils import *
|
9
9
|
from fastcore.script import call_parse
|
10
|
-
from fastcore.ansi import ansi2html
|
10
|
+
from fastcore.ansi import ansi2html, strip_ansi
|
11
11
|
|
12
12
|
import multiprocessing,types,traceback,signal
|
13
13
|
try:
|
@@ -17,7 +17,6 @@ except RuntimeError: pass # if re-running cell
|
|
17
17
|
from IPython.core.interactiveshell import InteractiveShell, ExecutionInfo, ExecutionResult
|
18
18
|
from IPython.core.displayhook import DisplayHook
|
19
19
|
from IPython.utils.capture import capture_output
|
20
|
-
from IPython.utils.text import strip_ansi
|
21
20
|
from IPython.core.completer import IPCompleter,provisionalcompleter,Completer
|
22
21
|
from IPython.core.hooks import CommandChainDispatcher
|
23
22
|
from IPython.core.completerlib import module_completer
|
@@ -33,9 +32,10 @@ except ImportError: set_matplotlib_formats = None
|
|
33
32
|
from .nbio import *
|
34
33
|
from .nbio import _dict2obj
|
35
34
|
|
35
|
+
|
36
36
|
# %% auto 0
|
37
|
-
__all__ = ['CaptureShell', 'format_exc', 'render_outputs', 'find_output', 'out_exec', 'out_stream', 'out_error',
|
38
|
-
'SmartCompleter']
|
37
|
+
__all__ = ['CaptureShell', 'format_exc', 'NbResult', 'render_outputs', 'find_output', 'out_exec', 'out_stream', 'out_error',
|
38
|
+
'exec_nb', 'SmartCompleter']
|
39
39
|
|
40
40
|
# %% ../nbs/02_shell.ipynb
|
41
41
|
class _CustDisplayHook(DisplayHook):
|
@@ -102,6 +102,9 @@ def format_exc(e):
|
|
102
102
|
"Format exception `e` as a string list"
|
103
103
|
return traceback.format_exception(type(e), e, e.__traceback__)
|
104
104
|
|
105
|
+
# %% ../nbs/02_shell.ipynb
|
106
|
+
class NbResult(list): pass
|
107
|
+
|
105
108
|
# %% ../nbs/02_shell.ipynb
|
106
109
|
def _out_stream(text, name): return dict(name=name, output_type='stream', text=text.splitlines(True))
|
107
110
|
def _out_exc(e):
|
@@ -122,13 +125,15 @@ def _mk_out(data, meta, output_type='display_data'):
|
|
122
125
|
return dict(data=fd, metadata=meta, output_type=output_type)
|
123
126
|
|
124
127
|
def _out_nb(o, fmt):
|
125
|
-
res =
|
128
|
+
res = NbResult()
|
126
129
|
if o.stdout: res.append(_out_stream(o.stdout, 'stdout'))
|
127
130
|
if o.stderr: res.append(_out_stream(o.stderr, 'stderr'))
|
128
131
|
if o.exception: res.append(_out_exc(o.exception))
|
129
132
|
r = o.result.result
|
133
|
+
if hasattr(r, '__ft__'): r = r.__ft__()
|
134
|
+
res.result = r
|
130
135
|
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'):
|
132
137
|
res.append(_mk_out(*fmt.format(r), 'execute_result'))
|
133
138
|
if 'execution_count' not in o: o['execution_count']=None
|
134
139
|
for p in res:
|
@@ -161,33 +166,35 @@ async def run_async(self:CaptureShell,
|
|
161
166
|
def _pre(s, xtra=''): return f"<pre {xtra}><code>{escape(s)}</code></pre>"
|
162
167
|
def _strip(s): return strip_ansi(escape(s))
|
163
168
|
|
164
|
-
def render_outputs(outputs, ansi_renderer=_strip, include_imgs=True, pygments=False):
|
169
|
+
def render_outputs(outputs, ansi_renderer=_strip, include_imgs=True, pygments=False, md_tfm=noop, html_tfm=noop):
|
165
170
|
try:
|
166
171
|
from mistletoe import markdown, HTMLRenderer
|
167
172
|
from mistletoe.contrib.pygments_renderer import PygmentsRenderer
|
168
|
-
except ImportError: return print('mistletoe not found -- please install it')
|
173
|
+
except ImportError: return print('mistletoe not found -- please install it for execnb.shell.render_output')
|
169
174
|
renderer = PygmentsRenderer if pygments else HTMLRenderer
|
175
|
+
|
170
176
|
def render_output(out):
|
171
177
|
otype = out['output_type']
|
172
178
|
if otype == 'stream':
|
173
|
-
txt = ansi_renderer(''.join(out[
|
179
|
+
txt = ansi_renderer(''.join(out["text"]))
|
174
180
|
xtra = '' if out['name']=='stdout' else "class='stderr'"
|
175
|
-
|
181
|
+
is_err = '<span class' in txt
|
182
|
+
return f"<pre {xtra}><code class='{'nohighlight hljs' if is_err else ''}'>{txt}</code></pre>"
|
176
183
|
elif otype in ('display_data','execute_result'):
|
177
184
|
data = out['data']
|
178
185
|
_g = lambda t: ''.join(data[t]) if t in data else None
|
179
|
-
if d := _g('text/html'): return d
|
186
|
+
if d := _g('text/html'): return html_tfm(d)
|
180
187
|
if d := _g('application/javascript'): return f'<script>{d}</script>'
|
181
|
-
if d := _g('text/markdown'): return markdown(d, renderer=renderer)
|
188
|
+
if d := _g('text/markdown'): return md_tfm(markdown(d, renderer=renderer))
|
182
189
|
if d := _g('text/latex'): return f'<div class="math">${d}$</div>'
|
183
190
|
if include_imgs:
|
184
191
|
if d := _g('image/jpeg'): return f'<img src="data:image/jpeg;base64,{d}"/>'
|
185
192
|
if d := _g('image/png'): return f'<img src="data:image/png;base64,{d}"/>'
|
193
|
+
if d := _g('image/svg+xml'): return d
|
186
194
|
if d := _g('text/plain'): return _pre(d)
|
187
|
-
if d := _g('image/svg+xml'): return d
|
188
195
|
|
189
196
|
return ''
|
190
|
-
|
197
|
+
|
191
198
|
return '\n'.join(map(render_output, outputs))
|
192
199
|
|
193
200
|
# %% ../nbs/02_shell.ipynb
|
@@ -273,7 +280,7 @@ def prettytb(self:CaptureShell,
|
|
273
280
|
fname = fname if fname else self._fname
|
274
281
|
_fence = '='*75
|
275
282
|
cell_intro_str = f"While Executing Cell #{self._cell_idx}:" if self._cell_idx else "While Executing:"
|
276
|
-
cell_str = f"\n{cell_intro_str}\n{format_exc(self.exc)}"
|
283
|
+
cell_str = f"\n{cell_intro_str}\n{''.join(format_exc(self.exc))}"
|
277
284
|
fname_str = f' in {fname}' if fname else ''
|
278
285
|
return f"{type(self.exc).__name__}{fname_str}:\n{_fence}\n{cell_str}\n"
|
279
286
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: execnb
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.13
|
4
4
|
Summary: A description of your project
|
5
5
|
Home-page: https://github.com/AnswerDotAI/execnb/
|
6
6
|
Author: Jeremy Howard
|
@@ -16,12 +16,25 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
16
16
|
Requires-Python: >=3.7
|
17
17
|
Description-Content-Type: text/markdown
|
18
18
|
License-File: LICENSE
|
19
|
-
Requires-Dist: fastcore
|
19
|
+
Requires-Dist: fastcore>=1.5.5
|
20
20
|
Requires-Dist: ipython
|
21
21
|
Provides-Extra: dev
|
22
|
-
Requires-Dist: matplotlib
|
23
|
-
Requires-Dist: Pillow
|
24
|
-
Requires-Dist: mistletoe
|
22
|
+
Requires-Dist: matplotlib; extra == "dev"
|
23
|
+
Requires-Dist: Pillow; extra == "dev"
|
24
|
+
Requires-Dist: mistletoe; extra == "dev"
|
25
|
+
Dynamic: author
|
26
|
+
Dynamic: author-email
|
27
|
+
Dynamic: classifier
|
28
|
+
Dynamic: description
|
29
|
+
Dynamic: description-content-type
|
30
|
+
Dynamic: home-page
|
31
|
+
Dynamic: keywords
|
32
|
+
Dynamic: license
|
33
|
+
Dynamic: license-file
|
34
|
+
Dynamic: provides-extra
|
35
|
+
Dynamic: requires-dist
|
36
|
+
Dynamic: requires-python
|
37
|
+
Dynamic: summary
|
25
38
|
|
26
39
|
# execnb
|
27
40
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
execnb/__init__.py,sha256=khDKUuWafURKVs5EAZkpOMiUHI2-V7axlqrWLPUpuZo,23
|
2
|
+
execnb/_modidx.py,sha256=5VB9uTJiRMiFNsXUWcd2J5p1jvvV36vsmQPUCWuqzrE,6308
|
3
|
+
execnb/nbio.py,sha256=gs3EGN0sP2j47XUH31rTn2KT57b3wWnBZsn9AoZm2JQ,3677
|
4
|
+
execnb/shell.py,sha256=lL0I5vMYjhaeD3WFKwXekyAAAb-4kjosA1PFd-IrpKE,13723
|
5
|
+
execnb-0.1.13.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
6
|
+
execnb-0.1.13.dist-info/METADATA,sha256=Uotcx1EkHSBT6yFY6T4Qpg0gZ1X2SPnNBif6yZetQw8,3587
|
7
|
+
execnb-0.1.13.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
8
|
+
execnb-0.1.13.dist-info/entry_points.txt,sha256=jZ8LPZCqnu4hXN_AgQpm05hVnTE-C25YK_4aiVX4i78,84
|
9
|
+
execnb-0.1.13.dist-info/top_level.txt,sha256=VGWmzsw8FOlT1r5TdOxaTWIAyRdclcxNdJ2r1hojf5U,7
|
10
|
+
execnb-0.1.13.dist-info/RECORD,,
|
execnb-0.1.11.dist-info/RECORD
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
execnb/__init__.py,sha256=nllDrH0jyChMuuYrK0CC55iTBKUNTUjejtcwxyUF2EQ,23
|
2
|
-
execnb/_modidx.py,sha256=mGvzO-ucSjMp0NX4t0Ed7XNi2v-gvMPLQUiGQpN1QKU,6211
|
3
|
-
execnb/nbio.py,sha256=gs3EGN0sP2j47XUH31rTn2KT57b3wWnBZsn9AoZm2JQ,3677
|
4
|
-
execnb/shell.py,sha256=kUZyWBTcEb9iKdH-EoeM1O7TtL_9_Agi7AVjLlU8bGk,13402
|
5
|
-
execnb-0.1.11.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
6
|
-
execnb-0.1.11.dist-info/METADATA,sha256=9vYzXQh7iYtP9cMcYOg23QTb_iGxhPNDa35lm9ixmcw,3313
|
7
|
-
execnb-0.1.11.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
8
|
-
execnb-0.1.11.dist-info/entry_points.txt,sha256=jZ8LPZCqnu4hXN_AgQpm05hVnTE-C25YK_4aiVX4i78,84
|
9
|
-
execnb-0.1.11.dist-info/top_level.txt,sha256=VGWmzsw8FOlT1r5TdOxaTWIAyRdclcxNdJ2r1hojf5U,7
|
10
|
-
execnb-0.1.11.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|