fedora-accounts bz-make-components.py,1.11,1.12

Toshio Ernie Kuratomi (toshio) fedora-extras-commits at redhat.com
Fri Mar 30 19:28:00 UTC 2007


Author: toshio

Update of /cvs/fedora/fedora-accounts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv7330

Modified Files:
	bz-make-components.py 
Log Message:
* bz-make-components.py: Reformat for consistent 4 spaces per indent level
  instead of mixed tabs, 2 & 4 spaces.



Index: bz-make-components.py
===================================================================
RCS file: /cvs/fedora/fedora-accounts/bz-make-components.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- bz-make-components.py	26 Feb 2007 20:24:51 -0000	1.11
+++ bz-make-components.py	30 Mar 2007 19:27:58 -0000	1.12
@@ -11,17 +11,18 @@
 GRANT_REGEXP = 2
 
 def get_bz_user_id(bzdbh, username):
-	bzdbc = bzdbh.cursor()
-	bzdbc.execute("SELECT userid FROM profiles WHERE login_name = %s", (username,))
-	if bzdbc.rowcount:
-		return bzdbc.fetchone()[0]
+    bzdbc = bzdbh.cursor()
+    bzdbc.execute("SELECT userid FROM profiles WHERE login_name = %s",
+            (username,))
+    if bzdbc.rowcount:
+        return bzdbc.fetchone()[0]
 
 opts, args = getopt.getopt(sys.argv[1:], '', ('usage', 'help'))
 if len(args) < 1 or ('--usage','') in opts or ('--help','') in opts:
