]> granicus.if.org Git - python/commitdiff
Improve MHMailbox: messages are now sorted in numerical order.
authorGuido van Rossum <guido@python.org>
Thu, 10 Aug 2000 03:05:26 +0000 (03:05 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 10 Aug 2000 03:05:26 +0000 (03:05 +0000)
Also don't allow leading zeros in message numbers.

Lib/mailbox.py

index b5a5692b23e50e7d70676330838335a94595bac1..afd9a55760007fd70c901a44cceb74c1dc025eae 100755 (executable)
@@ -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: