From 43dc04b6fe09c4fa1d5da75afb2c3a0e2ed24303 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 16 Jun 2022 15:00:24 +0100 Subject: [PATCH] add recursive tree-print of budgets --- src/budget_sync/main.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/budget_sync/main.py b/src/budget_sync/main.py index c8929af..6d587a2 100644 --- a/src/budget_sync/main.py +++ b/src/budget_sync/main.py @@ -4,6 +4,7 @@ from bugzilla import Bugzilla import logging import argparse from pathlib import Path +from budget_sync.money import Money from budget_sync.util import all_bugs from budget_sync.config import Config, ConfigParseError, Milestone from budget_sync.budget_graph import BudgetGraph, BudgetGraphBaseError, PaymentSummary @@ -47,6 +48,23 @@ def main(): summarize_milestones(budget_graph) +def print_budget_then_children(indent, nodes, bug_id): + """recursive indented printout of budgets + """ + + bug = nodes[bug_id] + print("bug #%5d %s budget %7s excltasks %7s" % \ + (bug.bug.id, ' ' * (indent*4), + str(bug.budget_including_subtasks), + str(bug.budget_excluding_subtasks))) + #print (repr(bug)) + for child in bug.immediate_children: + if (str(child.budget_including_subtasks) == "0" and + str(child.budget_excluding_subtasks) == "0"): + continue + print_budget_then_children(indent+1, nodes, child.bug.id) + + def summarize_milestones(budget_graph: BudgetGraph): for milestone, payments in budget_graph.milestone_payments.items(): summary = PaymentSummary(payments) @@ -59,6 +77,12 @@ def summarize_milestones(budget_graph: BudgetGraph): print(f"\t{person.identifier}") print() + # now do trees + for milestone, payments in budget_graph.milestone_payments.items(): + print("%s %d" % (milestone.identifier, milestone.canonical_bug_id)) + print_budget_then_children(0, budget_graph.nodes, + milestone.canonical_bug_id) + print() if __name__ == "__main__": main() -- 2.30.2