-	print """
+    print """
 Usage: bz-make-components.py FILENAME...
 """
-	sys.exit(1)
+    sys.exit(1)
 
 bzdbh = website.get_dbh('bugs', 'bugs')
 bzdbc = bzdbh.cursor()
@@ -29,82 +30,84 @@
 bzdbh.commit()
 need_emails = {}
 for curfile in args:
-  if not os.path.exists(curfile):
-    continue
-  fh = open(curfile, 'r')
-  lnum = 0
-  while 1:
-    aline = fh.readline()
-    lnum += 1
-    if not aline: break
-    aline = aline.strip()
-    if not aline or aline[0] == '#': continue
-
-    pieces = aline.split('|')
-    try:
-	    product, component, description, owner, qa = pieces[:5]
-    except:
-	    print "Invalid line %s at %s:%s" % (aline, curfile, lnum)
-    cclist = []
-    owners = owner.split(',')
-    owner = owners[0]
-    if len(owners) > 1:
+    if not os.path.exists(curfile):
+        continue
+    fh = open(curfile, 'r')
+    lnum = 0
+    while 1:
+        aline = fh.readline()
+        lnum += 1
+        if not aline:
+            break
+        aline = aline.strip()
+        if not aline or aline[0] == '#':
+            continue
+
+        pieces = aline.split('|')
+        try:
+            product, component, description, owner, qa = pieces[:5]
+        except:
+            print "Invalid line %s at %s:%s" % (aline, curfile, lnum)
+        cclist = []
+        owners = owner.split(',')
+        owner = owners[0]
+        if len(owners) > 1:
             for I in owners[1:]:
-		    Inum = get_bz_user_id(bzdbh, I)
-		    if Inum is None:
-			if not need_emails.has_key(I):
-			    need_emails[I] = []
-			need_emails[I].append((product, component, curfile, lnum))
-			continue
-		    cclist.append(Inum)
-    owner_num = get_bz_user_id(bzdbh, owner)
-    qa_num = get_bz_user_id(bzdbh, qa)
-    if owner_num is None:
-	if not need_emails.has_key(owner):
-	    need_emails[owner] = []
-	need_emails[owner].append((product, component, curfile, lnum))
-#	    print "Invalid owner %s at %s:%s" % (owner, curfile, lnum)
-	continue
-    if len(pieces) > 5 and pieces[5]:
-	    for I in pieces[5].split(','):
-		    Inum = get_bz_user_id(bzdbh, I)
-		    if Inum is None:
-			if not need_emails.has_key(I):
-			    need_emails[I] = []
-			need_emails[I].append((product, component, curfile, lnum))
-			continue
-		    cclist.append(Inum)
-
-    if product[:len('Fedora ')] != 'Fedora ' or product == 'Fedora Core' or product == 'Fedora Legacy':
-	    print "Invalid product %s at %s:%s" % (product, curfile, lnum)
-	    continue
-
-    bzdbc.execute("SELECT id FROM products WHERE name = %s", (product,))
-    if not bzdbc.rowcount:
-	    bzdbc.execute("INSERT INTO products (name, description, disallownew, votesperuser, maxvotesperbug, votestoconfirm, defaultmilestone, depends) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", (product, product, 0, 0, 10000, 0, '---', 0))
-	    bzdbc.execute("SELECT id FROM products WHERE name = %s", (product,))
-	    product_id = bzdbc.fetchone()[0]
-	    bzdbc.execute("INSERT INTO versions (value, product_id) VALUES (%s, %s)", ("development", product_id))
-	    bzdbc.execute("INSERT INTO milestones (product_id, value, sortkey) VALUES (%s, '---', 0)", (product_id,))
-    else:
-	product_id = bzdbc.fetchone()[0]
-
-    bzdbc.execute("SELECT * FROM components WHERE product_id = %s AND name = %s", (product_id, component))
-    if bzdbc.rowcount:
-	    arow = bzdbc.fetchhash()
-	    bzdbc.execute("UPDATE components SET initialowner = %s, initialqacontact = %s, initialcclist = %s WHERE id = %s",
-			  (owner_num, qa_num, ':'.join(map(str,cclist)), arow['id']))
-    else:
-	    bzdbc.execute("INSERT INTO components (name, product_id, description, initialowner, initialqacontact, initialcclist) VALUES (%s, %s, %s, %s, %s, %s)",
-			  (component, product_id, description, owner_num, qa_num, ':'.join(map(str,cclist))))
+                Inum = get_bz_user_id(bzdbh, I)
+                if Inum is None:
+                    if not need_emails.has_key(I):
+                        need_emails[I] = []
+                    need_emails[I].append((product, component, curfile, lnum))
+                    continue
+                cclist.append(Inum)
+        owner_num = get_bz_user_id(bzdbh, owner)
+        qa_num = get_bz_user_id(bzdbh, qa)
+        if owner_num is None:
+            if not need_emails.has_key(owner):
+                need_emails[owner] = []
+            need_emails[owner].append((product, component, curfile, lnum))
+#            print "Invalid owner %s at %s:%s" % (owner, curfile, lnum)
+            continue
+        if len(pieces) > 5 and pieces[5]:
+            for I in pieces[5].split(','):
+                Inum = get_bz_user_id(bzdbh, I)
+                if Inum is None:
+                    if not need_emails.has_key(I):
+                        need_emails[I] = []
+                    need_emails[I].append((product, component, curfile, lnum))
+                    continue
+                cclist.append(Inum)
+
+        if product[:len('Fedora ')] != 'Fedora ' or product == 'Fedora Core' or product == 'Fedora Legacy':
+            print "Invalid product %s at %s:%s" % (product, curfile, lnum)
+            continue
+
+        bzdbc.execute("SELECT id FROM products WHERE name = %s", (product,))
+        if not bzdbc.rowcount:
+            bzdbc.execute("INSERT INTO products (name, description, disallownew, votesperuser, maxvotesperbug, votestoconfirm, defaultmilestone, depends) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", (product, product, 0, 0, 10000, 0, '---', 0))
+            bzdbc.execute("SELECT id FROM products WHERE name = %s", (product,))
+            product_id = bzdbc.fetchone()[0]
+            bzdbc.execute("INSERT INTO versions (value, product_id) VALUES (%s, %s)", ("development", product_id))
+            bzdbc.execute("INSERT INTO milestones (product_id, value, sortkey) VALUES (%s, '---', 0)", (product_id,))
+        else:
+            product_id = bzdbc.fetchone()[0]
+
+        bzdbc.execute("SELECT * FROM components WHERE product_id = %s AND name = %s", (product_id, component))
+        if bzdbc.rowcount:
+            arow = bzdbc.fetchhash()
+            bzdbc.execute("UPDATE components SET initialowner = %s, initialqacontact = %s, initialcclist = %s WHERE id = %s",
+                          (owner_num, qa_num, ':'.join(map(str,cclist)), arow['id']))
+        else:
+            bzdbc.execute("INSERT INTO components (name, product_id, description, initialowner, initialqacontact, initialcclist) VALUES (%s, %s, %s, %s, %s, %s)",
+                          (component, product_id, description, owner_num, qa_num, ':'.join(map(str,cclist))))
 bzdbh.commit()
 
 for I, J in need_emails.items():
-	if not I.strip():
-		print "Need an e-mail for", J
-		continue
-	print "Sending e-mail to", I
-	website.send_email("accounts at fedora.redhat.com", I, "You need to create a bugzilla account for %s" % I, """
+    if not I.strip():
+        print "Need an e-mail for", J
+        continue
+    print "Sending e-mail to", I
+    website.send_email("accounts at fedora.redhat.com", I, "You need to create a bugzilla account for %s" % I, """
 In order to make bugzilla components for Fedora-related programs, we need to have an existing bugzilla account for 
 the listed owner. You (%s) do not have a bugzilla account, but are listed as the owner for the following components:
 %s




More information about the fedora-extras-commits mailing list