execnb 0.1.15__tar.gz → 0.1.17__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: execnb
3
- Version: 0.1.15
3
+ Version: 0.1.17
4
4
  Summary: A description of your project
5
5
  Home-page: https://github.com/AnswerDotAI/execnb/
6
6
  Author: Jeremy Howard
@@ -16,7 +16,7 @@ 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>=1.5.5
19
+ Requires-Dist: fastcore>=1.10.4
20
20
  Requires-Dist: ipython
21
21
  Provides-Extra: dev
22
22
  Requires-Dist: matplotlib; extra == "dev"
@@ -0,0 +1 @@
1
+ __version__ = "0.1.17"
@@ -3,10 +3,11 @@
3
3
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_nbio.ipynb.
4
4
 
5
5
  # %% auto 0
6
- __all__ = ['NbCell', 'dict2nb', 'read_nb', 'new_nb', 'mk_cell', 'nb2dict', 'nb2str', 'write_nb']
6
+ __all__ = ['NbCell', 'dict2nb', 'read_nb', 'mk_cell', 'new_nb', 'nb2dict', 'nb2str', 'write_nb']
7
7
 
8
8
  # %% ../nbs/01_nbio.ipynb
9
9
  from fastcore.basics import *
10
+ from fastcore.xtras import rtoken_hex
10
11
  from fastcore.imports import *
11
12
 
12
13
  import ast,functools
@@ -19,9 +20,10 @@ def _read_json(self, encoding=None, errors=None):
19
20
 
20
21
  # %% ../nbs/01_nbio.ipynb
21
22
  class NbCell(AttrDict):
22
- def __init__(self, idx, cell):
23
+ def __init__(self, idx, cell, id=None):
23
24
  super().__init__(cell)
24
25
  self.idx_ = idx
26
+ self.id = id or rtoken_hex(4)
25
27
  if 'source' in self: self.set_source(self.source)
26
28
 
27
29
  def set_source(self, source):
@@ -60,11 +62,6 @@ def read_nb(path):
60
62
  res['path_'] = str(path)
61
63
  return res
62
64
 
63
- # %% ../nbs/01_nbio.ipynb
64
- def new_nb(cells=None, meta=None, nbformat=4, nbformat_minor=5):
65
- "Returns an empty new notebook"
66
- return dict2nb(cells=cells or [],metadata=meta or {},nbformat=nbformat,nbformat_minor=nbformat_minor)
67
-
68
65
  # %% ../nbs/01_nbio.ipynb
69
66
  def mk_cell(text, # `source` attr in cell
70
67
  cell_type='code', # `cell_type` attr in cell
@@ -77,6 +74,12 @@ def mk_cell(text, # `source` attr in cell
77
74
  kwargs['execution_count']=0
78
75
  return NbCell(0, dict(cell_type=cell_type, source=text, directives_={}, **kwargs))
79
76
 
77
+ # %% ../nbs/01_nbio.ipynb
78
+ def new_nb(cells=None, meta=None, nbformat=4, nbformat_minor=5):
79
+ "Returns an empty new notebook"
80
+ cells = [o if isinstance(o,dict) else mk_cell(o) for o in cells]
81
+ return dict2nb(cells=cells or [],metadata=meta or {},nbformat=nbformat,nbformat_minor=nbformat_minor)
82
+
80
83
  # %% ../nbs/01_nbio.ipynb
81
84
  def nb2dict(d, k=None):
82
85
  "Convert parsed notebook to `dict`"
@@ -73,7 +73,8 @@ class CaptureShell(InteractiveShell):
73
73
  with capture_output(display=display, stdout=stdout and not verbose, stderr=stderr and not verbose) as c:
74
74
  result = super().run_cell(raw_cell, store_history, silent, shell_futures=shell_futures, cell_id=cell_id)
75
75
  return AttrDict(result=result, stdout='' if semic else c.stdout, stderr=c.stderr,
76
- display_objects=c.outputs, exception=result.error_in_exec, quiet=semic)
76
+ display_objects=c.outputs,
77
+ exception=result.error_in_exec or result.error_before_exec, quiet=semic)
77
78
 
78
79
  def set_path(self, path):
79
80
  "Add `path` to python path, or `path.parent` if it's a file"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: execnb
3
- Version: 0.1.15
3
+ Version: 0.1.17
4
4
  Summary: A description of your project
5
5
  Home-page: https://github.com/AnswerDotAI/execnb/
6
6
  Author: Jeremy Howard
@@ -16,7 +16,7 @@ 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>=1.5.5
19
+ Requires-Dist: fastcore>=1.10.4
20
20
  Requires-Dist: ipython
21
21
  Provides-Extra: dev
22
22
  Requires-Dist: matplotlib; extra == "dev"
@@ -1,4 +1,4 @@
1
- fastcore>=1.5.5
1
+ fastcore>=1.10.4
2
2
  ipython
3
3
 
4
4
  [dev]
@@ -9,9 +9,9 @@ user = AnswerDotAI
9
9
  author = Jeremy Howard
10
10
  author_email = j@fast.ai
11
11
  branch = main
12
- version = 0.1.15
12
+ version = 0.1.17
13
13
  min_python = 3.7
14
- requirements = fastcore>=1.5.5 ipython
14
+ requirements = fastcore>=1.10.4 ipython
15
15
  dev_requirements = matplotlib Pillow mistletoe
16
16
  console_scripts = exec_nb=execnb.shell:exec_nb
17
17
  audience = Developers
@@ -1 +0,0 @@
1
- __version__ = "0.1.15"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes