Update of /cvsroot/tmda/tmda/contrib
In directory sc8-pr-cvs1:/tmp/cvs-serv22867/contrib

Modified Files:
        ChangeLog collectaddys 
Log Message:
A faster implementation of collectaddys.  Using a list to
store the addresses means slow lookups when the number of
addresses is large.  A dictionary doesn't have this problem.


Index: ChangeLog
===================================================================
RCS file: /cvsroot/tmda/tmda/contrib/ChangeLog,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -r1.93 -r1.94
--- ChangeLog   18 Mar 2003 21:50:24 -0000      1.93
+++ ChangeLog   24 Mar 2003 19:45:15 -0000      1.94
@@ -1,3 +1,8 @@
+2003-03-24  Jason R. Mastaler  <[EMAIL PROTECTED]>
+
+       * collectaddys: Use a dictionary instead of a list to guarantee
+       uniqueness.
+       
 2003-03-18  Jason R. Mastaler  <[EMAIL PROTECTED]>
 
        * update-internaldomains: New script from Jesse Guardiani.

Index: collectaddys
===================================================================
RCS file: /cvsroot/tmda/tmda/contrib/collectaddys,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- collectaddys        12 Nov 2002 00:18:10 -0000      1.3
+++ collectaddys        24 Mar 2003 19:45:16 -0000      1.4
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright (C) 2001,2002 Jason R. Mastaler <[EMAIL PROTECTED]>
+# Copyright (C) 2001,2002,2003 Jason R. Mastaler <[EMAIL PROTECTED]>
 #
 # This file is part of TMDA.
 #
@@ -22,8 +22,7 @@
 """
 Collect e-mail addresses from mailboxes of various formats.
 Unix-style mbox files, qmail-style Maildirs, and MH/nmh-style folders
-are supported.  Each unique address is printed to stdout in lowercase,
-with the results sorted.
+are supported.  Each unique address is printed to stdout in lowercase.
 
 Every file or directory within the current working directory is
 assumed to be in one of the supported mailbox formats.
@@ -40,7 +39,7 @@
 # Collect addresses from these headers only; season to taste.
 hdrs = [ 'from', 'return-path', 'sender' ]
 
-addys = []
+uniq = {}
 
 for path in os.listdir('.'):
     # If it's a directory, try to guess whether it's a Maildir or an
@@ -65,11 +64,8 @@
                     address = msg.getaddr(hdr)[1]
                     if address is not None:
                         address = address.lower()
-                        if address not in addys:
-                            addys.append(address)
+                        uniq[address] = address
                     
-addys.sort()
-
-for a in addys:
+for a in uniq.keys():
     if a:
         print a

_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs

Reply via email to