nbcat 0.8.2__py3-none-any.whl → 0.9.2__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 CHANGED
@@ -1 +1 @@
1
- __version__ = "0.8.2"
1
+ __version__ = "0.9.2"
nbcat/main.py CHANGED
@@ -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)
nbcat/schemas.py CHANGED
@@ -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}")
@@ -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)
@@ -0,0 +1,11 @@
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,,
@@ -1,11 +0,0 @@
1
- nbcat/__init__.py,sha256=B7GiO0rd49YwtLYjvPg4lmCZEDlMTonslQKdSImaMJk,22
2
- nbcat/enums.py,sha256=ZsuOwYLF0D4PVwSkS74LwoXY0y0DkeBToLBWnmiS97Y,300
3
- nbcat/exceptions.py,sha256=Ho7LQz9K70VtIMDNtAwuAtGmb-lFKxGxSj7MN3-EpDA,321
4
- nbcat/main.py,sha256=5OawByiWMAX6LX25-Net8zZDE4_0m7a8GOKMIN-UjJc,4919
5
- nbcat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- nbcat/schemas.py,sha256=F5Wl0ZWa5j8RK4H98nDJm69h3oecEuP6wu62823Cxyg,2340
7
- nbcat-0.8.2.dist-info/METADATA,sha256=4yOzFXgN_yzTC0X8ItssABMyzvNNPVSp1KBXBeb-hi8,3385
8
- nbcat-0.8.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- nbcat-0.8.2.dist-info/entry_points.txt,sha256=io_GRDsecAkYuCZALsjyea3VBq91VCoSznqlZEAJshY,42
10
- nbcat-0.8.2.dist-info/licenses/LICENSE,sha256=7GjUnahXdd5opdvlpJdb1BisLbiXt2iOFhzIUduhdkE,1072
11
- nbcat-0.8.2.dist-info/RECORD,,
File without changes