diff options
author | Guido van Rossum <guido@python.org> | 2000-08-10 03:05:26 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-08-10 03:05:26 (GMT) |
commit | 0707fea5ee112da270a86b5a147f260d6c0e35ef (patch) | |
tree | f3cc0596edc6c1efa772c414a23ce3fab362dbb1 /Lib | |
parent | 65983372f0060de0a4d356fe62d47e1bfc3549ee (diff) | |
download | cpython-0707fea5ee112da270a86b5a147f260d6c0e35ef.zip cpython-0707fea5ee112da270a86b5a147f260d6c0e35ef.tar.gz cpython-0707fea5ee112da270a86b5a147f260d6c0e35ef.tar.bz2 |
Improve MHMailbox: messages are now sorted in numerical order.
Also don't allow leading zeros in message numbers.
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/mailbox.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py index b5a5692..afd9a55 100755 --- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -155,13 +155,18 @@ class MmdfMailbox(_Mailbox): class MHMailbox: def __init__(self, dirname): import re - pat = re.compile('^[0-9][0-9]*$') + pat = re.compile('^[1-9][0-9]*$') self.dirname = dirname files = os.listdir(self.dirname) - self.boxes = [] + list = [] for f in files: if pat.match(f): - self.boxes.append(f) + list.append(f) + list = map(long, list) + list.sort() + # This only works in Python 1.6 or later; + # before that str() added 'L': + self.boxes = map(str, list) def next(self): if not self.boxes: |