Пример #1
0
def dump(file_path: str = Argument(None)):
    """Export the database to a json file"""
    if file_path is None:
        date_str = datetime.now().strftime("%Y%m%d_%H%M%S")
        file_path = f"{APPLICATION_DIRECTORY}/time-clock-dump-{date_str}.json"
    print(f"Dumping the database to > {file_path}")
    dump_dict = {
        "time_clok_jobs": Job.dump(),
        "time_clok_state": State.dump(),
        "time_clok": Clok.dump(),
        "time_clok_journal": Journal.dump(),
    }
    s = json.dumps(dump_dict, default=to_json)
    with open(file_path, "w") as f:
        f.write(s)