From: Guido van Rossum Date: Fri, 25 Jul 1997 14:59:10 +0000 (+0000) Subject: Added createmessage() -- Lars Wirzenius. X-Git-Tag: v1.5a3~179 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4e5cbcf5afa411d654983cd4cf8c99739b935b26;p=thirdparty%2FPython%2Fcpython.git Added createmessage() -- Lars Wirzenius. --- diff --git a/Lib/mhlib.py b/Lib/mhlib.py index 34fc3b0b29ff..838b2f76a7c4 100644 --- a/Lib/mhlib.py +++ b/Lib/mhlib.py @@ -601,6 +601,32 @@ class Folder: except os.error: pass + # Create a message, with text from the open file txt. + def createmessage(self, n, txt): + path = self.getmessagefilename(n) + backuppath = self.getmessagefilename(',%d' % n) + try: + os.rename(path, backuppath) + except os.error: + pass + ok = 0 + BUFSIZE = 16*1024 + try: + f = open(path, "w") + while 1: + buf = txt.read(BUFSIZE) + if not buf: + break + f.write(buf) + f.close() + ok = 1 + finally: + if not ok: + try: + os.unlink(path) + except os.error: + pass + # Remove one or more messages from all sequeuces (including last) # -- but not from 'cur'!!! def removefromallsequences(self, list):