r12558 - software/list-inactive-members

Evgeni Golov evgeni at alioth.debian.org
Mon Jul 25 21:06:10 UTC 2011


Author: evgeni
Date: 2011-07-25 21:06:09 +0000 (Mon, 25 Jul 2011)
New Revision: 12558

Modified:
   software/list-inactive-members/get-members.py
Log:
add mail archive search feature

Modified: software/list-inactive-members/get-members.py
===================================================================
--- software/list-inactive-members/get-members.py	2011-07-25 20:33:53 UTC (rev 12557)
+++ software/list-inactive-members/get-members.py	2011-07-25 21:06:09 UTC (rev 12558)
@@ -8,9 +8,15 @@
 from lxml.html import fromstring
 import re
 import sys
+import os
+import glob
+import mailbox
+from email.utils import parsedate_tz, mktime_tz
+from datetime import datetime
+
 enc = sys.stdout.encoding or 'ascii'
 
-def get_members(teamurl, svn_file, git_file, since, only_inactive=True):
+def get_members(teamurl, svn_file, git_file, mail_dir, since, only_inactive=True):
     userinfo = {}
     html = urllib2.urlopen(URL).read()
     html = fromstring(html)
@@ -26,6 +32,7 @@
             userinfo[user]['user'] = user
             userinfo[user]['svn'] = '1970-01-01'
             userinfo[user]['git'] = '1970-01-01'
+            userinfo[user]['mail'] = '1970-01-01'
 
     svnfile = open(svn_file)
     svncommits = []
@@ -50,6 +57,16 @@
         commit['email'] = line.split('::')[2].lower()
         gitcommits.append(commit)
 
+    mails = []
+    for mboxf in glob.glob(os.path.join(mail_dir, '*')):
+        box = mailbox.mbox(mboxf)
+        for m in box:
+            mail = {}
+            d = datetime.fromtimestamp(mktime_tz(parsedate_tz(m.get('Date'))))
+            mail['date'] = d.strftime("%Y-%m-%d")
+            mail['from'] = m.get('From')
+            mails.append(mail)
+
     for user in userinfo:
         for commit in svncommits:
             if commit['user'] == user:
@@ -59,16 +76,20 @@
             if commit['email'].find(user.replace('-guest','')) != -1 or commit['name'] == userinfo[user]['name'].lower():
                 if userinfo[user]['git'] < commit['date']:
                     userinfo[user]['git'] = commit['date']
+        for mail in mails:
+            if mail['from'].lower().find(user.replace('-guest','')) != -1 or mail['from'].lower().find(userinfo[user]['name'].lower()) != -1:
+                if userinfo[user]['mail'] < mail['date']:
+                    userinfo[user]['mail'] = mail['date']
 
     for user in userinfo:
-        if not only_inactive or (userinfo[user]['svn'] < LIMIT and userinfo[user]['git'] < LIMIT):
+        if not only_inactive or (userinfo[user]['svn'] < LIMIT and userinfo[user]['git'] < LIMIT and userinfo[user]['mail'] < LIMIT):
             s = "%(name)s <%(user)s at alioth.debian.org>" % userinfo[user]
             print s.encode(enc, 'replace')
 
 if __name__ == '__main__':
-    if len(sys.argv) != 3:
+    if len(sys.argv) != 4:
         print "You have to call:"
-        print "%s <svn-commits-file> <git-commits-file>" % sys.argv[0]
+        print "%s <svn-commits-file> <git-commits-file> <mail-archive-dir>" % sys.argv[0]
         sys.exit(1)
 
-    get_members(URL, sys.argv[1], sys.argv[2], LIMIT)
+    get_members(URL, sys.argv[1], sys.argv[2], sys.argv[3], LIMIT)




More information about the Pkg-games-commits mailing list