nbcat 0.11.0__tar.gz → 0.12.0__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.
- nbcat-0.12.0/.github/workflows/homebrew.yml +23 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/PKG-INFO +6 -3
- {nbcat-0.11.0 → nbcat-0.12.0}/README.md +5 -2
- {nbcat-0.11.0 → nbcat-0.12.0}/pyproject.toml +1 -1
- nbcat-0.12.0/src/nbcat/__init__.py +1 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/src/nbcat/markdown.py +29 -1
- {nbcat-0.11.0 → nbcat-0.12.0}/uv.lock +1 -1
- nbcat-0.11.0/src/nbcat/__init__.py +0 -1
- {nbcat-0.11.0 → nbcat-0.12.0}/.github/workflows/ci.yml +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/.gitignore +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/LICENSE +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/Makefile +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/docs/screenshot.png +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/src/nbcat/enums.py +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/src/nbcat/exceptions.py +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/src/nbcat/image.py +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/src/nbcat/main.py +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/src/nbcat/py.typed +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/src/nbcat/schemas.py +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/assets/invalid.ipynb +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/assets/many_tracebacks.ipynb +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/assets/no_min_version.ipynb +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/assets/test3.ipynb +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/assets/test3_no_metadata.ipynb +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/assets/test3_no_min_version.ipynb +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/assets/test3_no_worksheets.ipynb +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/assets/test3_worksheet_with_no_cells.ipynb +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/assets/test4.5.ipynb +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/assets/test4.ipynb +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/assets/test4custom.ipynb +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/assets/test4docinfo.ipynb +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/assets/test4jupyter_metadata.ipynb +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/assets/test4jupyter_metadata_timings.ipynb +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/conftest.py +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/test_read_notebook.py +0 -0
- {nbcat-0.11.0 → nbcat-0.12.0}/tests/test_render_cell.py +0 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
name: Release to Homebrew
|
2
|
+
|
3
|
+
on:
|
4
|
+
release:
|
5
|
+
types: [published]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
homebrew-releaser:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
steps:
|
11
|
+
- name: Release project to Homebrew tap
|
12
|
+
uses: Justintime50/homebrew-releaser@v2
|
13
|
+
with:
|
14
|
+
homebrew_owner: akopdev
|
15
|
+
homebrew_tap: homebrew-formulas
|
16
|
+
github_token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
17
|
+
install: 'virtualenv_install_with_resources'
|
18
|
+
test: 'assert_match version.to_s, shell_output("#{bin}/nbcat --version")'
|
19
|
+
commit_owner: akopdev
|
20
|
+
commit_email: devnull@akop.dev
|
21
|
+
update_readme_table: true
|
22
|
+
formula_includes: 'include Language::Python::Virtualenv'
|
23
|
+
depends_on: '"python@3.13"'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nbcat
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.12.0
|
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
|
@@ -68,10 +68,13 @@ Please note, that `nbcat` doesn't aim to replace JupyterLab. If you need a full-
|
|
68
68
|
|
69
69
|
## Installation
|
70
70
|
|
71
|
-
From the command line using pip:
|
72
|
-
|
73
71
|
```bash
|
72
|
+
# Install from PyPI
|
74
73
|
pip install nbcat
|
74
|
+
|
75
|
+
# Install via Homebrew
|
76
|
+
brew tab akopdev/formulas/nbcat
|
77
|
+
brew install nbcat
|
75
78
|
```
|
76
79
|
|
77
80
|
## Quickstart
|
@@ -24,10 +24,13 @@ Please note, that `nbcat` doesn't aim to replace JupyterLab. If you need a full-
|
|
24
24
|
|
25
25
|
## Installation
|
26
26
|
|
27
|
-
From the command line using pip:
|
28
|
-
|
29
27
|
```bash
|
28
|
+
# Install from PyPI
|
30
29
|
pip install nbcat
|
30
|
+
|
31
|
+
# Install via Homebrew
|
32
|
+
brew tab akopdev/formulas/nbcat
|
33
|
+
brew install nbcat
|
31
34
|
```
|
32
35
|
|
33
36
|
## Quickstart
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "0.12.0"
|
@@ -10,12 +10,17 @@
|
|
10
10
|
|
11
11
|
from __future__ import annotations
|
12
12
|
|
13
|
+
import base64
|
14
|
+
from pathlib import Path
|
13
15
|
from typing import ClassVar
|
14
16
|
|
17
|
+
import requests
|
15
18
|
from rich import markdown as md
|
16
19
|
from rich.console import Console, ConsoleOptions, RenderResult
|
17
20
|
from rich.text import Text
|
18
21
|
|
22
|
+
from .image import Image
|
23
|
+
|
19
24
|
|
20
25
|
class Heading(md.Heading):
|
21
26
|
"""A heading."""
|
@@ -30,6 +35,29 @@ class Heading(md.Heading):
|
|
30
35
|
yield Text(f"{'#' * indent} {self.text}", style=styles.get(self.tag, "dim white"))
|
31
36
|
|
32
37
|
|
38
|
+
class ImageItem(md.ImageItem):
|
39
|
+
"""Renders a placeholder for an image."""
|
40
|
+
|
41
|
+
def __rich_console__(self, console: Console, options: ConsoleOptions) -> RenderResult:
|
42
|
+
image_content = None
|
43
|
+
path = Path(self.destination)
|
44
|
+
if path.exists():
|
45
|
+
image_content = path.read_bytes()
|
46
|
+
elif self.destination.startswith("http://") or self.destination.startswith("https://"):
|
47
|
+
try:
|
48
|
+
with requests.Session() as req:
|
49
|
+
res = req.get(self.destination, timeout=5)
|
50
|
+
res.raise_for_status()
|
51
|
+
image_content = res.content
|
52
|
+
except requests.RequestException:
|
53
|
+
return super().__rich_console__(console, options)
|
54
|
+
if image_content:
|
55
|
+
# TODO: This part can be improved by changing Image class to accept file objects
|
56
|
+
image = base64.b64encode(image_content).decode("utf-8")
|
57
|
+
return Image(image).__rich_console__(console, options)
|
58
|
+
return super().__rich_console__(console, options)
|
59
|
+
|
60
|
+
|
33
61
|
class Markdown(md.Markdown):
|
34
62
|
elements: ClassVar[dict[str, type[md.MarkdownElement]]] = {
|
35
63
|
"paragraph_open": md.Paragraph,
|
@@ -41,7 +69,7 @@ class Markdown(md.Markdown):
|
|
41
69
|
"bullet_list_open": md.ListElement,
|
42
70
|
"ordered_list_open": md.ListElement,
|
43
71
|
"list_item_open": md.ListItem,
|
44
|
-
"image":
|
72
|
+
"image": ImageItem,
|
45
73
|
"table_open": md.TableElement,
|
46
74
|
"tbody_open": md.TableBodyElement,
|
47
75
|
"thead_open": md.TableHeaderElement,
|
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = "0.11.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
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|