fix: make council source checksum reproducible across platforms

This commit is contained in:
codex committed 2026-10-08 14:52:12 +03:00
1 parent 74f32a3e67
commit 76bcb0db35
10 files changed
+43 -13

No files matched your search

+4 -2
View File
@@ -41,7 +41,9 @@ def _journal_names(data: dict) -> list[str]:
def prepare_reference(source: Path) -> dict:
publications = []
by_author = defaultdict(list)
source_bytes = source.read_bytes()
# Git stores this text export with LF; canonicalize Windows CRLF before
# parsing and hashing so the prepared artifact is identical on both hosts.
source_bytes = source.read_bytes().replace(b"\r\n", b"\n")
with StringIO(source_bytes.decode("utf-8-sig"), newline="") as stream:
reader = csv.DictReader(stream, delimiter=";")
required = {"Название публикации", "Год", "DOI", "Авторы НИУ ВШЭ", "Квартиль scopus", "Квартиль wos"}
@@ -65,7 +67,7 @@ def prepare_reference(source: Path) -> dict:
for author in sorted({_name(value) for value in authors} - {""}):
by_author[author].append(index)
return {"schema_version": 1, "source_file": source.name,
"source_sha256": hashlib.sha256(source_bytes).hexdigest(),
"source_sha256": hashlib.sha256(source_bytes).hexdigest(), "source_hash_eol": "LF",
"source_rows": len(publications), "publications": publications, "by_author": dict(by_author)}