nbcat 0.9.2__py3-none-any.whl → 0.9.4__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.
- nbcat/__init__.py +1 -1
- nbcat/main.py +10 -4
- nbcat/schemas.py +7 -7
- {nbcat-0.9.2.dist-info → nbcat-0.9.4.dist-info}/METADATA +2 -2
- nbcat-0.9.4.dist-info/RECORD +11 -0
- nbcat-0.9.2.dist-info/RECORD +0 -11
- {nbcat-0.9.2.dist-info → nbcat-0.9.4.dist-info}/WHEEL +0 -0
- {nbcat-0.9.2.dist-info → nbcat-0.9.4.dist-info}/entry_points.txt +0 -0
- {nbcat-0.9.2.dist-info → nbcat-0.9.4.dist-info}/licenses/LICENSE +0 -0
nbcat/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.9.
|
1
|
+
__version__ = "0.9.4"
|
nbcat/main.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import argparse
|
2
2
|
import sys
|
3
3
|
from pathlib import Path
|
4
|
+
from typing import Union
|
4
5
|
|
5
6
|
import argcomplete
|
6
7
|
import requests
|
@@ -26,7 +27,7 @@ from .schemas import Cell, Notebook
|
|
26
27
|
console = Console()
|
27
28
|
|
28
29
|
|
29
|
-
def read_notebook(fp: str) -> Notebook:
|
30
|
+
def read_notebook(fp: str, debug: bool = False) -> Notebook:
|
30
31
|
"""
|
31
32
|
Load and parse a Jupyter notebook from a local file or remote URL.
|
32
33
|
|
@@ -61,10 +62,12 @@ def read_notebook(fp: str) -> Notebook:
|
|
61
62
|
try:
|
62
63
|
return Notebook.model_validate_json(content)
|
63
64
|
except ValidationError as e:
|
65
|
+
if not debug:
|
66
|
+
raise InvalidNotebookFormatError("Failed to read notebook")
|
64
67
|
raise InvalidNotebookFormatError(f"Invalid notebook: {e}")
|
65
68
|
|
66
69
|
|
67
|
-
def render_cell(cell: Cell) -> list[tuple[str
|
70
|
+
def render_cell(cell: Cell) -> list[tuple[Union[str, None], RenderableType]]:
|
68
71
|
"""
|
69
72
|
Render the content of a notebook cell for display.
|
70
73
|
|
@@ -96,7 +99,7 @@ def render_cell(cell: Cell) -> list[tuple[str | None, RenderableType]]:
|
|
96
99
|
CellType.HEADING: _render_markdown,
|
97
100
|
}
|
98
101
|
|
99
|
-
rows: list[tuple[str
|
102
|
+
rows: list[tuple[Union[str, None], RenderableType]] = []
|
100
103
|
renderer = RENDERERS.get(cell.cell_type)
|
101
104
|
source = renderer(cell.input) if renderer else None
|
102
105
|
if source:
|
@@ -156,11 +159,14 @@ def main():
|
|
156
159
|
action="version",
|
157
160
|
version=__version__,
|
158
161
|
)
|
162
|
+
parser.add_argument(
|
163
|
+
"--debug", help="enable extended error output", action="store_true", default=False
|
164
|
+
)
|
159
165
|
|
160
166
|
try:
|
161
167
|
argcomplete.autocomplete(parser)
|
162
168
|
args = parser.parse_args()
|
163
|
-
notebook = read_notebook(args.file)
|
169
|
+
notebook = read_notebook(args.file, debug=args.debug)
|
164
170
|
print_notebook(notebook)
|
165
171
|
except Exception as e:
|
166
172
|
sys.exit(f"nbcat: {e}")
|
nbcat/schemas.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Any
|
1
|
+
from typing import Any, Union
|
2
2
|
|
3
3
|
from pydantic import BaseModel, computed_field, model_validator
|
4
4
|
|
@@ -8,11 +8,11 @@ from .exceptions import InvalidNotebookFormatError
|
|
8
8
|
|
9
9
|
class BaseOutput(BaseModel):
|
10
10
|
output_type: OutputType
|
11
|
-
execution_count: int
|
11
|
+
execution_count: Union[int, None] = None
|
12
12
|
|
13
13
|
|
14
14
|
class StreamOutput(BaseOutput):
|
15
|
-
text: list[str]
|
15
|
+
text: Union[list[str], str]
|
16
16
|
|
17
17
|
@computed_field
|
18
18
|
@property
|
@@ -54,10 +54,10 @@ class PyoutDataOutput(BaseOutput):
|
|
54
54
|
|
55
55
|
class Cell(BaseModel):
|
56
56
|
cell_type: CellType
|
57
|
-
source: list[str]
|
58
|
-
level: int
|
59
|
-
execution_count: int
|
60
|
-
outputs: list[StreamOutput
|
57
|
+
source: Union[list[str], str]
|
58
|
+
level: Union[int, None] = None
|
59
|
+
execution_count: Union[int, None] = None
|
60
|
+
outputs: list[Union[StreamOutput, DisplayDataOutput, ErrorOutput, PyoutDataOutput]] = []
|
61
61
|
|
62
62
|
@model_validator(mode="before")
|
63
63
|
@classmethod
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nbcat
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.4
|
4
4
|
Summary: cat for jupyter notebooks
|
5
5
|
Project-URL: Homepage, https://github.com/akopdev/nbcat
|
6
6
|
Project-URL: Repository, https://github.com/akopdev/nbcat
|
@@ -28,7 +28,7 @@ License: MIT License
|
|
28
28
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
29
29
|
SOFTWARE.
|
30
30
|
License-File: LICENSE
|
31
|
-
Requires-Python: >=3.
|
31
|
+
Requires-Python: >=3.9
|
32
32
|
Requires-Dist: argcomplete
|
33
33
|
Requires-Dist: pydantic
|
34
34
|
Requires-Dist: requests
|
@@ -0,0 +1,11 @@
|
|
1
|
+
nbcat/__init__.py,sha256=e56AvHfJCtG2ZwwINqsxINVbehWdKxMYgIDbjd7P-II,22
|
2
|
+
nbcat/enums.py,sha256=ZsuOwYLF0D4PVwSkS74LwoXY0y0DkeBToLBWnmiS97Y,300
|
3
|
+
nbcat/exceptions.py,sha256=Ho7LQz9K70VtIMDNtAwuAtGmb-lFKxGxSj7MN3-EpDA,321
|
4
|
+
nbcat/main.py,sha256=02qOCh4I4kXpoIgZCRYztiY5QPDw7FkAbC4smjl1Sxc,5273
|
5
|
+
nbcat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
nbcat/schemas.py,sha256=miVL0GDHIqXaFxz_cd9qn7cSZvIjZYK8TTY9YsfkuXs,2407
|
7
|
+
nbcat-0.9.4.dist-info/METADATA,sha256=VkAsyObzS8n5gT7qzA7Gxertoz863ZWENfqgaz3EGu0,3375
|
8
|
+
nbcat-0.9.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
9
|
+
nbcat-0.9.4.dist-info/entry_points.txt,sha256=io_GRDsecAkYuCZALsjyea3VBq91VCoSznqlZEAJshY,42
|
10
|
+
nbcat-0.9.4.dist-info/licenses/LICENSE,sha256=7GjUnahXdd5opdvlpJdb1BisLbiXt2iOFhzIUduhdkE,1072
|
11
|
+
nbcat-0.9.4.dist-info/RECORD,,
|
nbcat-0.9.2.dist-info/RECORD
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
nbcat/__init__.py,sha256=gqT-BGoeEItda9fICQDvLbxEjWRIBhFJxPxxKvmHLUo,22
|
2
|
-
nbcat/enums.py,sha256=ZsuOwYLF0D4PVwSkS74LwoXY0y0DkeBToLBWnmiS97Y,300
|
3
|
-
nbcat/exceptions.py,sha256=Ho7LQz9K70VtIMDNtAwuAtGmb-lFKxGxSj7MN3-EpDA,321
|
4
|
-
nbcat/main.py,sha256=Cv5CLuibhuEvLFxKH3vIk7XsD_Zr2ecTKACW1hy7d8c,4981
|
5
|
-
nbcat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
nbcat/schemas.py,sha256=IK1l2a4UcP6Ivh8xRBzV5BIQTbeES1b1cCH-6goEq8Q,2366
|
7
|
-
nbcat-0.9.2.dist-info/METADATA,sha256=FaJtGOMbBL_K2JrDY_sRA-r1nxdQeZysezxVny9X0rU,3376
|
8
|
-
nbcat-0.9.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
9
|
-
nbcat-0.9.2.dist-info/entry_points.txt,sha256=io_GRDsecAkYuCZALsjyea3VBq91VCoSznqlZEAJshY,42
|
10
|
-
nbcat-0.9.2.dist-info/licenses/LICENSE,sha256=7GjUnahXdd5opdvlpJdb1BisLbiXt2iOFhzIUduhdkE,1072
|
11
|
-
nbcat-0.9.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|