#!/usr/bin/env python3 """Ищу в portal-репо файлы, совпадающие по размеру/хэшу с продом simbiot.cil.by.""" import hashlib import json import re import sys import urllib.request GIT = "https://git.cil.by" TOK = re.search(r":([a-f0-9]{40})@", open("/home/hermes/vybirai/.git/config", errors="ignore").read()).group(1) REPO = "symbiot/portal" def api(path): req = urllib.request.Request(f"{GIT}/api/v1{path}", headers={"Authorization": f"token {TOK}"}) with urllib.request.urlopen(req, timeout=15) as r: return json.loads(r.read()) prod = urllib.request.urlopen("https://simbiot.cil.by/", timeout=15).read() target_len, target_sha = len(prod), hashlib.sha256(prod).hexdigest()[:12] print(f"PROD: {target_len} bytes, sha256={target_sha}") for br in ("main",): tree = api(f"/repos/{REPO}/git/trees/{br}?recursive=1") blobs = [t for t in tree.get("tree", []) if t["type"] == "blob"] print(f"{br}: {len(blobs)} blobs") # 1) точный размер hits = [t for t in blobs if t.get("size") == target_len] print("same size:", [t["path"] for t in hits]) # 2) html-файлы рядом по размеру (±30%) near = [t for t in blobs if t["path"].endswith(".html") and target_len * 0.7 < (t.get("size") or 0) < target_len * 1.3] for t in sorted(near, key=lambda x: abs((x.get("size") or 0) - target_len))[:8]: print(f" near: {t['path']} ({t.get('size')} b)")