#!.venv/bin/inner_python3
import requests
from pathlib import Path
import json


CARGO_MOMMY_DATA = "https://raw.githubusercontent.com/Gankra/cargo-mommy/refs/heads/main/responses.json"
MODULE_PATH = Path("python_mommy_venv")


if __name__ == "__main__":
    print("generating stuff")

    res = requests.get(CARGO_MOMMY_DATA)
    if not res.ok:
        raise Exception(f"couldn't fetch {CARGO_MOMMY_DATA} ({res.status_code})")

    data = res.json()
    data["etag"] = res.headers["etag"]

    print(f"writing {Path(MODULE_PATH, 'responses.json')}")
    with Path(MODULE_PATH, "responses.json").open("w") as f:
        json.dump(data, f, indent=4)
