Skip to content

Commit

Permalink
feat(devtools): collect history
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Jan 15, 2022
1 parent d5a65b9 commit a6dc4d6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions apps/tools/librelingo_tools/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)


Expand Down

1 comment on commit a6dc4d6

@vercel
Copy link

@vercel vercel bot commented on a6dc4d6 Jan 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.