PR for UID EXPUNGE to achieve MOVE semantics

dave@...
 

Hello maintainers and others,
 
I am using IMAPClient for a project, and have a need for single-message MOVE semantics. I saw the comment on this issue "...implement the MOVE extension to the UID command." https://github.com/mjs/imapclient/issues/142
 
Unfortunately, we need a patch to imaplib.py to get it to support 'UID MOVE' - it won't issue 'UID <command>' unless it supports <command>. https://github.com/python/cpython/blob/2.7/Lib/imaplib.py#L767-L768
 
I can achieve the semantics I want with:
 
COPY m other_folder
DELETE m
UID EXPUNGE m
 
(UID EXPUNGE is desirable to avoid expunging every deleted message in a folder).
 
So I put together this change to allow for UID EXPUNGE, based on the 1.x branch:
 
https://github.com/davebrown/imapclient/commit/fc8a0eeb2fc7c35f8355734fb7cd6b758ff721e2
 
The idea is to overload arguments to expunge(): if messages are specified, do a 'UID EXPUNGE <messages>', else it is a folder-wide expunge(). The former won't work if use_uid=False. I don't have insight how many IMAPClient users turn off uid's. 
 
This also implements item on the list for https://github.com/mjs/imapclient/issues/36
 
That change also adds a livetest, which asserts that only the specified message is expunged, and other Deleted messages remain.
 
If that change is within the ethos of the project, I'll submit a PR (to 1.x? master?). Otherwise, I'd like to figure out a way to achieve MOVE without a global expunge.
 
Thanks,
Dave Brown
 
PS - I'm unsure what should be the return type from UID expunge. It's currently None, but should probably be whatever is the response payload, but I haven't sorted out the helper methods needed to achieve that. If the change is on the right track, I'll try to figure that out.
 

Join imapclient@groups.io to automatically receive all group messages.