[Popcon-commits] cvs commit to popularity-contest by pere

popcon-commits@lists.alioth.debian.org popcon-commits@lists.alioth.debian.org
Sun, 01 Feb 2004 17:46:43 +0100


Update of /cvsroot/popcon/popularity-contest
In directory quantz:/tmp/cvs-serv6837

Modified Files:
	prepop.py 
Log Message:
Add some sanity check of md5sum and entries without the
'END-POPULARITY-CONTEST-0' marker.


Index: prepop.py
===================================================================
RCS file: /cvsroot/popcon/popularity-contest/prepop.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- prepop.py	7 Sep 2003 17:27:27 -0000	1.1.1.1
+++ prepop.py	1 Feb 2004 16:46:40 -0000	1.2
@@ -5,13 +5,16 @@
 # Only the most recent entry with a given MD5 ID is kept.
 #
 
-import sys, string, os, time
+import sys, string, os, time, re
 
 dirname = 'popcon-entries'
 output = None
 
 now = time.time()
 
+msgstartre = re.compile("^From")
+md5sumre   = re.compile("^([a-f0-9]{32})$")
+
 while 1:
     line = sys.stdin.readline()
     if not line: break
@@ -31,7 +34,7 @@
 		key, value = list
 	    except:
 		continue
-	    if key == 'ID' and len(value) > 2:
+	    if key == 'ID' and md5sumre.match(value):
 		md5 = value
 		subdir = dirname + '/' + value[0:2]
 		try:
@@ -48,7 +51,7 @@
 		
 	
 
-    elif split[0] == 'END-POPULARITY-CONTEST-0':
+    elif split[0] == 'END-POPULARITY-CONTEST-0' or msgstartre.match(split[0]):
 	if output != None:
 	    print "%s: %s" % (md5, time.ctime(mtime))
 	    output.write(line)