mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
Improve MHMailbox: messages are now sorted in numerical order.
Also don't allow leading zeros in message numbers.
This commit is contained in:
parent
65983372f0
commit
0707fea5ee
1 changed files with 8 additions and 3 deletions
|
@ -155,13 +155,18 @@ class MmdfMailbox(_Mailbox):
|
||||||
class MHMailbox:
|
class MHMailbox:
|
||||||
def __init__(self, dirname):
|
def __init__(self, dirname):
|
||||||
import re
|
import re
|
||||||
pat = re.compile('^[0-9][0-9]*$')
|
pat = re.compile('^[1-9][0-9]*$')
|
||||||
self.dirname = dirname
|
self.dirname = dirname
|
||||||
files = os.listdir(self.dirname)
|
files = os.listdir(self.dirname)
|
||||||
self.boxes = []
|
list = []
|
||||||
for f in files:
|
for f in files:
|
||||||
if pat.match(f):
|
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):
|
def next(self):
|
||||||
if not self.boxes:
|
if not self.boxes:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue