nbcat 0.8.2__tar.gz → 0.9.2__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.
Files changed (33) hide show
  1. {nbcat-0.8.2 → nbcat-0.9.2}/.github/workflows/ci.yml +10 -2
  2. {nbcat-0.8.2 → nbcat-0.9.2}/PKG-INFO +19 -39
  3. nbcat-0.9.2/README.md +67 -0
  4. {nbcat-0.8.2 → nbcat-0.9.2}/pyproject.toml +2 -1
  5. nbcat-0.9.2/src/nbcat/__init__.py +1 -0
  6. {nbcat-0.8.2 → nbcat-0.9.2}/src/nbcat/main.py +8 -6
  7. {nbcat-0.8.2 → nbcat-0.9.2}/src/nbcat/schemas.py +2 -2
  8. {nbcat-0.8.2 → nbcat-0.9.2}/tests/test_render_cell.py +1 -1
  9. {nbcat-0.8.2 → nbcat-0.9.2}/uv.lock +327 -316
  10. nbcat-0.8.2/README.md +0 -88
  11. nbcat-0.8.2/src/nbcat/__init__.py +0 -1
  12. {nbcat-0.8.2 → nbcat-0.9.2}/.gitignore +0 -0
  13. {nbcat-0.8.2 → nbcat-0.9.2}/LICENSE +0 -0
  14. {nbcat-0.8.2 → nbcat-0.9.2}/Makefile +0 -0
  15. {nbcat-0.8.2 → nbcat-0.9.2}/src/nbcat/enums.py +0 -0
  16. {nbcat-0.8.2 → nbcat-0.9.2}/src/nbcat/exceptions.py +0 -0
  17. {nbcat-0.8.2 → nbcat-0.9.2}/src/nbcat/py.typed +0 -0
  18. {nbcat-0.8.2 → nbcat-0.9.2}/tests/assets/invalid.ipynb +0 -0
  19. {nbcat-0.8.2 → nbcat-0.9.2}/tests/assets/many_tracebacks.ipynb +0 -0
  20. {nbcat-0.8.2 → nbcat-0.9.2}/tests/assets/no_min_version.ipynb +0 -0
  21. {nbcat-0.8.2 → nbcat-0.9.2}/tests/assets/test3.ipynb +0 -0
  22. {nbcat-0.8.2 → nbcat-0.9.2}/tests/assets/test3_no_metadata.ipynb +0 -0
  23. {nbcat-0.8.2 → nbcat-0.9.2}/tests/assets/test3_no_min_version.ipynb +0 -0
  24. {nbcat-0.8.2 → nbcat-0.9.2}/tests/assets/test3_no_worksheets.ipynb +0 -0
  25. {nbcat-0.8.2 → nbcat-0.9.2}/tests/assets/test3_worksheet_with_no_cells.ipynb +0 -0
  26. {nbcat-0.8.2 → nbcat-0.9.2}/tests/assets/test4.5.ipynb +0 -0
  27. {nbcat-0.8.2 → nbcat-0.9.2}/tests/assets/test4.ipynb +0 -0
  28. {nbcat-0.8.2 → nbcat-0.9.2}/tests/assets/test4custom.ipynb +0 -0
  29. {nbcat-0.8.2 → nbcat-0.9.2}/tests/assets/test4docinfo.ipynb +0 -0
  30. {nbcat-0.8.2 → nbcat-0.9.2}/tests/assets/test4jupyter_metadata.ipynb +0 -0
  31. {nbcat-0.8.2 → nbcat-0.9.2}/tests/assets/test4jupyter_metadata_timings.ipynb +0 -0
  32. {nbcat-0.8.2 → nbcat-0.9.2}/tests/conftest.py +0 -0
  33. {nbcat-0.8.2 → nbcat-0.9.2}/tests/test_read_notebook.py +0 -0
@@ -4,6 +4,8 @@ on:
4
4
  push:
5
5
  branches:
