From ef6afbf35ef65522e273e1056e87f3202cc87bd1 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 4 Dec 2023 16:45:55 +0000 Subject: [PATCH] bug#1171: output report.mdwn to output_dir, default to ./report.mdwn" --- src/budget_sync/main.py | 49 +++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/budget_sync/main.py b/src/budget_sync/main.py index 96e0f27..d646556 100644 --- a/src/budget_sync/main.py +++ b/src/budget_sync/main.py @@ -49,28 +49,33 @@ def main(): logging.error("Failed to parse config file: %s", e) return logging.info("Using Bugzilla instance at %s", config.bugzilla_url) - f = open("/tmp/report.mdwn", "w") - print("```", file=f) # for using the output as markdown - bz = Bugzilla(config.bugzilla_url) - if args.username: - logging.debug("logging in...") - bz.interactive_login(args.username, args.password) - logging.debug("Connected to Bugzilla") - budget_graph = BudgetGraph(all_bugs(bz), config) - for error in budget_graph.get_errors(): - logging.error("%s", error) - if args.person or args.subset: - if not args.person: - logging.fatal("must use --subset-person with --subset option") - sys.exit(1) - print_markdown_for_person(f, budget_graph, config, - args.person, args.subset) - return - if args.output_dir is not None: - write_budget_markdown(budget_graph, args.output_dir) - write_budget_csv(budget_graph, args.output_dir) - summarize_milestones(f, budget_graph) - print("```", file=f) # for using the output as markdown + # download all bugs and create a summary report + reportdir = "./" if args.output_dir is None else str(args.output_dir) + reportdir = "/".join(reportdir.split("/")[:-1]) # strip /mdwn + reportname = reportdir + "/report.mdwn" + with open(reportname, "w") as f: + print("```", file=f) # for using the output as markdown + bz = Bugzilla(config.bugzilla_url) + if args.username: + logging.debug("logging in...") + bz.interactive_login(args.username, args.password) + logging.debug("Connected to Bugzilla") + budget_graph = BudgetGraph(all_bugs(bz), config) + for error in budget_graph.get_errors(): + logging.error("%s", error) + if args.person or args.subset: + if not args.person: + logging.fatal("must use --subset-person with --subset option") + sys.exit(1) + print_markdown_for_person(f, budget_graph, config, + args.person, args.subset) + return + if args.output_dir is not None: + write_budget_markdown(budget_graph, args.output_dir) + write_budget_csv(budget_graph, args.output_dir) + summarize_milestones(f, budget_graph) + print("```", 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) -- 2.30.2