From bccb089e3b8c380c0394e44fc59110a5eebbe4b3 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 17 Jul 2022 12:32:58 +0100 Subject: [PATCH] 2nd round getting info for NLnet for audit purposes --- README.txt | 4 ++++ src/budget_sync/main.py | 50 +++++++++++++++++++++++++++-------------- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/README.txt b/README.txt index cb29f29..3ce63ac 100644 --- a/README.txt +++ b/README.txt @@ -15,6 +15,10 @@ run as: nohup budget-sync -c budget-sync-config.toml -o mdwn +to create JSON output with comment #0 for each MoU task: + + nohup budget-sync -c budget-sync-config.toml -o mdwn --comments + then examine the nohup.out and also the individual markdown files, or compile to html first (after apt-get install python-markdown): diff --git a/src/budget_sync/main.py b/src/budget_sync/main.py index 12ce493..916dd7e 100644 --- a/src/budget_sync/main.py +++ b/src/budget_sync/main.py @@ -39,6 +39,8 @@ def main(): help="Log in with this Bugzilla username") parser.add_argument('--password', help="Log in with this Bugzilla password") + parser.add_argument('--comments', action='store_true', + help="Put JSON into comments") args = parser.parse_args() try: with args.config as config_file: @@ -67,7 +69,7 @@ def main(): write_budget_markdown(budget_graph, args.output_dir) write_budget_csv(budget_graph, args.output_dir) summarize_milestones(budget_graph) - json_milestones(budget_graph) + json_milestones(budget_graph, args.comments) def print_markdown_for_person(budget_graph: BudgetGraph, config: Config, @@ -134,7 +136,7 @@ def summarize_milestones(budget_graph: BudgetGraph): print ("```") # for using the output as markdown -def json_milestones(budget_graph): +def json_milestones(budget_graph, add_comments): """reports milestones as json format """ for milestone, payments in budget_graph.milestone_payments.items(): @@ -150,28 +152,41 @@ def json_milestones(budget_graph): 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() + for st in list(child.children()) + [child]: + amount = st.fixed_budget_excluding_subtasks.int() if amount == 0: # skip anything at zero continue - task = {'description': "%d %s" % (st.bug.id, st.bug.summary), - 'intro': [], + # if "task itself" then put the milestone as "wrapup" + if st.bug == child.bug: + description = 'wrapup' + intro = [] + else: + # otherwise create a description and get comment #0 + description = "%d %s" % (st.bug.id, st.bug.summary) + # add parent and MoU top-level + parent_id = st.parent.bug.id + if parent_id != child.bug.id: + description += "\n(Sub-sub-task of %d)" % parent_id + task = {'description': description, '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 + #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 + # create MoU task: get comment #0 + intro = [] + comment = "%s\n " % child.bug_url + if add_comments: + comments = child.bug.getcomments() + comment += "\n%s" % comments[0]['text'] + intro.append(comment) + print (description, intro) + sys.stdout.flush() task = {'title': "%d %s" % (child.bug.id, child.bug.summary), - 'intro': [], + 'intro': intro, 'amount': child.fixed_budget_including_subtasks.int(), - 'url': child.bug_url, + 'url': "{{ %s }} " % child.bug_url, 'milestones': milestones } tasks.append(task) @@ -179,6 +194,7 @@ def json_milestones(budget_graph): d = {'participants': ppl, 'preamble': '', 'type': 'Group', + 'url': canonical.bug_url, 'plan': { 'intro': [''], 'tasks': tasks, 'rfp_secret': '', -- 2.30.2