summaryrefslogtreecommitdiff
path: root/Lib/mhlib.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-09-09 11:10:15 +0000
committerGuido van Rossum <guido@python.org>1994-09-09 11:10:15 +0000
commit57b29e6b4c32e5dadcadedd839bbf962713fcba9 (patch)
tree0344fafd299324e198f993732a7b5e1308e5834f /Lib/mhlib.py
parent5f917d8bd079611b59ce737f9f1753db43368906 (diff)
downloadcpython-57b29e6b4c32e5dadcadedd839bbf962713fcba9.tar.gz
mhlib.py: delay opening of sequences file so we don't overwrite it when
putsequences is called with a bad argument rfc822.py: better handling of dates with no or bad timezones uu.py: contributed by Lance -- uu{en,de}code
Diffstat (limited to 'Lib/mhlib.py')
-rw-r--r--Lib/mhlib.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/mhlib.py b/Lib/mhlib.py
index b24695cfeb..5bdda7220d 100644
--- a/Lib/mhlib.py
+++ b/Lib/mhlib.py
@@ -36,6 +36,7 @@
# f.putsequences(dict) # write sequences back to folder
#
# m = f.openmessage(n) # new open message object (costs a file descriptor)
+# m is a derived class of mimetools.Message(rfc822.Message), with:
# s = m.getheadertext() # text of message's headers
# s = m.getheadertext(pred) # text of message's headers, filtered by pred
# s = m.getbodytext() # text of message's body, decoded
@@ -299,11 +300,19 @@ class Folder:
# Write the set of sequences back to the folder
def putsequences(self, sequences):
fullname = self.getsequencesfilename()
- f = open(fullname, 'w')
+ f = None
for key in sequences.keys():
s = IntSet('', ' ')
s.fromlist(sequences[key])
+ if not f: f = open(fullname, 'w')
f.write('%s: %s\n' % (key, s.tostring()))
+ if not f:
+ try:
+ os.unlink(fullname)
+ except os.error:
+ pass
+ else:
+ f.close()
# Return the current message. Raise KeyError when there is none
def getcurrent(self):
@@ -313,7 +322,7 @@ class Folder:
def setcurrent(self, n):
updateline(self.getsequencesfilename(), 'cur', str(n), 0)
- # Open a message -- returns a mimetools.Message object
+ # Open a message -- returns a Message object
def openmessage(self, n):
path = self.getmessagefilename(n)
return Message(self, n)