-
Notifications
You must be signed in to change notification settings - Fork 99
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
Migrate to notmuch2 module #320
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Guillaume Seren <[email protected]>
Signed-off-by: Guillaume Seren <[email protected]>
Signed-off-by: Guillaume Seren <[email protected]>
283ee15 ("Upgrade Database to notmuch2 python module afewmail#278", 2020-11-11) adjusted Databse partially to notmuch2. There, open() does not have a create argument any more. So far, only afew's test suite needs to create a db. So, remove the argument from afew's Database class and use notmuch2's create() directly in the test suite.
Besides the obvious call signature changes, filenames are Posix.Path objects now, searches do not return an email.Message object, and non-existing headers throw a LookupError.
Not caught by the test suite.
f8db509
to
88d675e
Compare
python3-notmuch2 is part of ubuntu 21.04 and later, so we need to bump that, too.
88d675e
to
6e98c68
Compare
ret = set() | ||
for msg in db.open().messages('folder:{}'.format(folder)): | ||
with open(msg.path) as f: | ||
ret.add((os.path.basename(msg.messageid), | ||
email.message_from_file(f).get_payload())) | ||
return ret |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: would it be interesting to run this method asynchronously to speed things up? I believe this will speed things up when someone has a bunch of emails to process. Perhaps having a private method that handles the asynchronous call and calls add
? I've done something similar here: https://github.com/afewmail/afew/pull/316/files#r744197423
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just in the test suite, which has 10 e-mails or so.
That mail mover test suite is not exactly "pretty" anyways, the proposed changes are the minimal ones to let it pass with the notmuch2 bindings. I would refactor the e-mail comparisons quite a bit, for example.
My bad, I didn’t pay attention to the file name.
On Sat, 27 Nov 2021 at 10:57 Michael J Gruber ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In afew/tests/test_mailmover.py
<#320 (comment)>:
> + ret = set()
+ for msg in db.open().messages('folder:{}'.format(folder)):
+ with open(msg.path) as f:
+ ret.add((os.path.basename(msg.messageid),
+ email.message_from_file(f).get_payload()))
+ return ret
This is just in the test suite, which has 10 e-mails or so.
That mail mover test suite is not exactly "pretty" anyways, the proposed
changes are the minimal ones to let it pass with the notmuch2 bindings. I
would refactor the e-mail comparisons quite a bit, for example.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#320 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG7RFQFWCGGQMKVQOKAGJLUODPVBANCNFSM5I3ML44A>
.
--
Ben Mezger
|
Hey @mjg ! This is a big subject as the eco-system is gona migrate to the new python module soon (notmuch, alot and afew), But I didn't merge it right away because many distro still ship older version of notmuch (0.2x I think), Is there something going on with the ci runners ? Maybe there is an issue un GH now ? |
I see that lieer is trying to still support 18LTS versions of ubuntu by catering for both versions of the notmuch bindings. Is that something you would prefer, too? In this case this PR needs to be done differently, of course. (Also, I haven't looked into it since.) |
Hey @mjg, If we can refactor the branch to able to support both, it would nice because we could merge now, In the end it depends on the implementation. |
Is there something I can do to help to get this merged ? The current notmuch bindings bother me by causing segmentation faults is certain cases. |
Hey @hbog , |
What would help (without having to port any bindings) is adding more tests so that at least each filter is covered. |
Here are some contributions on the way to using notmuch2:
I based my work on @GuillaumeSeren `s branch and added my work on top, resulting in a passing test suite. The test suite does not cover all code paths. The last commit in this PR covers changes which are not caught by the suite, and I have not run this branch against my "real" mail database yet.
Also, I use a generator expression at some point, and this may fail on older python versions - I'm not sure which ones afew wants to support.
So, basically: do not merge yet ;)