mbox-to-sqlite icon indicating copy to clipboard operation
mbox-to-sqlite copied to clipboard

Search all parts of a message

Open tgs opened this issue 11 months ago • 0 comments

Hiya, This is a very rough first stab at dealing with #2 . It only makes sense if all the parts of the email are plain text, but that happens to be the case for me.

Before this patch, if you have multipart messages, you end up with payloads of the repr() of the message objects, like

["<email.message.Message object at 0x7fecbb4cac30>",
 "<email.message.Message object at 0x7fecbbff7ce0>",
 "<email.message.Message object at 0x7fecbbf56e00>"]

You can see by rolling back to the failing-test commit.

This patch just concatenates all of the text parts together... clearly there are better ways. An alternative to this patch could be to detect if the email is multipart, and throw an error?

if not isinstance(row["payload"], str):
    raise ValueError("An email is not plain-text")

Anyway, like I said, this is good enough for me - I'm happy to spend a little time reworking it if you like the concept, but my feelings won't be hurt if you don't like it. Thanks very much for datasette and the related items!

tgs avatar May 06 '25 21:05 tgs