From a6dc4d658fd259b935af129d6d5bf759fb9aa87f Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Sat, 15 Jan 2022 17:59:00 +0200 Subject: [PATCH] feat(devtools): collect history --- apps/tools/librelingo_tools/generate.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/apps/tools/librelingo_tools/generate.py b/apps/tools/librelingo_tools/generate.py index b2a12ed78ae0..d3773721da70 100755 --- a/apps/tools/librelingo_tools/generate.py +++ b/apps/tools/librelingo_tools/generate.py @@ -13,8 +13,15 @@ import lili +def myconverter(o): + if isinstance(o, datetime.datetime): + return o.__str__() + return None + + def get_args(): parser = argparse.ArgumentParser() + parser.add_argument("--history", help="path to history.json file") parser.add_argument("--outdir", required=True, help="path to output directory") parser.add_argument("--courses", required=True, help="path to courses.json file") parser.add_argument("--log", action="store_true", help="Additional logging") @@ -127,6 +134,16 @@ def main(): end_time = datetime.datetime.now() with open(os.path.join(outdir, "courses.json"), "w") as fh: json.dump(courses_data, fh, sort_keys=True) + if args.history: + with open(args.history, "a") as fh: + json.dump( + {"courses": courses_data, "date": start_time}, + fh, + sort_keys=True, + default=myconverter, + ) + fh.write("\n") + shutil.copy(args.history, os.path.join(outdir, "history.json")) generate_html(start_time, end_time, links, outdir)