mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-24 02:27:52 -06:00
refactor: move check_freshness logic to freshness
This commit is contained in:
1 parent
5fa802a3c5
commit
8a2ef047ab
26 files changed
+2171
-1987
No files matched your search
@@ -0,0 +1,35 @@
|
||||
"""A scraper's own write path run on a throwaway copy of the committed file."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from core.paths import REPO_ROOT
|
||||
|
||||
|
||||
def scrape_into_copy(
|
||||
module: str, source: Path, workdir: Path, timeout: int = 900,
|
||||
extra: tuple[str, ...] = (),
|
||||
) -> tuple[Path, str | None]:
|
||||
"""Run a scraper's own write path on a throwaway copy of *source*.
|
||||
|
||||
The CLI merges into the file it writes, so the copy carries every field
|
||||
the scraper preserves and the diff shows only what the scrape changes.
|
||||
"""
|
||||
target = workdir / source.name
|
||||
shutil.copyfile(source, target)
|
||||
proc = subprocess.run(
|
||||
[sys.executable, "-m", module, "-o", str(target), *extra],
|
||||
cwd=REPO_ROOT,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=timeout,
|
||||
check=False,
|
||||
)
|
||||
if proc.returncode != 0:
|
||||
tail = (proc.stderr or proc.stdout).strip().splitlines()[-1:]
|
||||
return target, tail[0] if tail else f"exit {proc.returncode}"
|
||||
return target, None
|
||||
Reference in new issue
Block a user