Spaces:
Running
Running
| import hashlib | |
| import json | |
| from typing import Any | |
| def content_hash(source: dict[str, Any]) -> str: | |
| value = { | |
| "article": source.get("article") or {}, | |
| "title": source.get("title"), | |
| "publication_name": source.get("publication_name"), | |
| "publication_author": source.get("publication_author"), | |
| "publication_type": source.get("publication_type"), | |
| "source_files": source.get("source_files") or [], | |
| } | |
| return hashlib.sha256(json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode()).hexdigest() | |