visidata icon indicating copy to clipboard operation
visidata copied to clipboard

[eml] Traceback when using the x command to extract entries without a filename

Open frosencrantz opened this issue 2 months ago • 1 comments

Small description In an eml file I get a traceback when using the x command to extract entries without a filename

Expected result File is extracted or asks for a filename to use.

Actual result with screenshot

https://asciinema.org/a/HENigRDqV7EOsvf6TM6uN1DAg

Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/visidata/basesheet.py", line 211, in execCommand
escaped = super().execCommand2(cmd, vdglobals=vdglobals)
File "/usr/lib/python3.9/site-packages/visidata/extensible.py", line 79, in wrappedfunc
r = oldfunc(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/visidata/basesheet.py", line 76, in execCommand2
exec(code, vdglobals, LazyChainMap(vd, self))
File "extract-part", line 1, in <module>
'VisiData: a curses interface for exploring and arranging tabular data'
File "/usr/lib/python3.9/site-packages/visidata/_open.py", line 23, in inputPath
return Path(vd.inputFilename(*args, **kwargs))
File "/usr/lib/python3.9/site-packages/visidata/_open.py", line 18, in inputFilename
return vd.input(prompt, type="filename", *args, completer=completer, **kwargs).strip()
File "/usr/lib/python3.9/site-packages/visidata/_input.py", line 543, in input
ret = vd.editText(y, promptlen, w=w,
File "/usr/lib/python3.9/site-packages/visidata/_input.py", line 376, in editText
v = type(starting_value)(v)
TypeError: NoneType takes no arguments

Steps to reproduce with sample data and a .vd

Github has .eml files: https://github.com/search?q=path%3A%2F%5C.eml%24%2F&type=code

Here are a few:

  • https://raw.githubusercontent.com/phiresky/ripgrep-all/179f7cb5ceb63eee7de1abbdde2b44e7fa7d100e/exampledir/mail_nested.eml
    • Contains html without filename, and unable to save (See the stack trace below)
  • https://raw.githubusercontent.com/guardian/grid/c7ed800a97eeed21251a915d193683b7668a6377/dev/config/usages.eml
    • Contains a csv file, that has a filename, and can be extracted.
  • https://raw.githubusercontent.com/sendgrid/go-gmime/9326dd0f4619b06caff9c384596c30caa59882fb/gmime/fixtures/benchmark.eml
    • Contains html with a table but no filename

I still see the error when using the x command for entries without a filename. I think it would be useful if when diving into a row, that it would open the file in VisiData, so you can read html files or other data files it contains.

vd  https://raw.githubusercontent.com/guardian/grid/c7ed800a97eeed21251a915d193683b7668a6377/dev/config/usages.eml https://raw.githubusercontent.com/phiresky/ripgrep-all/179f7cb5ceb63eee7de1abbdde2b44e7fa7d100e/exampledir/mail_nested.eml

Additional context Please include the version of VisiData and Python. Head version of VisiData around Feb 23

frosencrantz avatar Apr 09 '24 18:04 frosencrantz