visidata icon indicating copy to clipboard operation
visidata copied to clipboard

[eml loader] The email loader doesn't import email.parser

Open frosencrantz opened this issue 4 months ago • 1 comments

Small description The eml loader uses the Python built email.parser module, but does not import it.

Expected result Load and read MIME messages.

Actual result with screenshot If you get an unexpected error, please include the full stack trace that you get with Ctrl-E.

Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/visidata/threads.py", line 220, in _toplevelTryFunc
t.status = func(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/visidata/sheets.py", line 260, in reload
self.loader()
File "/usr/lib/python3.9/site-packages/visidata/sheets.py", line 285, in loader
for r in self.iterload():
File "/usr/lib/python3.9/site-packages/visidata/loaders/eml.py", line 18, in iterload
parser = email.parser.Parser()
AttributeError: module 'email' has no attribute 'parser'

Steps to reproduce with sample data and a .vd

vd -f eml foo.mhtml

For this error you do not even need a valid email file or MIME file, since there is a missing import email.parser which fails when the code tries to parse the input

Additional context Please include the version of VisiData and Python. Latest develop branch. Python 3.9.2

I was able to save a webpage as an MHTML file via my web browser. Since this is an MIME format, I though VisiData could read it. There is a missing import.

Even with the proper import in place, there is another bug that causes the code to not properly open or save individual file content from within the file. I only tried using an mhtml file.

frosencrantz avatar Feb 13 '24 21:02 frosencrantz