From: Jacob Lifshay Date: Tue, 30 Aug 2022 03:52:53 +0000 (-0700) Subject: write json to specified output dir instead of current directory X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9f71c115b6d9ac7cd9653fd4ab51079734f83bdd;p=utils.git write json to specified output dir instead of current directory --- diff --git a/src/budget_sync/main.py b/src/budget_sync/main.py index d2674b5..cdcc82e 100644 --- a/src/budget_sync/main.py +++ b/src/budget_sync/main.py @@ -69,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, args.comments) + json_milestones(budget_graph, args.comments, args.output_dir) def print_markdown_for_person(budget_graph: BudgetGraph, config: Config, @@ -136,7 +136,8 @@ def summarize_milestones(budget_graph: BudgetGraph): print ("```") # for using the output as markdown -def json_milestones(budget_graph, add_comments): +def json_milestones(budget_graph: BudgetGraph, add_comments: bool, + output_dir: Path): """reports milestones as json format """ for milestone, payments in budget_graph.milestone_payments.items(): @@ -181,8 +182,8 @@ def json_milestones(budget_graph, add_comments): comments = child.bug.getcomments() comment += "\n%s" % comments[0]['text'] intro.append(comment) - #print (description, intro) - sys.stdout.flush() + # print (description, intro) + # sys.stdout.flush() task = {'title': "%d %s" % (child.bug.id, child.bug.summary), 'intro': intro, 'amount': child.fixed_budget_including_subtasks.int(), @@ -201,8 +202,8 @@ def json_milestones(budget_graph, add_comments): } } - with open("report.%s.json" % milestone.identifier, "w") as f: - json.dump(d, f, indent=2) + output_file = output_dir / f"report.{milestone.identifier}.json" + output_file.write_text(json.dumps(d, indent=2), encoding="utf-8")