File size: 524 Bytes
0109502 | 1 2 3 4 5 6 7 8 9 | import json, hashlib, re
from pathlib import Path
def load_json(path): return json.loads(Path(path).read_text(encoding="utf-8"))
def append_jsonl(path,record):
path=Path(path); path.parent.mkdir(parents=True,exist_ok=True)
with path.open("a",encoding="utf-8") as f:f.write(json.dumps(record,ensure_ascii=False)+"\n")
def normalize_code(code): return "\n".join(x.rstrip() for x in code.replace("\r\n","\n").splitlines()).strip()
def sha256_text(text): return hashlib.sha256(text.encode("utf-8","ignore")).hexdigest()
|