all_people = OrderedDict()
# pre-initialise the CSV lists (to avoid overwrite)
for milestone, payments in budget_graph.milestone_payments.items():
- milestone_csvs[milestone] = [] # rows in the CSV file
+ milestone_csvs[milestone] = {} # rows in the CSV file
for milestone, payments in budget_graph.milestone_payments.items():
# first get the list of people, then create some columns
people = milestones_people[milestone]
- headings = []
+ headings = ['bug_id']
for person in people:
name = str(person).replace(" ", "_")
all_people[person] = person
headings.append(name+"_paid")
milestone_headings[milestone] = headings
# now we go through the whole "payments" thing again...
- row = {}
for payment in payments:
+ row = milestone_csvs[milestone].get(payment.node.id, None)
+ if row is None:
+ row = {'bug_id': payment.node.id}
+
name = str(payment.payee.identifier).replace(" ", "_")
row[name+"_amount"] = str(payment.amount)
if payment.submitted is not None:
paid = ""
row[name+"_req"] = requested
row[name+"_paid"] = paid
+
print (row)
- milestone_csvs[milestone].append(row)
+ milestone_csvs[milestone][payment.node.id] = row
if args.output_dir is not None:
with open("%s/csvs.mdwn" % args.output_dir, "w") as f:
ident = milestone.identifier
header = milestone_headings[milestone]
fname = "%s/%s.csv" % (args.output_dir, ident)
+ rows = rows.values() # turn into list
write_csv(fname, rows, header)
f.write(mdwn_csv_template % (ident, fname))