diff options
author | Guido van Rossum <guido@python.org> | 1994-09-09 11:10:15 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1994-09-09 11:10:15 +0000 |
commit | 57b29e6b4c32e5dadcadedd839bbf962713fcba9 (patch) | |
tree | 0344fafd299324e198f993732a7b5e1308e5834f /Lib/mhlib.py | |
parent | 5f917d8bd079611b59ce737f9f1753db43368906 (diff) | |
download | cpython-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.py | 13 |
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) |