Re: mbox2txt subject sorting patch
* Brian Nelson <pyro@debian.org> [2004-07-19 15:12]:
> I noticed that the subject sorting in the mbox2txt script does not
> ignore the leading "Re: " in the subject of replies, which makes the
> sort pretty useless. Here's a quick patch I made to fix it.
Thans, I've commited something like this.
Index: mbox2txt
===================================================================
RCS file: /cvsroot/nm-templates/templates/mbox2txt,v
retrieving revision 1.2
diff -u -r1.2 mbox2txt
--- mbox2txt 10 Feb 2004 20:07:59 -0000 1.2
+++ mbox2txt 12 Aug 2004 17:56:31 -0000
@@ -24,7 +24,7 @@
import email
import email.Errors
import mailbox
-import sys
+import re, sys
from email.Utils import parsedate_tz, mktime_tz
@@ -55,9 +55,12 @@
mb = open(filename)
mbox = mailbox.UnixMailbox(mb, email.message_from_file)
+ def strip_re(subject):
+ return re.sub("^Re:\s*", "", subject)
+
def sort_mails(a, b):
# Sort by Subject: as well
- #ret = cmp(a['subject'], b['subject'])
+ #ret = cmp(strip_re(a['subject']), strip_re(b['subject']))
#if ret: return ret
a_time = mktime_tz(parsedate_tz(a['date']))
--
Martin Michlmayr
tbm@cyrius.com
Reply to: