from budget_sync.write_budget_markdown import write_budget_markdown
from collections import OrderedDict
-# Write an array of dictionaries to the CSV file name
+
def write_csv(name, items, headers):
+ """ Write an array of dictionaries to the CSV file name """
with open(name, 'w') as csvfile:
writer = csv.DictWriter(csvfile, headers, lineterminator="\n")
writer.writeheader()
writer.writerows(items)
+
mdwn_csv_template = """\
# %s
* [%s](%s)
"""
+
def main():
parser = argparse.ArgumentParser(
description="Check for errors in "
# quick hack to display total payment amounts per-milestone
for milestone, payments in budget_graph.milestone_payments.items():
- print (milestone)
+ print(milestone)
total = 0
total_requested = 0
total_req_or_paid = 0
if payment.submitted or payment.paid is not None:
total_req_or_paid += payment.amount
- print ("\t %-9s" % total,
- "submitted %-9s" % total_requested,
- "paid %-9s" % total_paid,
- "submitted or paid %-9s" % total_req_or_paid)
- print ()
+ print("\t %-9s" % total,
+ "submitted %-9s" % total_requested,
+ "paid %-9s" % total_paid,
+ "submitted or paid %-9s" % total_req_or_paid)
+ print()
# and one to display peole
milestones_people = budget_graph.get_milestone_people()
for milestone, people in milestones_people.items():
- print (milestone)
+ print(milestone)
for person in people:
print("\t", person)
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
row[name+"_req"] = requested
row[name+"_paid"] = paid
- print (row)
+ print(row)
milestone_csvs[milestone][payment.node.bug.id] = row
if args.output_dir is not None:
with open("%s/csvs.mdwn" % args.output_dir, "w") as f:
# write out the people pages
# TODO, has to be done by the markdown page name
- #f.write("# People\n\n")
- #for name, person in all_people.items():
+ # f.write("# People\n\n")
+ # for name, person in all_people.items():
# fname = "%s/%s" % (args.output_dir, name)
# f.write(mdwn_people_template % (person, fname))
# and the CSV files
ident = milestone.identifier
header = milestone_headings[milestone]
fname = "%s/%s.csv" % (args.output_dir, ident)
- rows = rows.values() # turn into list
+ rows = rows.values() # turn into list
write_csv(fname, rows, header)
f.write(mdwn_csv_template % (ident, fname))
+
if __name__ == "__main__":
main()