Add -i flag
authorRich Salz <rsalz@openssl.org>
Fri, 16 Jun 2017 15:14:22 +0000 (11:14 -0400)
committerRich Salz <rsalz@openssl.org>
Fri, 16 Jun 2017 15:14:47 +0000 (11:14 -0400)
license/whattoremove

index 632ba4bfa28d2c88d044cfbe3f7f5ed881b100f0..3fc47f0c60a4bdd7ba4113ba88c04519a881773f 100755 (executable)
@@ -1,10 +1,31 @@
 #! /usr/bin/env python
-"""Takes no arguments.  Outputs CSV of what commits people who rejected
-the license were involved in.
+"""whattoremove [arguments]
+
+Flags:
+    -i file     File of commits to include
+    -h          This help
+
+Outputs CSV list of the commits that people who rejected
+the license were involved in.  The exclude file can be
+generated by a command like this:
+    git log --pretty=fomat:%h
 """
 
 import mysql.connector
 import datetime, os, re, subprocess, sys, string, random
+import getopt
+
+# Parse JCL
+include = None
+opts, args = getopt.getopt(sys.argv[1:], "hi:")
+for o,a in opts:
+    if o == '-i':
+        f = open(a)
+        include = [ c.strip() for c in f ]
+        f.close()
+    else:
+        print __doc__
+        raise SystemExit
 
 dbconfig = {
         'user': 'licensereader',
@@ -13,7 +34,6 @@ dbconfig = {
         }
 conn = mysql.connector.connect(**dbconfig)
 cursor = conn.cursor()
-raw = open("request-approval.txt").read()
 
 # Get those who said no and all the commits the did
 q = ( 'SELECT log.cid,users.email FROM log'
@@ -32,4 +52,7 @@ for cid in cids:
     cursor.execute(q, (cid,))
     for row in cursor:
         commit,date,descrip = row
-        print '%s, %s, "%s"' % (commit[0:7], emails[cid], descrip)
+        commit = commit[0:7]
+        descrip = descrip.replace('"', '\'')
+        if include == None or commit in include:
+            print '%s, %s, "%s"' % (commit, emails[cid], descrip)