nbcat 0.12.0__py3-none-any.whl → 0.12.1__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.12.0"
1
+ __version__ = "0.12.1"
nbcat/main.py CHANGED
@@ -6,7 +6,6 @@ import argcomplete
6
6
  import requests
7
7
  from argcomplete.completers import FilesCompleter
8
8
  from pydantic import ValidationError
9
- from rich import box
10
9
  from rich.console import Console, Group, RenderableType
11
10
  from rich.padding import Padding
12
11
  from rich.panel import Panel
@@ -87,10 +86,8 @@ def render_cell(cell: Cell) -> RenderableType:
87
86
  def _render_markdown(input: str) -> Markdown:
88
87
  return Markdown(input, code_theme="ansi_dark")
89
88
 
90
- def _render_code(input: str, language: str = "python") -> Panel:
91
- return Panel(
92
- Syntax(input, language, line_numbers=True, theme="ansi_dark", dedent=True), padding=0
93
- )
89
+ def _render_code(input: str, language: str = "python") -> Syntax:
90
+ return Syntax(input, language, theme="ansi_dark", padding=(1, 2), dedent=True)
94
91
 
95
92
  def _render_raw(input: str) -> Text:
96
93
  return Text(input)
@@ -116,16 +113,25 @@ def render_cell(cell: Cell) -> RenderableType:
116
113
  renderer = RENDERERS.get(cell.cell_type)
117
114
  source = renderer(cell.input) if renderer else None
118
115
  if source:
119
- rows.append(Padding(source, (1, 0)))
116
+ s_title = f"[green]In [{cell.execution_count}][/]" if cell.execution_count else None
117
+ if s_title:
118
+ rows.append(Panel(source, title=s_title, title_align="left"))
119
+ else:
120
+ rows.append(Padding(source, (1, 0)))
121
+
120
122
  if not cell.outputs:
121
- return source
123
+ return rows.pop()
122
124
 
123
125
  for o in cell.outputs:
126
+ o_title = f"[blue]Out [{o.execution_count}][/]" if o.execution_count else None
124
127
  if o.output:
125
128
  renderer = RENDERERS.get(o.output.output_type)
126
129
  output = renderer(o.output.text) if renderer else None
127
130
  if output:
128
- rows.append(Panel(output, style="italic", box=box.MINIMAL))
131
+ if o_title:
132
+ rows.append(Panel(output, style="italic", title=o_title, title_align="left"))
133
+ else:
134
+ rows.append(Padding(output, (1, 0), style="italic"))
129
135
  return Group(*rows)
130
136
 
131
137
 
@@ -142,15 +148,7 @@ def print_notebook(nb: Notebook):
142
148
 
143
149
  for cell in nb.cells:
144
150
  rendered = render_cell(cell)
145
- if isinstance(rendered, Group):
146
- out = Panel(
147
- rendered,
148
- title=f"[green][{cell.execution_count}][/]" if cell.execution_count else None,
149
- title_align="left",
150
- )
151
- else:
152
- out = Padding(rendered, (1, 0))
153
- console.print(out)
151
+ console.print(rendered)
154
152
 
155
153
 
156
154
  def main():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbcat
3
- Version: 0.12.0
3
+ Version: 0.12.1
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
@@ -1,13 +1,13 @@
1
- nbcat/__init__.py,sha256=eHjt9DPsMbptabS2yGx9Yhbyzq5hFSUHXb7zc8Q_8-o,23
1
+ nbcat/__init__.py,sha256=PAuBI8I6F9Yu_86XjI2yaWn8QmCd9ZvK7tkZLWvEg-Q,23
2
2
  nbcat/enums.py,sha256=Fn8PIcLl_uY4nQIs1EUvmKTwfhNUIZgmhRFiCSJk9wk,411
3
3
  nbcat/exceptions.py,sha256=Ho7LQz9K70VtIMDNtAwuAtGmb-lFKxGxSj7MN3-EpDA,321
4
4
  nbcat/image.py,sha256=hGZZK5mtij7ckWAvQwzim3thqGC92pLW5ZU5CYbRv_Q,995
5
- nbcat/main.py,sha256=vchFzwcvPGmv4pg5AHRaOOsZh83ynmxkTqIKl0z_Sys,5749
5
+ nbcat/main.py,sha256=gZ8mM2louxU8GgB40F7DE7pc7MAidDHatiNjkLUzeug,5839
6
6
  nbcat/markdown.py,sha256=GkPNfzBhNLMl89pVcj14U6ytYUVk3yNB0G1zGYRRJ04,2962
7
7
  nbcat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  nbcat/schemas.py,sha256=a7GoKgPTHgun199-J-sZq-ahkdQwvyRaCdQVg1gC798,3135
9
- nbcat-0.12.0.dist-info/METADATA,sha256=QOcOghWxUMkPA986f-xscLwz-YQrbZQPUJQF8P3r4cQ,4164
10
- nbcat-0.12.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
11
- nbcat-0.12.0.dist-info/entry_points.txt,sha256=io_GRDsecAkYuCZALsjyea3VBq91VCoSznqlZEAJshY,42
12
- nbcat-0.12.0.dist-info/licenses/LICENSE,sha256=7GjUnahXdd5opdvlpJdb1BisLbiXt2iOFhzIUduhdkE,1072
13
- nbcat-0.12.0.dist-info/RECORD,,
9
+ nbcat-0.12.1.dist-info/METADATA,sha256=Jq7TL6gCnqsAn_hm5eTHHK-DRGbp3nXn4aq6-w_jv2Y,4164
10
+ nbcat-0.12.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
11
+ nbcat-0.12.1.dist-info/entry_points.txt,sha256=io_GRDsecAkYuCZALsjyea3VBq91VCoSznqlZEAJshY,42
12
+ nbcat-0.12.1.dist-info/licenses/LICENSE,sha256=7GjUnahXdd5opdvlpJdb1BisLbiXt2iOFhzIUduhdkE,1072
13
+ nbcat-0.12.1.dist-info/RECORD,,
File without changes