execnb 0.2.5__tar.gz → 0.2.6__tar.gz
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-0.2.5/execnb.egg-info → execnb-0.2.6}/PKG-INFO +1 -1
- execnb-0.2.6/execnb/__init__.py +1 -0
- {execnb-0.2.5 → execnb-0.2.6}/execnb/shell.py +15 -9
- {execnb-0.2.5 → execnb-0.2.6/execnb.egg-info}/PKG-INFO +1 -1
- execnb-0.2.5/execnb/__init__.py +0 -1
- {execnb-0.2.5 → execnb-0.2.6}/LICENSE +0 -0
- {execnb-0.2.5 → execnb-0.2.6}/MANIFEST.in +0 -0
- {execnb-0.2.5 → execnb-0.2.6}/README.md +0 -0
- {execnb-0.2.5 → execnb-0.2.6}/execnb/_modidx.py +0 -0
- {execnb-0.2.5 → execnb-0.2.6}/execnb.egg-info/SOURCES.txt +0 -0
- {execnb-0.2.5 → execnb-0.2.6}/execnb.egg-info/dependency_links.txt +0 -0
- {execnb-0.2.5 → execnb-0.2.6}/execnb.egg-info/entry_points.txt +0 -0
- {execnb-0.2.5 → execnb-0.2.6}/execnb.egg-info/requires.txt +0 -0
- {execnb-0.2.5 → execnb-0.2.6}/execnb.egg-info/top_level.txt +0 -0
- {execnb-0.2.5 → execnb-0.2.6}/pyproject.toml +0 -0
- {execnb-0.2.5 → execnb-0.2.6}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.6"
|
|
@@ -328,19 +328,21 @@ def _is_noeval(src):
|
|
|
328
328
|
|
|
329
329
|
def select_cells(
|
|
330
330
|
nb, # A notebook read with `read_nb`
|
|
331
|
-
msgid:str=None, # Cell id prefix to match
|
|
331
|
+
msgid:str=None, # Cell id, or unique prefix, to match
|
|
332
332
|
above:bool=False, # Include the matched cell and all cells above it?
|
|
333
333
|
below:bool=False, # Include the matched cell and all cells below it?
|
|
334
334
|
all:bool=False, # Include all code cells (ignores `msgid`)?
|
|
335
335
|
exported:bool=False, # Only cells with `#| export` or `#| exports`?
|
|
336
336
|
skip_noeval:bool=False # Skip `#| eval: false` and `nbdev_export` cells (like `nbdev-test`)?
|
|
337
337
|
):
|
|
338
|
-
"Select code cells from `nb` by cell id prefix"
|
|
338
|
+
"Select code cells from `nb` by cell id or unique prefix"
|
|
339
339
|
cells = [o for o in nb.cells if o.cell_type=='code']
|
|
340
340
|
if not all:
|
|
341
341
|
if not msgid: raise ValueError('`msgid` required unless `all=True`')
|
|
342
|
-
|
|
343
|
-
if
|
|
342
|
+
idxs = [i for i,o in enumerate(cells) if str(o.id).startswith(msgid)]
|
|
343
|
+
if not idxs: raise ValueError(f'No code cell id starting with {msgid!r}')
|
|
344
|
+
if len(idxs)>1: raise ValueError(f'Multiple code cell ids start with {msgid!r}: {", ".join(str(cells[i].id) for i in idxs)}')
|
|
345
|
+
idx = idxs[0]
|
|
344
346
|
if above: cells = cells[:idx+1]
|
|
345
347
|
elif below: cells = cells[idx:]
|
|
346
348
|
else: cells = [cells[idx]]
|
|
@@ -355,12 +357,14 @@ from fastcore.nbio import render_text
|
|
|
355
357
|
@patch
|
|
356
358
|
def nbopen(self:CaptureShell, fname:str|Path):
|
|
357
359
|
"Set the default notebook for `nbrun`"
|
|
358
|
-
|
|
360
|
+
fname = Path(fname)
|
|
361
|
+
if not fname.exists(): raise FileNotFoundError(fname)
|
|
362
|
+
self._nbrun_fname = fname
|
|
359
363
|
|
|
360
364
|
@patch
|
|
361
365
|
def nbrun(
|
|
362
366
|
self:CaptureShell,
|
|
363
|
-
|
|
367
|
+
*msgids:str, # Cell id prefixes to run, in the order given
|
|
364
368
|
fname:str|Path=None, # Notebook path (defaults to last `nbopen`)
|
|
365
369
|
above:bool=False, # Also run all cells above the match?
|
|
366
370
|
below:bool=False, # Also run all cells below the match?
|
|
@@ -373,9 +377,11 @@ def nbrun(
|
|
|
373
377
|
if not fname: raise ValueError('No `fname` passed and no notebook opened with `nbopen`')
|
|
374
378
|
self.nbopen(fname)
|
|
375
379
|
nb = read_nb(fname)
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
380
|
+
if all or not msgids: msgids = (None,)
|
|
381
|
+
for msgid in msgids:
|
|
382
|
+
for cell in select_cells(nb, msgid, above=above, below=below, all=all, exported=exported, skip_noeval=skip_noeval):
|
|
383
|
+
res = render_text(self.run(cell.source))
|
|
384
|
+
if res: print(f'--- {cell.id} ---\n{res}')
|
|
379
385
|
|
|
380
386
|
# %% ../nbs/00_shell.ipynb #1227c8b1
|
|
381
387
|
@call_parse
|
execnb-0.2.5/execnb/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.5"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|