refactor: share the scrapers' fetch helpers

This commit is contained in:
Abdessamad Derraz committed 2026-11-18 13:38:44 +01:00
1 parent a5834a4b8a
commit 6f8b8dedb2
12 files changed
+89 -171

No files matched your search

+2 -12
View File
@@ -21,6 +21,7 @@ from .base_scraper import (
BaseScraper,
BiosRequirement,
fetch_github_latest_version,
github_json,
md5_field,
requirement_entry,
)
@@ -168,19 +169,8 @@ class Scraper(BaseScraper):
def _fetch_standalone(self) -> list[str]:
"""The packages of projects/ROCKNIX/packages/emulators/standalone."""
import json
import urllib.error
import urllib.request
from .base_scraper import github_headers
url = STANDALONE_TREE_URL.format(ref=self.tag or "next")
req = urllib.request.Request(url, headers=github_headers())
try:
with urllib.request.urlopen(req, timeout=30) as resp:
listing = json.loads(resp.read())
except (urllib.error.URLError, json.JSONDecodeError) as e:
raise ConnectionError(f"Failed to list {url}: {e}") from e
listing = github_json(url, f"Failed to list {url}", timeout=30, error=ConnectionError)
packages = [item["name"] for item in listing if item.get("type") == "dir"]
if not packages:
raise RuntimeError(f"no standalone emulator package at {url}")