use <pre> not <tt>
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 6 Dec 2023 18:46:16 +0000 (18:46 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 6 Dec 2023 18:46:16 +0000 (18:46 +0000)
src/budget_sync/main.py

index d2828fba0379b03d6ef545ff012582987693f051..5baa1c37855617c79740e2f502fa58c5873ab3b5 100644 (file)
@@ -18,6 +18,7 @@ from budget_sync.write_budget_markdown import (write_budget_markdown,
 def spc(s):
     return s.replace(" ", "&nbsp;")
 
+bugurl = "https://bugs.libre-soc.org/show_bug.cgi?bug="
 
 def main():
     parser = argparse.ArgumentParser(
@@ -59,7 +60,7 @@ def main():
     reportdir = "/".join(reportdir.split("/")[:-1]) # strip /mdwn
     reportname = reportdir + "/report.mdwn"
     with open(reportname, "w") as f:
-        print("<tt>", file=f)  # for using the output as markdown
+        print("<pre>", file=f)  # for using the output as markdown
         bz = Bugzilla(config.bugzilla_url)
         if args.username:
             logging.debug("logging in...")
@@ -79,7 +80,7 @@ def main():
             write_budget_markdown(budget_graph, args.output_dir)
             write_budget_csv(budget_graph, args.output_dir)
         summarize_milestones(f, budget_graph, detail=args.detail)
-        print("</tt>", file=f)  # for using the output as markdown
+        print("</pre>", file=f)  # for using the output as markdown
     # now create the JSON milestone files for putting into NLnet RFP system
     json_milestones(budget_graph, args.comments, args.output_dir)
 
@@ -124,14 +125,16 @@ def print_budget_then_children(f, indent, nodes, bug_id, detail=False):
     excl_desc = "               "
     if b_incl != b_excl:
         excl_desc = "excltasks %6s" % b_excl
-    print(spc("bug #%5d %s budget %6s %s %s<br>" %
-              (bug.bug.id, ' |   ' * indent,
+    bugid = spc("%5d" % bug.bug.id)
+    buglink = "<a href='%s%d'>%s</a>" % (bugurl, bug.bug.id, bugid)
+    print(spc("bug #URL %s budget %6s %s %s" %
+              (' |   ' * indent,
                b_incl,
                excl_desc,
                descr
-               )), file=f)
+               )).replace("URL", buglink), file=f)
     if detail:
-        print(spc("           %s |        (%s)<br>" %
+        print(spc("           %s |        (%s)" %
                   (' |   ' * indent,
                    bug.bug.summary[:40]
                   )), file=f)
@@ -147,28 +150,28 @@ def print_budget_then_children(f, indent, nodes, bug_id, detail=False):
 def summarize_milestones(f, budget_graph, detail=False):
     for milestone, payments in budget_graph.milestone_payments.items():
         summary = PaymentSummary(payments)
-        print(f"{milestone.identifier}<br>", file=f)
+        print(f"{milestone.identifier}", file=f)
         print(f"    {summary.total} submitted: "
-              f"{summary.total_submitted} paid: {summary.total_paid}<br>",
+              f"{summary.total_submitted} paid: {summary.total_paid}",
               file=f)
         not_submitted = summary.get_not_submitted()
         if not_submitted:
-            print("not submitted %s<br>" % not_submitted, file=f)
+            print("not submitted %s" % not_submitted, file=f)
 
         # and one to display people
         for person in budget_graph.milestone_people[milestone]:
-            print(spc("    %-30s - %s<br>" % (person.identifier,
+            print(spc("    %-30s - %s" % (person.identifier,
                                             person.full_name)),
                   file=f)
-        print("<br>", file=f)
+        print("", file=f)
 
     # now do trees
     for milestone, payments in budget_graph.milestone_payments.items():
-        print("%s %d<br>" % (milestone.identifier, milestone.canonical_bug_id),
+        print("%s %d" % (milestone.identifier, milestone.canonical_bug_id),
               file=f)
         print_budget_then_children(f, 0, budget_graph.nodes,
                                    milestone.canonical_bug_id, detail)
-        print("<br>", file=f)
+        print("", file=f)
 
 
 def json_milestones(budget_graph: BudgetGraph, add_comments: bool,