import os
import re
import sys
+import json
from typing import Optional
from budget_sync.ordered_set import OrderedSet
from budget_sync.write_budget_csv import write_budget_csv
write_budget_markdown(budget_graph, args.output_dir)
write_budget_csv(budget_graph, args.output_dir)
summarize_milestones(budget_graph)
+ json_milestones(budget_graph)
def print_markdown_for_person(budget_graph: BudgetGraph, config: Config,
print ("```") # for using the output as markdown
+def json_milestones(budget_graph):
+ """reports milestones as json format
+ """
+ for milestone, payments in budget_graph.milestone_payments.items():
+ summary = PaymentSummary(payments)
+ # and one to display people
+ ppl = []
+ for person in budget_graph.milestone_people[milestone]:
+ p = {'name': person.full_name, 'email': person.email}
+ ppl.append(p)
+
+ tasks = []
+ canonical = budget_graph.nodes[milestone.canonical_bug_id]
+ for child in canonical.immediate_children:
+ milestones = []
+ # include the task itself as a milestone
+ for st in [child] + list(child.children()):
+ amount = st.fixed_budget_including_subtasks.int()
+ if amount == 0: # skip anything at zero
+ continue
+ task = {'description': "%d %s" % (st.bug.id, st.bug.summary),
+ 'intro': [],
+ 'amount': amount,
+ 'url': st.bug_url,
+ }
+ # add parent and MoU top-level
+ parent_id = st.parent.bug.id,
+ if parent_id != milestone.canonical_bug_id:
+ task['parent'] = parent_id
+ mou_bug = st.closest_bug_in_mou
+ if mou_bug is not None:
+ task['mou_task'] = mou_bug.bug.id
+ milestones.append(task)
+ # create MoU task
+ task = {'title': "%d %s" % (child.bug.id, child.bug.summary),
+ 'intro': [],
+ 'amount': child.fixed_budget_including_subtasks.int(),
+ 'url': child.bug_url,
+ 'milestones': milestones
+ }
+ tasks.append(task)
+
+ d = {'participants': ppl,
+ 'preamble': '',
+ 'type': 'Group',
+ 'plan': { 'intro': [''],
+ 'tasks': tasks,
+ 'rfp_secret': '',
+ }
+ }
+
+ with open("report.%s.json" % milestone.identifier, "w") as f:
+ json.dump(d, f, indent=2)
+
+
+
if __name__ == "__main__":
main()