nbcat 0.9.0__tar.gz → 0.9.3__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.9.0 → nbcat-0.9.3}/.github/workflows/ci.yml +10 -2
  2. {nbcat-0.9.0 → nbcat-0.9.3}/PKG-INFO +18 -39
  3. nbcat-0.9.3/README.md +67 -0
  4. {nbcat-0.9.0 → nbcat-0.9.3}/pyproject.toml +1 -1
  5. nbcat-0.9.3/src/nbcat/__init__.py +1 -0
  6. {nbcat-0.9.0 → nbcat-0.9.3}/src/nbcat/main.py +9 -7
  7. {nbcat-0.9.0 → nbcat-0.9.3}/src/nbcat/schemas.py +2 -2
  8. {nbcat-0.9.0 → nbcat-0.9.3}/tests/test_render_cell.py +1 -1
  9. {nbcat-0.9.0 → nbcat-0.9.3}/uv.lock +1 -1
  10. nbcat-0.9.0/README.md +0 -88
  11. nbcat-0.9.0/src/nbcat/__init__.py +0 -1
  12. {nbcat-0.9.0 → nbcat-0.9.3}/.gitignore +0 -0
  13. {nbcat-0.9.0 → nbcat-0.9.3}/LICENSE +0 -0
  14. {nbcat-0.9.0 → nbcat-0.9.3}/Makefile +0 -0
  15. {nbcat-0.9.0 → nbcat-0.9.3}/src/nbcat/enums.py +0 -0
  16. {nbcat-0.9.0 → nbcat-0.9.3}/src/nbcat/exceptions.py +0 -0
  17. {nbcat-0.9.0 → nbcat-0.9.3}/src/nbcat/py.typed +0 -0
  18. {nbcat-0.9.0 → nbcat-0.9.3}/tests/assets/invalid.ipynb +0 -0
  19. {nbcat-0.9.0 → nbcat-0.9.3}/tests/assets/many_tracebacks.ipynb +0 -0
  20. {nbcat-0.9.0 → nbcat-0.9.3}/tests/assets/no_min_version.ipynb +0 -0
  21. {nbcat-0.9.0 → nbcat-0.9.3}/tests/assets/test3.ipynb +0 -0
  22. {nbcat-0.9.0 → nbcat-0.9.3}/tests/assets/test3_no_metadata.ipynb +0 -0
  23. {nbcat-0.9.0 → nbcat-0.9.3}/tests/assets/test3_no_min_version.ipynb +0 -0
  24. {nbcat-0.9.0 → nbcat-0.9.3}/tests/assets/test3_no_worksheets.ipynb +0 -0
  25. {nbcat-0.9.0 → nbcat-0.9.3}/tests/assets/test3_worksheet_with_no_cells.ipynb +0 -0
  26. {nbcat-0.9.0 → nbcat-0.9.3}/tests/assets/test4.5.ipynb +0 -0
  27. {nbcat-0.9.0 → nbcat-0.9.3}/tests/assets/test4.ipynb +0 -0
  28. {nbcat-0.9.0 → nbcat-0.9.3}/tests/assets/test4custom.ipynb +0 -0
  29. {nbcat-0.9.0 → nbcat-0.9.3}/tests/assets/test4docinfo.ipynb +0 -0
  30. {nbcat-0.9.0 → nbcat-0.9.3}/tests/assets/test4jupyter_metadata.ipynb +0 -0
  31. {nbcat-0.9.0 → nbcat-0.9.3}/tests/assets/test4jupyter_metadata_timings.ipynb +0 -0
  32. {nbcat-0.9.0 → nbcat-0.9.3}/tests/conftest.py +0 -0
  33. {nbcat-0.9.0 → nbcat-0.9.3}/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.9.0
3
+ Version: 0.9.3
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
@@ -43,48 +43,39 @@ Description-Content-Type: text/markdown
43
43
 
44
44
  # 📦 nbcat
45
45
 
