15 خطوط
850 B
Python
15 خطوط
850 B
Python
#!/usr/bin/env python3
|
|
"""Fetch a real upstream native SchDoc; checksum-pin it and never redistribute."""
|
|
import hashlib
|
|
from pathlib import Path
|
|
from urllib.request import urlopen
|
|
URL='https://raw.githubusercontent.com/KiCad/kicad-source-mirror/master/qa/data/eeschema/plugins/altium/issue24861/Channel.SchDoc'
|
|
SHA='e7dc42a4e983e6b716f6883eb0863fe47164d941636e11b1f2b5ec5d0143dca4'
|
|
root=Path(__file__).resolve().parents[1]
|
|
target=root/'.runtime/fixtures/Channel.SchDoc'
|
|
if not target.exists() or hashlib.sha256(target.read_bytes()).hexdigest()!=SHA:
|
|
with urlopen(URL,timeout=30) as response: data=response.read(4*1024*1024)
|
|
if hashlib.sha256(data).hexdigest()!=SHA: raise SystemExit('Upstream fixture changed; review before updating expected hash')
|
|
target.parent.mkdir(parents=True,exist_ok=True); target.write_bytes(data)
|
|
print(target)
|