http://scons.tigris.org/issues/show_bug.cgi?id=2345
[scons.git] / bin / xmlagenda.py
1 #!/usr/bin/env python
2
3 # Download the issues from Issuzilla as XML; this creates a file named
4 # 'issues.xml'.  Run this script to translate 'issues.xml' into a CSV
5 # file named 'editlist.csv'.  Upload the CSV into a Google spreadsheet.
6
7 # In the spreadsheet, select the last column and pick "delete-->column" (it
8 # was added by the upload to allow for expansion and we don't need it).
9 # Select all the columns and pick "align-->top"
10 # Select the ID and votes columns and pick "align-->right"
11 # Select the priority column and pick "align-->center"
12 # Select the first row and click on the "bold" button
13 # Grab the lines between the column headers to adjust the column widths
14 # Grab the sort bar on the far left (just above the "1" for row one)
15 # and move it down one row.  (Row one becomes a floating header)
16 # Voila!
17
18 # The team members
19 # FIXME: These names really should be external to this script
20 team = sorted('Steven Gary Greg Ken Jim David Bill Sergey Jason'.split())
21
22 # The elements to be picked out of the issue
23 PickList = [
24     # sort key -- these are used to sort the entry
25     'target_milestone', 'priority', 'votes_desc', 'creation_ts',
26     # payload -- these are displayed
27     'issue_id', 'votes', 'issue_type', 'target_milestone',
28     'priority', 'assigned_to', 'short_desc',
29     ]
30
31 # Conbert a leaf element into its value as a text string
32 # We assume it's "short enough" that there's only one substring
33 def Value(element):
34     v = element.firstChild
35     if v is None: return ''
36     return v.nodeValue
37
38 # Parse the XML issues file and produce a DOM for it
39 import sys
40 if len(sys.argv) > 1: xml = sys.argv[1]
41 else: xml = 'issues.xml'
42 from xml.dom.minidom import parse
43 xml = parse(xml)
44
45 # Go through the issues in the DOM, pick out the elements we want,
46 # and put them in our list of issues.
47 issues = []
48 for issuezilla in xml.childNodes:
49     # The Issuezilla element contains the issues
50     if issuezilla.nodeType != issuezilla.ELEMENT_NODE: continue
51     for issue in issuezilla.childNodes:
52         # The issue elements contain the info for an issue
53         if issue.nodeType != issue.ELEMENT_NODE: continue
54         # Accumulate the pieces we want to include
55         d = {}
56         for element in issue.childNodes:
57             if element.nodeName in PickList:
58                 d[element.nodeName] = Value(element)
59         # convert 'votes' to numeric, ascending and descending
60         try:
61             v = int('0' + d['votes'])
62         except KeyError:
63             pass
64         else:
65             d['votes_desc'] = -v
66             d['votes'] = v
67         # Marshal the elements and add them to the list
68         issues.append([ d[ix] for ix in PickList ])
69 issues.sort()
70
71 # Transcribe the issues into comma-separated values.
72 # FIXME: parameterize the output file name
73 import csv
74 writer = csv.writer(open('editlist.csv', 'w'))
75 # header
76 writer.writerow(['ID', 'Votes', 'Type/Member', 'Milestone',
77         'Pri', 'Owner', 'Summary/Comments'])
78 for issue in issues:
79     row = issue[4:]        # strip off sort key
80     #row[0] = """=hyperlink("http://scons.tigris.org/issues/show_bug.cgi?id=%s","%s")""" % (row[0],row[0])
81     if row[3] == '-unspecified-': row[3] = 'triage'
82     writer.writerow(['','','','','','',''])
83     writer.writerow(row)
84     writer.writerow(['','','consensus','','','',''])
85     writer.writerow(['','','','','','',''])
86     for member in team: writer.writerow(['','',member,'','','',''])
87
88 # Local Variables:
89 # tab-width:4
90 # indent-tabs-mode:nil
91 # End:
92 # vim: set expandtab tabstop=4 shiftwidth=4: