Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File name too long #496

Closed
paw-lu opened this issue Mar 11, 2022 · 0 comments · Fixed by #498
Closed

File name too long #496

paw-lu opened this issue Mar 11, 2022 · 0 comments · Fixed by #498
Labels
bug Something isn't working

Comments

@paw-lu
Copy link
Owner

paw-lu commented Mar 11, 2022

What happened?

File name too long on notebook

nbpreview version

0.8.0

Output

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│                                                                                                  │
│ /Users/pawlu/.local/bin/nbp:8 in <module>                                                        │
│                                                                                                  │
│   5 from nbpreview.__main__ import app                                                           │
│   6 if __name__ == '__main__':                                                                   │
│   7 │   sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])                         │
│ ❱ 8 │   sys.exit(app())                                                                          │
│   9                                                                                              │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/typer/main.py:214 in       │
│ __call__                                                                                         │
│                                                                                                  │
│   211 │   │   )                                                                                  │
│   212 │                                                                                          │
│   213 │   def __call__(self, *args: Any, **kwargs: Any) -> Any:                                  │
│ ❱ 214 │   │   return get_command(self)(*args, **kwargs)                                          │
│   215                                                                                            │
│   216                                                                                            │
│   217 def get_group(typer_instance: Typer) -> click.Command:                                     │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/click/core.py:1128 in      │
│ __call__                                                                                         │
│                                                                                                  │
│   1125 │                                                                                         │
│   1126 │   def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Any:                           │
│   1127 │   │   """Alias for :meth:`main`."""                                                     │
│ ❱ 1128 │   │   return self.main(*args, **kwargs)                                                 │
│   1129                                                                                           │
│   1130                                                                                           │
│   1131 class Command(BaseCommand):                                                               │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/click/core.py:1053 in main │
│                                                                                                  │
│   1050 │   │   try:                                                                              │
│   1051 │   │   │   try:                                                                          │
│   1052 │   │   │   │   with self.make_context(prog_name, args, **extra) as ctx:                  │
│ ❱ 1053 │   │   │   │   │   rv = self.invoke(ctx)                                                 │
│   1054 │   │   │   │   │   if not standalone_mode:                                               │
│   1055 │   │   │   │   │   │   return rv                                                         │
│   1056 │   │   │   │   │   # it's not safe to `ctx.exit(rv)` here!                               │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/click/core.py:1395 in      │
│ invoke                                                                                           │
│                                                                                                  │
│   1392 │   │   │   echo(style(message, fg="red"), err=True)                                      │
│   1393 │   │                                                                                     │
│   1394 │   │   if self.callback is not None:                                                     │
│ ❱ 1395 │   │   │   return ctx.invoke(self.callback, **ctx.params)                                │
│   1396 │                                                                                         │
│   1397 │   def shell_complete(self, ctx: Context, incomplete: str) -> t.List["CompletionItem"]:  │
│   1398 │   │   """Return a list of completions for the incomplete value. Looks                   │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/click/core.py:754 in       │
│ invoke                                                                                           │
│                                                                                                  │
│    751 │   │                                                                                     │
│    752 │   │   with augment_usage_errors(__self):                                                │
│    753 │   │   │   with ctx:                                                                     │
│ ❱  754 │   │   │   │   return __callback(*args, **kwargs)                                        │
│    755 │                                                                                         │
│    756 │   def forward(                                                                          │
│    757 │   │   __self, __cmd: "Command", *args: t.Any, **kwargs: t.Any  # noqa: B902             │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/typer/main.py:500 in       │
│ wrapper                                                                                          │
│                                                                                                  │
│   497 │   │   │   │   use_params[k] = v                                                          │
│   498 │   │   if context_param_name:                                                             │
│   499 │   │   │   use_params[context_param_name] = click.get_current_context()                   │
│ ❱ 500 │   │   return callback(**use_params)  # type: ignore                                      │
│   501 │                                                                                          │
│   502 │   update_wrapper(wrapper, callback)                                                      │
│   503 │   return wrapper                                                                         │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/nbpreview/__main__.py:228  │
│ in main                                                                                          │
│                                                                                                  │
│   225 │   │   │   │   │   │   plain=plain_title,                                                 │
│   226 │   │   │   │   │   │   has_multiple_files=has_multiple_files,                             │
│   227 │   │   │   │   │   )                                                                      │
│ ❱ 228 │   │   │   │   │   output_console.print(titled_output)                                    │
│   229 │                                                                                          │
│   230 │   if successful_render:                                                                  │
│   231 │   │   _render_notebook(                                                                  │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/console.py:1621 in    │
│ print                                                                                            │
│                                                                                                  │
│   1618 │   │   │   render = self.render                                                          │
│   1619 │   │   │   if style is None:                                                             │
│   1620 │   │   │   │   for renderable in renderables:                                            │
│ ❱ 1621 │   │   │   │   │   extend(render(renderable, render_options))                            │
│   1622 │   │   │   else:                                                                         │
│   1623 │   │   │   │   for renderable in renderables:                                            │
│   1624 │   │   │   │   │   extend(                                                               │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/console.py:1263 in    │
│ render                                                                                           │
│                                                                                                  │
│   1260 │   │   │   if isinstance(render_output, _Segment):                                       │
│   1261 │   │   │   │   yield render_output                                                       │
│   1262 │   │   │   else:                                                                         │
│ ❱ 1263 │   │   │   │   yield from self.render(render_output, _options)                           │
│   1264 │                                                                                         │
│   1265 │   def render_lines(                                                                     │
│   1266 │   │   self,                                                                             │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/console.py:1263 in    │
│ render                                                                                           │
│                                                                                                  │
│   1260 │   │   │   if isinstance(render_output, _Segment):                                       │
│   1261 │   │   │   │   yield render_output                                                       │
│   1262 │   │   │   else:                                                                         │
│ ❱ 1263 │   │   │   │   yield from self.render(render_output, _options)                           │
│   1264 │                                                                                         │
│   1265 │   def render_lines(                                                                     │
│   1266 │   │   self,                                                                             │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/console.py:1259 in    │
│ render                                                                                           │
│                                                                                                  │
│   1256 │   │   │   │   f"object {render_iterable!r} is not renderable"                           │
│   1257 │   │   │   )                                                                             │
│   1258 │   │   _Segment = Segment                                                                │
│ ❱ 1259 │   │   for render_output in iter_render:                                                 │
│   1260 │   │   │   if isinstance(render_output, _Segment):                                       │
│   1261 │   │   │   │   yield render_output                                                       │
│   1262 │   │   │   else:                                                                         │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/table.py:468 in       │
│ __rich_console__                                                                                 │
│                                                                                                  │
│   465 │   │   │   │   style=Style.pick_first(self.title_style, "table.title"),                   │
│   466 │   │   │   │   justify=self.title_justify,                                                │
│   467 │   │   │   )                                                                              │
│ ❱ 468 │   │   yield from self._render(console, render_options, widths)                           │
│   469 │   │   if self.caption:                                                                   │
│   470 │   │   │   yield from render_annotation(                                                  │
│   471 │   │   │   │   self.caption,                                                              │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/table.py:774 in       │
│ _render                                                                                          │
│                                                                                                  │
│   771 │   │   │   │   │   height=None,                                                           │
│   772 │   │   │   │   )                                                                          │
│   773 │   │   │   │   cell_style = table_style + row_style + get_style(cell.style)               │
│ ❱ 774 │   │   │   │   lines = console.render_lines(                                              │
│   775 │   │   │   │   │   cell.renderable, render_options, style=cell_style                      │
│   776 │   │   │   │   )                                                                          │
│   777 │   │   │   │   max_height = max(max_height, len(lines))                                   │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/console.py:1294 in    │
│ render_lines                                                                                     │
│                                                                                                  │
│   1291 │   │   │   _rendered = self.render(renderable, render_options)                           │
│   1292 │   │   │   if style:                                                                     │
│   1293 │   │   │   │   _rendered = Segment.apply_style(_rendered, style)                         │
│ ❱ 1294 │   │   │   lines = list(                                                                 │
│   1295 │   │   │   │   islice(                                                                   │
│   1296 │   │   │   │   │   Segment.split_and_crop_lines(                                         │
│   1297 │   │   │   │   │   │   _rendered,                                                        │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/segment.py:280 in     │
│ split_and_crop_lines                                                                             │
│                                                                                                  │
│   277 │   │   adjust_line_length = cls.adjust_line_length                                        │
│   278 │   │   new_line_segment = cls("\n")                                                       │
│   279 │   │                                                                                      │
│ ❱ 280 │   │   for segment in segments:                                                           │
│   281 │   │   │   if "\n" in segment.text and not segment.control:                               │
│   282 │   │   │   │   text, style, _ = segment                                                   │
│   283 │   │   │   │   while text:                                                                │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/console.py:1259 in    │
│ render                                                                                           │
│                                                                                                  │
│   1256 │   │   │   │   f"object {render_iterable!r} is not renderable"                           │
│   1257 │   │   │   )                                                                             │
│   1258 │   │   _Segment = Segment                                                                │
│ ❱ 1259 │   │   for render_output in iter_render:                                                 │
│   1260 │   │   │   if isinstance(render_output, _Segment):                                       │
│   1261 │   │   │   │   yield render_output                                                       │
│   1262 │   │   │   else:                                                                         │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/padding.py:97 in      │
│ __rich_console__                                                                                 │
│                                                                                                  │
│    94 │   │   │   render_options = render_options.update_height(                                 │
│    95 │   │   │   │   height=render_options.height - self.top - self.bottom                      │
│    96 │   │   │   )                                                                              │
│ ❱  97 │   │   lines = console.render_lines(                                                      │
│    98 │   │   │   self.renderable, render_options, style=style, pad=True                         │
│    99 │   │   )                                                                                  │
│   100 │   │   _Segment = Segment                                                                 │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/console.py:1294 in    │
│ render_lines                                                                                     │
│                                                                                                  │
│   1291 │   │   │   _rendered = self.render(renderable, render_options)                           │
│   1292 │   │   │   if style:                                                                     │
│   1293 │   │   │   │   _rendered = Segment.apply_style(_rendered, style)                         │
│ ❱ 1294 │   │   │   lines = list(                                                                 │
│   1295 │   │   │   │   islice(                                                                   │
│   1296 │   │   │   │   │   Segment.split_and_crop_lines(                                         │
│   1297 │   │   │   │   │   │   _rendered,                                                        │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/segment.py:280 in     │
│ split_and_crop_lines                                                                             │
│                                                                                                  │
│   277 │   │   adjust_line_length = cls.adjust_line_length                                        │
│   278 │   │   new_line_segment = cls("\n")                                                       │
│   279 │   │                                                                                      │
│ ❱ 280 │   │   for segment in segments:                                                           │
│   281 │   │   │   if "\n" in segment.text and not segment.control:                               │
│   282 │   │   │   │   text, style, _ = segment                                                   │
│   283 │   │   │   │   while text:                                                                │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/console.py:1259 in    │
│ render                                                                                           │
│                                                                                                  │
│   1256 │   │   │   │   f"object {render_iterable!r} is not renderable"                           │
│   1257 │   │   │   )                                                                             │
│   1258 │   │   _Segment = Segment                                                                │
│ ❱ 1259 │   │   for render_output in iter_render:                                                 │
│   1260 │   │   │   if isinstance(render_output, _Segment):                                       │
│   1261 │   │   │   │   yield render_output                                                       │
│   1262 │   │   │   else:                                                                         │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/padding.py:97 in      │
│ __rich_console__                                                                                 │
│                                                                                                  │
│    94 │   │   │   render_options = render_options.update_height(                                 │
│    95 │   │   │   │   height=render_options.height - self.top - self.bottom                      │
│    96 │   │   │   )                                                                              │
│ ❱  97 │   │   lines = console.render_lines(                                                      │
│    98 │   │   │   self.renderable, render_options, style=style, pad=True                         │
│    99 │   │   )                                                                                  │
│   100 │   │   _Segment = Segment                                                                 │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/console.py:1294 in    │
│ render_lines                                                                                     │
│                                                                                                  │
│   1291 │   │   │   _rendered = self.render(renderable, render_options)                           │
│   1292 │   │   │   if style:                                                                     │
│   1293 │   │   │   │   _rendered = Segment.apply_style(_rendered, style)                         │
│ ❱ 1294 │   │   │   lines = list(                                                                 │
│   1295 │   │   │   │   islice(                                                                   │
│   1296 │   │   │   │   │   Segment.split_and_crop_lines(                                         │
│   1297 │   │   │   │   │   │   _rendered,                                                        │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/segment.py:280 in     │
│ split_and_crop_lines                                                                             │
│                                                                                                  │
│   277 │   │   adjust_line_length = cls.adjust_line_length                                        │
│   278 │   │   new_line_segment = cls("\n")                                                       │
│   279 │   │                                                                                      │
│ ❱ 280 │   │   for segment in segments:                                                           │
│   281 │   │   │   if "\n" in segment.text and not segment.control:                               │
│   282 │   │   │   │   text, style, _ = segment                                                   │
│   283 │   │   │   │   while text:                                                                │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/console.py:1263 in    │
│ render                                                                                           │
│                                                                                                  │
│   1260 │   │   │   if isinstance(render_output, _Segment):                                       │
│   1261 │   │   │   │   yield render_output                                                       │
│   1262 │   │   │   else:                                                                         │
│ ❱ 1263 │   │   │   │   yield from self.render(render_output, _options)                           │
│   1264 │                                                                                         │
│   1265 │   def render_lines(                                                                     │
│   1266 │   │   self,                                                                             │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/console.py:1259 in    │
│ render                                                                                           │
│                                                                                                  │
│   1256 │   │   │   │   f"object {render_iterable!r} is not renderable"                           │
│   1257 │   │   │   )                                                                             │
│   1258 │   │   _Segment = Segment                                                                │
│ ❱ 1259 │   │   for render_output in iter_render:                                                 │
│   1260 │   │   │   if isinstance(render_output, _Segment):                                       │
│   1261 │   │   │   │   yield render_output                                                       │
│   1262 │   │   │   else:                                                                         │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/markdown.py:497 in    │
│ __rich_console__                                                                                 │
│                                                                                                  │
│   494 │   │   │   │   element_class = self.elements.get(node_type) or UnknownElement             │
│   495 │   │   │   │   if current.is_container():                                                 │
│   496 │   │   │   │   │   if entering:                                                           │
│ ❱ 497 │   │   │   │   │   │   element = element_class.create(self, current)                      │
│   498 │   │   │   │   │   │   context.stack.push(element)                                        │
│   499 │   │   │   │   │   │   element.on_enter(context)                                          │
│   500 │   │   │   │   │   else:                                                                  │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/rich/markdown.py:321 in    │
│ create                                                                                           │
│                                                                                                  │
│   318 │   │   Returns:                                                                           │
│   319 │   │   │   MarkdownElement: A new markdown element                                        │
│   320 │   │   """                                                                                │
│ ❱ 321 │   │   return cls(node.destination, markdown.hyperlinks)                                  │
│   322 │                                                                                          │
│   323 │   def __init__(self, destination: str, hyperlinks: bool) -> None:                        │
│   324 │   │   self.destination = destination                                                     │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/nbpreview/component/markdo │
│ wn.py:249 in __init__                                                                            │
│                                                                                                  │
│   246 │   │   self.extension = self.path.suffix.lstrip(".")                                      │
│   247 │   │   if content is not None and (self.images or (self.is_url and self.files)):          │
│   248 │   │   │   try:                                                                           │
│ ❱ 249 │   │   │   │   with Image.open(content) as image:                                         │
│   250 │   │   │   │   │   with io.BytesIO() as output:                                           │
│   251 │   │   │   │   │   │   try:                                                               │
│   252 │   │   │   │   │   │   │   format = Image.EXTENSION[f".{self.extension}"]                 │
│                                                                                                  │
│ /Users/pawlu/.local/pipx/venvs/nbpreview/lib/python3.10/site-packages/PIL/Image.py:2953 in open  │
│                                                                                                  │
│   2950 │   │   filename = fp                                                                     │
│   2951 │                                                                                         │
│   2952 │   if filename:                                                                          │
│ ❱ 2953 │   │   fp = builtins.open(filename, "rb")                                                │
│   2954 │   │   exclusive_fp = True                                                               │
│   2955 │                                                                                         │
│   2956 │   try:                                                                                  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
OSError: [Errno 63] File name too long: '/Users/pawlu/Documents/personal/BAP/extras/data:image/png;base64,iVBORw0KGgoAAAANS

Notebook

https://github.com/aloctavodia/BAP/blob/master/extras/interactions.ipynb

OS

No response

Terminal

No response

Python version

No response

@paw-lu paw-lu added the bug Something isn't working label Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant