Hello, this issue is sadly still a problem.
For those who may hit the same troublesome spot, I'm attaching the script I'm using as a replacement, which is a lot less flexible (or one could say, has a lot of hardcodable flexibility), but has a very low memory footprint Enrico -- GPG key: 4096R/634F4BD1E7AD5568 2009-05-08 Enrico Zini <[email protected]>
#!/usr/bin/python3
import argparse
from collections import defaultdict
import datetime
import mailbox
import sys
def main():
today = datetime.date.today()
this_month = today.replace(day=1)
parser = argparse.ArgumentParser(description="Make monthly archives of
maildir contents")
parser.add_argument("--until", action="store",
default=this_month.strftime("%Y-%m"),
help="stop archiving before this month")
parser.add_argument("maildir", action="store", help="maildir to archive")
args = parser.parse_args()
until = datetime.datetime.strptime(args.until, "%Y-%m").date()
src = mailbox.Maildir(args.maildir)
by_month = defaultdict(list)
for key in src.keys():
dt = datetime.datetime.fromtimestamp(int(key.split('.')[0])).date()
if dt >= until:
continue
by_month[dt.strftime("%Y-%m")].append(key)
for month, keys in sorted(by_month.items()):
dst = mailbox.mbox(args.maildir + "-" + month)
try:
dst.lock()
for key in keys:
email = src[key]
dst.add(email)
finally:
dst.flush()
dst.unlock()
dst.close()
for key in keys:
del src[key]
print(month, len(keys))
return
if __name__ == "__main__":
sys.exit(main())
signature.asc
Description: PGP signature