6
6
  - main
7
+ tags:
8
+ - 'v*'
7
9
  pull_request:
8
10
 
9
11
  jobs:
@@ -31,11 +33,12 @@ jobs:
31
33
  path: dist/
32
34
 
33
35
  deploy:
34
- if: ${{ github.ref == 'refs/heads/main' && success() }}
36
+ if: ${{ startsWith(github.ref, 'refs/tags/') && success() }}
35
37
  needs: build
36
38
  runs-on: ubuntu-latest
37
39
  environment: pypi
38
40
  permissions:
41
+ contents: write
39
42
  id-token: write
40
43
  steps:
41
44
  - uses: actions/checkout@v4
@@ -52,5 +55,10 @@ jobs:
52
55
  - name: List contents
53
56
  run: ls -la dist/
54
57
 
55
- - name: Publish
58
+ - name: Upload to PyPi
56
59
  uses: pypa/gh-action-pypi-publish@release/v1
60
+
61
+ - name: Upload to GitHub Release
62
+ uses: softprops/action-gh-release@v2
63
+ with:
64
+ files: dist/*
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbcat
3
- Version: 0.8.2
3
+ Version: 0.9.2
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
@@ -29,6 +29,7 @@ License: MIT License
29
29
  SOFTWARE.
30
30
  License-File: LICENSE
31
31
  Requires-Python: >=3.10
32
+ Requires-Dist: argcomplete
32
33
  Requires-Dist: pydantic
33
34
  Requires-Dist: requests
34
35
  Requires-Dist: rich
@@ -42,48 +43,39 @@ Description-Content-Type: text/markdown
42
43
 
43
44
  # 📦 nbcat
44
45
 
45
- cat for jupyter notebooks
46
-
47
- [![License](https://img.shields.io/github/license/akopdev/nbcat)](./LICENSE)
48
- [![Build](https://github.com/akopdev/nbcat/actions/workflows/ci.yml/badge.svg)](https://github.com/akopdev/nbcat/actions)
49
-
50
- ---
46
+ `nbcat` lets you preview Jupyter notebooks directly in your terminal. Think of it as `cat`, but for `.ipynb` files.
51
47
 
52
48
  ## 🚀 Features
53
49
 
54
- - Clean, minimal API
55
- - 🧰 Easily extensible
56
- - 🧪 Fully tested and type-annotated
57
- - ⚡ Fast and lightweight
58
- - 📦 Available on PyPI
59
-
60
- ---
50
+ - Fast and lightweight with minimal external dependencies
51
+ - Preview remote notebooks without downloading them
52
+ - Supports for all Jupyter notebook versions - including legacy formats
61
53
 
62
54
  ## 📦 Installation
63
55
 
64
- Install with [uv](https://github.com/astral-sh/uv)
56
+ From the command line using pip:
65
57
 
66
58
  ```bash
67
- uv pip install nbcat
59
+ pip install nbcat
68
60
  ```
69
61
 
70
- To install the latest development version:
62
+ ## 🛠️ Quickstart
71
63
 
72
64
  ```bash
73
- uv pip install git+https://github.com/akopdev/nbcat.git
65
+ $ nbcat notebook.ipynb
74
66
  ```
75
67
 
76
- ---
77
-
78
- ## 🛠️ Quickstart
68
+ You can pass URLs as well.
79
69
 
80
- ```python
81
- # example of using the package
70
+ ```bash
71
+ $ nbcat https://raw.githubusercontent.com/akopdev/nbcat/refs/heads/main/tests/assets/test4.ipynb
82
72
  ```
83
73
 
84
- For more examples, check out the [`examples/`](./examples/) folder.
74
+ Example use case with `fzf` command that lists all `.ipynb` files and uses `nbcat` for previewing them:
85
75
 
86
- ---
76
+ ```bash
77
+ find . -type f -name "*.ipynb" | fzf --preview 'nbcat {}'
78
+ ```
87
79
 
88
80
  ## 🧪 Testing & Development
89
81
 
@@ -96,29 +88,17 @@ make test
96
88
  Check code quality:
97
89
 
98
90
  ```bash
99
- make lint
100
- ```
101
-
102
- Format code:
103
-
104
- ```bash
105
- make format
91
+ make format lint
106
92
  ```
107
93
 
108
- ---
109
-
110
94
  ## 🙌 Contributing
111
95
 
112
96
  Contributions are welcome! Please open an issue or [pull request](https://github.com/akopdev/nbcat/pulls).
113
97
 
114
- ---
115
-
116
98
  ## 📄 License
117
99
 
118
100
  Distributed under the MIT License. See [`LICENSE`](./LICENSE) for more information.
119
101
 
120
- ---
121
-
122
102
  ## 🔗 Useful Links
123
103
 
124
104
  - 📘 Documentation: _coming soon_
@@ -127,4 +107,4 @@ Distributed under the MIT License. See [`LICENSE`](./LICENSE) for more informati
127
107
 
128
108
  ---
129
109
 
130
- > Made with ❤️ by [Akop Kesheshyan](https://github.com/akopdev)
110
+ Made with ❤️ by [Akop Kesheshyan](https://github.com/akopdev)
nbcat-0.9.2/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # 📦 nbcat
2
+
3
+ `nbcat` lets you preview Jupyter notebooks directly in your terminal. Think of it as `cat`, but for `.ipynb` files.
4
+
5
+ ## 🚀 Features
6
+
7
+ - Fast and lightweight with minimal external dependencies
8
+ - Preview remote notebooks without downloading them
9
+ - Supports for all Jupyter notebook versions - including legacy formats
10
+
11
+ ## 📦 Installation
12
+
13
+ From the command line using pip:
14
+
15
+ ```bash
16
+ pip install nbcat
17
+ ```
18
+
19
+ ## 🛠️ Quickstart
20
+
21
+ ```bash
22
+ $ nbcat notebook.ipynb
23
+ ```
24
+
25
+ You can pass URLs as well.
26
+
27
+ ```bash
28
+ $ nbcat https://raw.githubusercontent.com/akopdev/nbcat/refs/heads/main/tests/assets/test4.ipynb
29
+ ```
30
+
31
+ Example use case with `fzf` command that lists all `.ipynb` files and uses `nbcat` for previewing them:
32
+
33
+ ```bash
34
+ find . -type f -name "*.ipynb" | fzf --preview 'nbcat {}'
35
+ ```
36
+
37
+ ## 🧪 Testing & Development
38
+
39
+ Run the tests:
40
+
41
+ ```bash
42
+ make test
43
+ ```
44
+
45
+ Check code quality:
46
+
47
+ ```bash
48
+ make format lint
49
+ ```
50
+
51
+ ## 🙌 Contributing
52
+
53
+ Contributions are welcome! Please open an issue or [pull request](https://github.com/akopdev/nbcat/pulls).
54
+
55
+ ## 📄 License
56
+
57
+ Distributed under the MIT License. See [`LICENSE`](./LICENSE) for more information.
58
+
59
+ ## 🔗 Useful Links
60
+
61
+ - 📘 Documentation: _coming soon_
62
+ - 🐛 Issues: [GitHub Issues](https://github.com/akopdev/nbcat/issues)
63
+ - 🚀 Releases: [GitHub Releases](https://github.com/akopdev/nbcat/releases)
64
+
65
+ ---
66
+
67
+ Made with ❤️ by [Akop Kesheshyan](https://github.com/akopdev)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nbcat"
3
- version = "0.8.2"
3
+ version = "0.9.2"
4
4
  description = "cat for jupyter notebooks"
5
5
  authors = [
6
6
  { name = "Akop Kesheshyan", email = "devnull@akop.dev" }
@@ -12,6 +12,7 @@ license = {file = "LICENSE"}
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.10"
14
14
  dependencies = [
15
+ "argcomplete",
15
16
  "requests",
16
17
  "pydantic",
17
18
  "rich",
@@ -0,0 +1 @@
1
+ __version__ = "0.9.2"
@@ -2,7 +2,9 @@ import argparse
2
2
  import sys
3
3
  from pathlib import Path
4
4
 
5
+ import argcomplete
5
6
  import requests
7
+ from argcomplete.completers import FilesCompleter
6
8
  from pydantic import ValidationError
7
9
  from rich import box
8
10
  from rich.console import Console, RenderableType
@@ -82,19 +84,16 @@ def render_cell(cell: Cell) -> list[tuple[str | None, RenderableType]]:
82
84
  return Markdown(input)
83
85
 
84
86
  def _render_code(input: str) -> Panel:
85
- return Panel(Syntax(input, "python", line_numbers=True, theme="ansi_dark"), box=box.SQUARE)
87
+ return Panel(Syntax(input, "python", theme="ansi_dark"), box=box.SQUARE)
86
88
 
87
89
  def _render_raw(input: str) -> Text:
88
90
  return Text(input)
89
91
 
90
- def _render_heading(input: str) -> Text:
91
- return Text(input)
92
-
93
92
  RENDERERS = {
94
93
  CellType.MARKDOWN: _render_markdown,
95
94
  CellType.CODE: _render_code,
96
95
  CellType.RAW: _render_raw,
97
- CellType.HEADING: _render_heading,
96
+ CellType.HEADING: _render_markdown,
98
97
  }
99
98
 
100
99
  rows: list[tuple[str | None, RenderableType]] = []
@@ -148,7 +147,9 @@ def main():
148
147
  description="cat for Jupyter Notebooks",
149
148
  argument_default=argparse.SUPPRESS,
150
149
  )
151
- parser.add_argument("file", help="Path or URL to a .ipynb notebook", type=str)
150
+ parser.add_argument(
151
+ "file", help="Path or URL to a .ipynb notebook", type=str
152
+ ).completer = FilesCompleter()
152
153
  parser.add_argument(
153
154
  "--version",
154
155
  help="print version information and quite",
@@ -157,6 +158,7 @@ def main():
157
158
  )
158
159
 
159
160
  try:
161
+ argcomplete.autocomplete(parser)
160
162
  args = parser.parse_args()
161
163
  notebook = read_notebook(args.file)
162
164
  print_notebook(notebook)
@@ -70,7 +70,7 @@ class Cell(BaseModel):
70
70
  @property
71
71
  def input(self) -> str:
72
72
  if self.cell_type == CellType.HEADING and self.level is not None:
73
- return f"{'#' * self.level} {self.source}"
73
+ return f"{'#' * self.level} {''.join(self.source)}"
74
74
 
75
75
  if isinstance(self.source, list):
76
76
  return "".join(self.source)
@@ -87,7 +87,7 @@ class Notebook(BaseModel):
87
87
  def handle_format_versions(cls, data: dict[str, Any]) -> dict[str, Any]:
88
88
  if data.get("worksheets"):
89
89
  try:
90
- data["cells"] = data.get("worksheets")[0].get("cells", [])
90
+ data["cells"] = data.get("worksheets", [{"cells": []}])[0].get("cells", [])
91
91
  except (KeyError, IndexError, TypeError) as e:
92
92
  print(e)
93
93
  raise InvalidNotebookFormatError(f"Invalid v3 notebook structure: {e}")
@@ -13,7 +13,7 @@ from nbcat.schemas import Cell, StreamOutput
13
13
  ("markdown", "# Heading", Markdown),
14
14
  ("code", "print('Hello')", Panel),
15
15
  ("raw", "Raw content", Text),
16
- ("heading", "Heading text", Text),
16
+ ("heading", "Heading text", Markdown),
17
17
  ],
18
18
  )
19
19
  def test_render_cell_input_rendering(cell_type: str, source: str, expected):