- Add shared telemetry module - Add common telemetry helpers - Ignore Python cache files
19 lines
432 B
Python
19 lines
432 B
Python
#!/usr/bin/env python3
|
|
|
|
from pathlib import Path
|
|
from datetime import datetime, timezone
|
|
import json
|
|
|
|
def timestamp():
|
|
return datetime.now(timezone.utc).isoformat()
|
|
|
|
def write_json(path, payload):
|
|
path = Path(path)
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
payload["generated_at"] = timestamp()
|
|
|
|
tmp = path.with_suffix(".tmp")
|
|
tmp.write_text(json.dumps(payload, indent=2) + "\n")
|
|
tmp.replace(path)
|