diff options
author | Guido van Rossum <guido@python.org> | 1996-07-21 02:18:22 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-07-21 02:18:22 (GMT) |
commit | 6d6a15bab20b27f739d5c9a44903a4e420ce3af7 (patch) | |
tree | e404b313608fc316fd057bcefdb801c2de9186a1 /Lib | |
parent | 154a539460974738da40feb637a624cb05fe098d (diff) | |
download | cpython-6d6a15bab20b27f739d5c9a44903a4e420ce3af7.zip cpython-6d6a15bab20b27f739d5c9a44903a4e420ce3af7.tar.gz cpython-6d6a15bab20b27f739d5c9a44903a4e420ce3af7.tar.bz2 |
Added option to refilemessages() to keep sequences
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/mhlib.py | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/Lib/mhlib.py b/Lib/mhlib.py index 79eee26..f8599b7 100644 --- a/Lib/mhlib.py +++ b/Lib/mhlib.py @@ -409,9 +409,9 @@ class Folder: # Refile one or more messages -- may raise os.error. # 'tofolder' is an open folder object - def refilemessages(self, list, tofolder): + def refilemessages(self, list, tofolder, keepsequences=0): errors = [] - refiled = [] + refiled = {} for n in list: ton = tofolder.getlast() + 1 path = self.getmessagefilename(n) @@ -431,15 +431,38 @@ class Folder: pass continue tofolder.setlast(ton) - refiled.append(n) + refiled[n] = ton if refiled: - self.removefromallsequences(refiled) + if keepsequences: + tofolder._copysequences(self, refiled.items()) + self.removefromallsequences(refiled.keys()) if errors: if len(errors) == 1: raise os.error, errors[0] else: raise os.error, ('multiple errors:', errors) + # Helper for refilemessages() to copy sequences + def _copysequences(self, fromfolder, refileditems): + fromsequences = fromfolder.getsequences() + tosequences = self.getsequences() + changed = 0 + for name, seq in fromsequences.items(): + try: + toseq = tosequences[name] + new = 0 + except: + toseq = [] + new = 1 + for fromn, ton in refileditems: + if fromn in seq: + toseq.append(ton) + changed = 1 + if new and toseq: + tosequences[name] = toseq + if changed: + self.putsequences(tosequences) + # Move one message over a specific destination message, # which may or may not already exist. def movemessage(self, n, tofolder, ton): |