46
- cat for jupyter notebooks
47
-
48
- [![License](https://img.shields.io/github/license/akopdev/nbcat)](./LICENSE)
49
- [![Build](https://github.com/akopdev/nbcat/actions/workflows/ci.yml/badge.svg)](https://github.com/akopdev/nbcat/actions)
50
-
51
- ---
46
+ `nbcat` lets you preview Jupyter notebooks directly in your terminal. Think of it as `cat`, but for `.ipynb` files.
52
47
 
53
48
  ## 🚀 Features
54
49
 
55
- - Clean, minimal API
56
- - 🧰 Easily extensible
57
- - 🧪 Fully tested and type-annotated
58
- - ⚡ Fast and lightweight
59
- - 📦 Available on PyPI
60
-
61
- ---
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
62
53
 
63
54
  ## 📦 Installation
64
55
 
65
- Install with [uv](https://github.com/astral-sh/uv)
56
+ From the command line using pip:
66
57
 
67
58
  ```bash
68
- uv pip install nbcat
59
+ pip install nbcat
69
60
  ```
70
61
 
71
- To install the latest development version:
62
+ ## 🛠️ Quickstart
72
63
 
73
64
  ```bash
74
- uv pip install git+https://github.com/akopdev/nbcat.git
65
+ $ nbcat notebook.ipynb
75
66
  ```
76
67
 
77
- ---
78
-
79
- ## 🛠️ Quickstart
68
+ You can pass URLs as well.
80
69
 
81
- ```python
82
- # example of using the package
70
+ ```bash
71
+ $ nbcat https://raw.githubusercontent.com/akopdev/nbcat/refs/heads/main/tests/assets/test4.ipynb
83
72
  ```
84
73
 
85
- 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:
86
75
 
87
- ---
76
+ ```bash
77
+ find . -type f -name "*.ipynb" | fzf --preview 'nbcat {}'
78
+ ```
88
79
 
89
80
  ## 🧪 Testing & Development
90
81
 
@@ -97,29 +88,17 @@ make test
97
88
  Check code quality:
98
89
 
99
90
  ```bash
100
- make lint
101
- ```
102
-
103
- Format code:
104
-
105
- ```bash
106
- make format
91
+ make format lint
107
92
  ```
108
93
 
109
- ---
110
-
111
94
  ## 🙌 Contributing
112
95
 
113
96
  Contributions are welcome! Please open an issue or [pull request](https://github.com/akopdev/nbcat/pulls).
114
97
 
115
- ---
116
-
117
98
  ## 📄 License
118
99
 
119
100
  Distributed under the MIT License. See [`LICENSE`](./LICENSE) for more information.
120
101
 
121
- ---
122
-
123
102
  ## 🔗 Useful Links
124
103
 
125
104
  - 📘 Documentation: _coming soon_
@@ -128,4 +107,4 @@ Distributed under the MIT License. See [`LICENSE`](./LICENSE) for more informati
128
107
 
129
108
  ---
130
109
 
131
- > Made with ❤️ by [Akop Kesheshyan](https://github.com/akopdev)
110
+ Made with ❤️ by [Akop Kesheshyan](https://github.com/akopdev)
nbcat-0.9.3/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.9.0"
3
+ version = "0.9.3"
4
4
  description = "cat for jupyter notebooks"
5
5
  authors = [
6
6
  { name = "Akop Kesheshyan", email = "devnull@akop.dev" }
@@ -0,0 +1 @@
1
+ __version__ = "0.9.3"
@@ -26,7 +26,7 @@ from .schemas import Cell, Notebook
26
26
  console = Console()
27
27
 
28
28
 
29
- def read_notebook(fp: str) -> Notebook:
29
+ def read_notebook(fp: str, debug: bool = False) -> Notebook:
30
30
  """
31
31
  Load and parse a Jupyter notebook from a local file or remote URL.
32
32
 
@@ -61,6 +61,8 @@ def read_notebook(fp: str) -> Notebook:
61
61
  try:
62
62
  return Notebook.model_validate_json(content)
63
63
  except ValidationError as e:
64
+ if not debug:
65
+ raise InvalidNotebookFormatError("Failed to read notebook")
64
66
  raise InvalidNotebookFormatError(f"Invalid notebook: {e}")
65
67
 
66
68
 
@@ -84,19 +86,16 @@ def render_cell(cell: Cell) -> list[tuple[str | None, RenderableType]]:
84
86
  return Markdown(input)
85
87
 
86
88
  def _render_code(input: str) -> Panel:
87
- return Panel(Syntax(input, "python", line_numbers=True, theme="ansi_dark"), box=box.SQUARE)
89
+ return Panel(Syntax(input, "python", theme="ansi_dark"), box=box.SQUARE)
88
90
 
89
91
  def _render_raw(input: str) -> Text:
90
92
  return Text(input)
91
93
 
92
- def _render_heading(input: str) -> Text:
93
- return Text(input)
94
-
95
94
  RENDERERS = {
96
95
  CellType.MARKDOWN: _render_markdown,
97
96
  CellType.CODE: _render_code,
98
97
  CellType.RAW: _render_raw,
99
- CellType.HEADING: _render_heading,
98
+ CellType.HEADING: _render_markdown,
100
99
  }
101
100
 
102
101
  rows: list[tuple[str | None, RenderableType]] = []
@@ -159,11 +158,14 @@ def main():
159
158
  action="version",
160
159
  version=__version__,
161
160
  )
161
+ parser.add_argument(
162
+ "--debug", help="enable extended error output", action="store_true", default=False
163
+ )
162
164
 
163
165
  try:
164
166
  argcomplete.autocomplete(parser)
165
167
  args = parser.parse_args()
166
- notebook = read_notebook(args.file)
168
+ notebook = read_notebook(args.file, debug=args.debug)
167
169
  print_notebook(notebook)
168
170
  except Exception as e:
169
171
  sys.exit(f"nbcat: {e}")
@@ -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):
@@ -214,7 +214,7 @@ wheels = [
214
214
 
215
215
  [[package]]
216
216
  name = "nbcat"
217
- version = "0.9.0"
217
+ version = "0.9.3"
218
218
  source = { editable = "." }
219
219
  dependencies = [
220
220
  { name = "argcomplete" },
nbcat-0.9.0/README.md DELETED
@@ -1,88 +0,0 @@
1
- # 📦 nbcat
2
-
3
- cat for jupyter notebooks
4
-
5
- [![License](https://img.shields.io/github/license/akopdev/nbcat)](./LICENSE)
6
- [![Build](https://github.com/akopdev/nbcat/actions/workflows/ci.yml/badge.svg)](https://github.com/akopdev/nbcat/actions)
7
-
8
- ---
9
-
10
- ## 🚀 Features
11
-
12
- - ✅ Clean, minimal API
13
- - 🧰 Easily extensible
14
- - 🧪 Fully tested and type-annotated
15
- - ⚡ Fast and lightweight
16
- - 📦 Available on PyPI
17
-
18
- ---
19
-
20
- ## 📦 Installation
21
-
22
- Install with [uv](https://github.com/astral-sh/uv)
23
-
24
- ```bash
25
- uv pip install nbcat
26
- ```
27
-
28
- To install the latest development version:
29
-
30
- ```bash
31
- uv pip install git+https://github.com/akopdev/nbcat.git
32
- ```
33
-
34
- ---
35
-
36
- ## 🛠️ Quickstart
37
-
38
- ```python
39
- # example of using the package
40
- ```
41
-
42
- For more examples, check out the [`examples/`](./examples/) folder.
43
-
44
- ---
45
-
46
- ## 🧪 Testing & Development
47
-
48
- Run the tests:
49
-
50
- ```bash
51
- make test
52
- ```
53
-
54
- Check code quality:
55
-
56
- ```bash
57
- make lint
58
- ```
59
-
60
- Format code:
61
-
62
- ```bash
63
- make format
64
- ```
65
-
66
- ---
67
-
68
- ## 🙌 Contributing
69
-
70
- Contributions are welcome! Please open an issue or [pull request](https://github.com/akopdev/nbcat/pulls).
71
-
72
- ---
73
-
74
- ## 📄 License
75
-
76
- Distributed under the MIT License. See [`LICENSE`](./LICENSE) for more information.
77
-
78
- ---
79
-
80
- ## 🔗 Useful Links
81
-
82
- - 📘 Documentation: _coming soon_
83
- - 🐛 Issues: [GitHub Issues](https://github.com/akopdev/nbcat/issues)
84
- - 🚀 Releases: [GitHub Releases](https://github.com/akopdev/nbcat/releases)
85
-
86
- ---
87
-
88
- > Made with ❤️ by [Akop Kesheshyan](https://github.com/akopdev)
@@ -1 +0,0 @@
1
- __version__ = "0.9.0"
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
File without changes