summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-07-25 14:59:10 (GMT)
committerGuido van Rossum <guido@python.org>1997-07-25 14:59:10 (GMT)
commit4e5cbcf5afa411d654983cd4cf8c99739b935b26 (patch)
tree8c9514302e452d777cb381904da240a10f305b0e
parent2e2525fd3cb841cf4850a81c7bb95e97230c6964 (diff)
downloadcpython-4e5cbcf5afa411d654983cd4cf8c99739b935b26.zip
cpython-4e5cbcf5afa411d654983cd4cf8c99739b935b26.tar.gz
cpython-4e5cbcf5afa411d654983cd4cf8c99739b935b26.tar.bz2
Added createmessage() -- Lars Wirzenius.
-rw-r--r--Lib/mhlib.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/mhlib.py b/Lib/mhlib.py
index 34fc3b0..838b2f7 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):