2nd round getting info for NLnet for audit purposes
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 17 Jul 2022 11:32:58 +0000 (12:32 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 17 Jul 2022 11:32:58 +0000 (12:32 +0100)
README.txt
src/budget_sync/main.py

index cb29f299dd56ca02d51570404a5b24db4d5fe529..3ce63ac9dcb0c1f60ca331e16c95bb04dcd8246d 100644 (file)
@@ -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):
 
index 12ce493cfac90a0b9eebba9ca4d0d6d5e58e9592..916dd7e9f608d24f4c9d4839ea667e62e9d64a57 100644 (file)
@@ -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': '',