Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
741e42001d | ||
|
|
cb294f72a0 | ||
|
|
37ebc97b51 | ||
|
|
a34686f7a5 | ||
|
|
5445f82d91 | ||
|
|
dd62312f87 | ||
|
|
003b2ab111 | ||
|
|
b5cce78652 | ||
|
|
cbe1848d10 | ||
|
|
25eee44483 |
No files matched your search
@@ -61,7 +61,7 @@ ENGINE_MAP = {
|
||||
"Recharged Emerald": "pokeemerald-expansion (likely)",
|
||||
"Recharged Emerald Rebalanced": "pokeemerald-expansion (likely)", # rebalanced/difficulty variant
|
||||
"Recharged Pink": "pokeemerald-expansion (likely)",
|
||||
"Recharged Yellow (previously known as Pokémon Yellow Cross)": "pokeemerald-expansion (likely)",
|
||||
"Recharged Yellow (previously known as Pokémon Yellow Cross)": "pokeemerald-expansion (likely)",
|
||||
# Emerald Cross (Jaizu) — vanilla+ QoL/bugfix, no expansion → lighter decomp build
|
||||
"Emerald Cross": "pokeemerald (decomp, likely)",
|
||||
# --- HeartGold → hg-engine ------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import os, sys
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__))))
|
||||
from update_swarm.cli import main
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,105 @@
|
||||
from __future__ import annotations
|
||||
import hashlib, os, re, zipfile
|
||||
|
||||
CHANGELOG_NAMES = {"changelog.txt", "changelog.md", "changes.txt", "readme.txt", "readme.md"}
|
||||
CURRENT_RE = re.compile(r"(?im)^\s*(?:current\s+version|version)\s*[:\-]\s*(.+?)\s*$")
|
||||
INI_VER = re.compile(r"(?im)^\s*Version\s*=\s*(.+?)\s*$")
|
||||
FILE_VER = re.compile(r"\[(?:v)?(\d+(?:\.\d+)*)\]|\((?:v)?(\d+(?:\.\d+)*)\)|v(\d+(?:\.\d+)*)", re.I)
|
||||
ROM_VER = re.compile(rb"Version\s+[vV]?(\d+(?:\.\d+)*)")
|
||||
|
||||
def _sha_size(path: str) -> tuple[str, int]:
|
||||
h = hashlib.sha256()
|
||||
with open(path, "rb") as f:
|
||||
for chunk in iter(lambda: f.read(1024 * 1024), b""):
|
||||
h.update(chunk)
|
||||
return h.hexdigest(), os.path.getsize(path)
|
||||
|
||||
def _from_text(text: str) -> str | None:
|
||||
m = CURRENT_RE.search(text or "")
|
||||
return m.group(1).strip() if m else None
|
||||
|
||||
def _sidecar_version(file_path: str) -> str | None:
|
||||
parent = os.path.dirname(file_path)
|
||||
if not os.path.isdir(parent):
|
||||
return None
|
||||
names = os.listdir(parent)
|
||||
for name in names:
|
||||
if name.lower() in CHANGELOG_NAMES:
|
||||
with open(os.path.join(parent, name), encoding="utf-8", errors="ignore") as fh:
|
||||
found = _from_text(fh.read())
|
||||
if found:
|
||||
return found
|
||||
for name in names:
|
||||
if name.lower() == "game.ini":
|
||||
with open(os.path.join(parent, name), encoding="utf-8", errors="ignore") as fh:
|
||||
m = INI_VER.search(fh.read())
|
||||
if m:
|
||||
return m.group(1).strip()
|
||||
return None
|
||||
|
||||
def _zip_version(file_path: str) -> str | None:
|
||||
try:
|
||||
with zipfile.ZipFile(file_path) as z:
|
||||
names = z.namelist()
|
||||
for n in names:
|
||||
base = os.path.basename(n).lower()
|
||||
if base in CHANGELOG_NAMES:
|
||||
found = _from_text(z.read(n).decode("utf-8", "ignore"))
|
||||
if found:
|
||||
return found
|
||||
for n in names:
|
||||
if os.path.basename(n).lower() == "game.ini":
|
||||
m = INI_VER.search(z.read(n).decode("utf-8", "ignore"))
|
||||
if m:
|
||||
return m.group(1).strip()
|
||||
except zipfile.BadZipFile:
|
||||
return None
|
||||
return None
|
||||
|
||||
def _filename_version(file_path: str) -> str | None:
|
||||
m = FILE_VER.search(os.path.basename(file_path))
|
||||
if not m:
|
||||
return None
|
||||
return next(g for g in m.groups() if g)
|
||||
|
||||
def _rom_version(file_path: str) -> str | None:
|
||||
with open(file_path, "rb") as f:
|
||||
blob = f.read(512 * 1024)
|
||||
m = ROM_VER.search(blob)
|
||||
return m.group(1).decode() if m else None
|
||||
|
||||
def census_job(job: dict, file_path: str | None) -> dict:
|
||||
rec = {
|
||||
"stem": job["stem"],
|
||||
"installed_version": None,
|
||||
"source": "unknown",
|
||||
"evidence": "",
|
||||
"sha256": None,
|
||||
"size": None,
|
||||
"language": None,
|
||||
}
|
||||
if file_path and os.path.isfile(file_path):
|
||||
rec["sha256"], rec["size"] = _sha_size(file_path)
|
||||
extractors = (
|
||||
(_sidecar_version, "sidecar"),
|
||||
(_zip_version, "zip"),
|
||||
(_filename_version, "filename"),
|
||||
(_rom_version, "rom-bytes"),
|
||||
)
|
||||
for fn, evidence in extractors:
|
||||
try:
|
||||
found = fn(file_path)
|
||||
except OSError:
|
||||
found = None
|
||||
if found:
|
||||
rec["installed_version"] = found
|
||||
rec["source"] = "file"
|
||||
rec["evidence"] = evidence
|
||||
return rec
|
||||
if job.get("note_version"):
|
||||
rec["installed_version"] = job["note_version"]
|
||||
rec["source"] = "note"
|
||||
rec["evidence"] = "vault"
|
||||
return rec
|
||||
rec["evidence"] = "none"
|
||||
return rec
|
||||
@@ -0,0 +1,87 @@
|
||||
from __future__ import annotations
|
||||
import argparse, glob, os, sys
|
||||
from update_swarm.jobs import build_jobs, init_run
|
||||
from update_swarm.judge import judge_all
|
||||
from update_swarm.reports import write_reports
|
||||
from update_swarm.schema import read_json, write_json
|
||||
|
||||
SCOUT_KEYS = ["stem", "latest_english_version", "url", "host", "gate",
|
||||
"language_matrix", "source_used", "hackdex", "upstream_status", "notes"]
|
||||
|
||||
def validate_scout(obj: dict) -> list[str]:
|
||||
return [k for k in SCOUT_KEYS if k not in obj]
|
||||
|
||||
def deploy_argv(pokemon_repo: str, site_repo: str) -> list[list[str]]:
|
||||
return [
|
||||
["python", "scripts/build-vault-mocs.py"],
|
||||
["python", "scripts/build-wiki-data.py"],
|
||||
["powershell", "-File", "scripts/deploy-site.ps1"],
|
||||
]
|
||||
|
||||
def _load_scouts(run_dir: str, jobs: list[dict] | None = None) -> dict:
|
||||
out = {}
|
||||
for path in glob.glob(os.path.join(run_dir, "scouts", "*.json")):
|
||||
obj = read_json(path)
|
||||
errs = validate_scout(obj)
|
||||
if errs:
|
||||
raise SystemExit(f"{path} missing keys: {errs}")
|
||||
out[obj["stem"]] = obj
|
||||
if jobs and len(jobs) > 0 and not out:
|
||||
raise SystemExit("no valid scout files in scouts/ but jobs.json has jobs")
|
||||
return out
|
||||
|
||||
def _load_census(run_dir: str) -> dict:
|
||||
out = {}
|
||||
for path in glob.glob(os.path.join(run_dir, "census", "*.json")):
|
||||
obj = read_json(path)
|
||||
out[obj["stem"]] = obj
|
||||
return out
|
||||
|
||||
def main(argv=None) -> int:
|
||||
p = argparse.ArgumentParser(prog="update-swarm")
|
||||
p.add_argument("--run", required=False, help="path to .scrape/update-runs/YYYY-MM-DD")
|
||||
sub = p.add_subparsers(dest="cmd", required=True)
|
||||
sub.add_parser("init")
|
||||
pj = sub.add_parser("jobs")
|
||||
pj.add_argument("--vault", required=True)
|
||||
sub.add_parser("validate-scouts")
|
||||
sub.add_parser("judge")
|
||||
sub.add_parser("reports")
|
||||
args = p.parse_args(argv)
|
||||
if args.cmd == "init":
|
||||
if not args.run:
|
||||
raise SystemExit("--run is required")
|
||||
init_run(args.run)
|
||||
return 0
|
||||
if args.cmd == "jobs":
|
||||
if not args.run:
|
||||
raise SystemExit("--run is required")
|
||||
jobs = build_jobs(args.vault)
|
||||
write_json(os.path.join(args.run, "jobs.json"), {"run_date": os.path.basename(args.run), "jobs": jobs})
|
||||
print(f"wrote {len(jobs)} jobs")
|
||||
return 0
|
||||
if args.cmd == "validate-scouts":
|
||||
if not args.run:
|
||||
raise SystemExit("--run is required")
|
||||
jobs = read_json(os.path.join(args.run, "jobs.json")).get("jobs")
|
||||
_load_scouts(args.run, jobs)
|
||||
print("scouts ok")
|
||||
return 0
|
||||
if args.cmd == "judge":
|
||||
if not args.run:
|
||||
raise SystemExit("--run is required")
|
||||
jobs = read_json(os.path.join(args.run, "jobs.json"))["jobs"]
|
||||
verdicts = judge_all(jobs, _load_census(args.run), _load_scouts(args.run, jobs))
|
||||
write_json(os.path.join(args.run, "verdict.json"), {"verdicts": verdicts})
|
||||
print(f"wrote {len(verdicts)} verdicts")
|
||||
return 0
|
||||
if args.cmd == "reports":
|
||||
if not args.run:
|
||||
raise SystemExit("--run is required")
|
||||
verdicts = read_json(os.path.join(args.run, "verdict.json"))["verdicts"]
|
||||
write_reports(args.run, verdicts)
|
||||
return 0
|
||||
return 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,66 @@
|
||||
from __future__ import annotations
|
||||
import hashlib, os, re, urllib.request, zipfile
|
||||
from update_swarm.census import _from_text, CHANGELOG_NAMES
|
||||
from update_swarm.hosts import classify_url
|
||||
from update_swarm.versions import compare_versions
|
||||
|
||||
UA = "Mozilla/5.0 (homelab personal archival)"
|
||||
MF = re.compile(r"https://download\d+\.mediafire\.com/[^\"'\s<>]+")
|
||||
|
||||
class GatedHostError(ValueError):
|
||||
pass
|
||||
|
||||
def resolve_mediafire(html: str) -> str | None:
|
||||
m = MF.search(html or "")
|
||||
return m.group(0) if m else None
|
||||
|
||||
def _open(url: str, opener=None):
|
||||
req = urllib.request.Request(url, headers={"User-Agent": UA})
|
||||
if opener:
|
||||
return opener(req, timeout=60)
|
||||
return urllib.request.urlopen(req, timeout=60)
|
||||
|
||||
def download(url: str, dest_path: str, opener=None) -> dict:
|
||||
host, gate = classify_url(url)
|
||||
if gate == "gated":
|
||||
raise GatedHostError(f"{host} is gated: {url}")
|
||||
if host == "mega":
|
||||
raise NotImplementedError("mega downloads use megadl in the CLI")
|
||||
fetch_url = url
|
||||
if host == "mediafire" and "/file/" in url:
|
||||
with _open(url, opener) as resp:
|
||||
html = resp.read().decode("utf-8", "ignore")
|
||||
direct = resolve_mediafire(html)
|
||||
if not direct:
|
||||
raise ValueError("no mediafire direct link")
|
||||
fetch_url = direct
|
||||
os.makedirs(os.path.dirname(dest_path) or ".", exist_ok=True)
|
||||
part_path = dest_path + ".part"
|
||||
h = hashlib.sha256()
|
||||
size = 0
|
||||
try:
|
||||
with _open(fetch_url, opener) as resp, open(part_path, "wb") as out:
|
||||
while True:
|
||||
chunk = resp.read(1024 * 1024)
|
||||
if not chunk:
|
||||
break
|
||||
out.write(chunk)
|
||||
h.update(chunk)
|
||||
size += len(chunk)
|
||||
except BaseException:
|
||||
if os.path.exists(part_path):
|
||||
os.remove(part_path)
|
||||
raise
|
||||
os.replace(part_path, dest_path)
|
||||
return {"path": dest_path, "sha256": h.hexdigest(), "size": size, "url": fetch_url}
|
||||
|
||||
def english_mismatch(archive_path: str, expected_version: str) -> bool:
|
||||
if not zipfile.is_zipfile(archive_path):
|
||||
return False
|
||||
with zipfile.ZipFile(archive_path) as z:
|
||||
for n in z.namelist():
|
||||
if os.path.basename(n).lower() in CHANGELOG_NAMES:
|
||||
found = _from_text(z.read(n).decode("utf-8", "ignore"))
|
||||
if found and compare_versions(found, expected_version) != "eq":
|
||||
return True
|
||||
return False
|
||||
@@ -1,30 +1,40 @@
|
||||
from __future__ import annotations
|
||||
from urllib.parse import urlparse
|
||||
|
||||
GITHUB_HOSTS = frozenset(("github.com", "raw.githubusercontent.com", "objects.githubusercontent.com"))
|
||||
# Exact host or dot-suffix match — `endswith(d)` alone accepts lookalikes like
|
||||
# `notmediafire.com` or `evilmega.nz`.
|
||||
SUFFIX_HOSTS = {
|
||||
"archive.org": "archive",
|
||||
"mediafire.com": "mediafire",
|
||||
"mega.nz": "mega",
|
||||
"mega.co.nz": "mega",
|
||||
"itch.io": "itch",
|
||||
"ko-fi.com": "kofi",
|
||||
"hackdex.app": "hackdex",
|
||||
"pokecommunity.com": "pokecommunity",
|
||||
}
|
||||
|
||||
def _host_match(host: str, domain: str) -> bool:
|
||||
return host == domain or host.endswith("." + domain)
|
||||
|
||||
def classify_url(url: str) -> tuple[str, str]:
|
||||
p = urlparse(url or "")
|
||||
host = (p.netloc or "").lower().removeprefix("www.")
|
||||
path = p.path or ""
|
||||
if host in ("github.com", "raw.githubusercontent.com", "objects.githubusercontent.com"):
|
||||
if host in GITHUB_HOSTS:
|
||||
if host != "github.com" or "/releases/download/" in path:
|
||||
return "github", "ungated"
|
||||
return "github", "gated"
|
||||
if host.endswith("archive.org"):
|
||||
return "archive", "ungated"
|
||||
if host.endswith("mediafire.com"):
|
||||
return "mediafire", "ungated"
|
||||
if host.endswith("mega.nz") or host.endswith("mega.co.nz"):
|
||||
return "mega", "ungated" if p.fragment else "gated"
|
||||
if host.endswith("itch.io"):
|
||||
return "itch", "gated"
|
||||
for domain, label in SUFFIX_HOSTS.items():
|
||||
if _host_match(host, domain):
|
||||
if label == "mega":
|
||||
return "mega", "ungated" if p.fragment else "gated"
|
||||
if label in ("archive", "mediafire"):
|
||||
return label, "ungated"
|
||||
return label, "gated"
|
||||
if host in ("drive.google.com", "docs.google.com"):
|
||||
return "drive", "gated"
|
||||
if host in ("discord.com", "discord.gg"):
|
||||
return "discord", "gated"
|
||||
if host.endswith("ko-fi.com"):
|
||||
return "kofi", "gated"
|
||||
if host.endswith("hackdex.app"):
|
||||
return "hackdex", "gated"
|
||||
if host.endswith("pokecommunity.com"):
|
||||
return "pokecommunity", "gated"
|
||||
return "other", "gated"
|
||||
@@ -6,17 +6,45 @@ import enrich_vault as E
|
||||
from update_swarm.schema import write_json
|
||||
|
||||
WIKILINK = re.compile(r"\[\[([^\]|#]+)")
|
||||
BOLD = re.compile(r"\*\*([^*]+)\*\*")
|
||||
WL_CELL = re.compile(r"^\s*\[\[([^\]|#]+)\]\]\s*$")
|
||||
POKE_PREFIX = re.compile(r"^pokémon\s+", re.I)
|
||||
|
||||
def _links(path: str) -> set[str]:
|
||||
def _norm_stem(s: str) -> str:
|
||||
return POKE_PREFIX.sub("", s.strip()).casefold()
|
||||
|
||||
def _watchlist_stems(path: str) -> set[str]:
|
||||
if not os.path.isfile(path):
|
||||
return set()
|
||||
text = open(path, encoding="utf-8").read()
|
||||
return {m.strip() for m in WIKILINK.findall(text)}
|
||||
stems: set[str] = set()
|
||||
with open(path, encoding="utf-8") as fh:
|
||||
for line in fh:
|
||||
if not line.lstrip().startswith("|"):
|
||||
continue
|
||||
for cell in line.split("|"):
|
||||
m = WL_CELL.match(cell)
|
||||
if m:
|
||||
stems.add(m.group(1).strip())
|
||||
return stems
|
||||
|
||||
def _wanted_stems(path: str) -> set[str]:
|
||||
if not os.path.isfile(path):
|
||||
return set()
|
||||
with open(path, encoding="utf-8") as fh:
|
||||
text = fh.read()
|
||||
stems = {m.strip() for m in WIKILINK.findall(text)}
|
||||
for line in text.splitlines():
|
||||
if not line.lstrip().startswith("|"):
|
||||
continue
|
||||
for cell in line.split("|"):
|
||||
for m in BOLD.finditer(cell):
|
||||
stems.add(m.group(1).strip())
|
||||
return stems
|
||||
|
||||
def build_jobs(vault_romhacks_dir: str) -> list[dict]:
|
||||
hacks = os.path.join(vault_romhacks_dir, "Hacks")
|
||||
watch = _links(os.path.join(vault_romhacks_dir, "Demo Watchlist.md"))
|
||||
wanted = _links(os.path.join(vault_romhacks_dir, "Wanted.md"))
|
||||
watch = {_norm_stem(s) for s in _watchlist_stems(os.path.join(vault_romhacks_dir, "Demo Watchlist.md"))}
|
||||
wanted = {_norm_stem(s) for s in _wanted_stems(os.path.join(vault_romhacks_dir, "Wanted.md"))}
|
||||
jobs = []
|
||||
for path in sorted(glob.glob(os.path.join(hacks, "*.md"))):
|
||||
stem = os.path.splitext(os.path.basename(path))[0]
|
||||
@@ -24,6 +52,7 @@ def build_jobs(vault_romhacks_dir: str) -> list[dict]:
|
||||
fm = E.parse_fm(fm_text)
|
||||
def blank(v):
|
||||
return None if v in (None, "", "—") else v
|
||||
nstem = _norm_stem(stem)
|
||||
jobs.append({
|
||||
"stem": stem,
|
||||
"title": fm.get("title") or stem,
|
||||
@@ -33,8 +62,8 @@ def build_jobs(vault_romhacks_dir: str) -> list[dict]:
|
||||
"source": blank(fm.get("source")),
|
||||
"note_version": blank(fm.get("version")),
|
||||
"note_status": blank(fm.get("status")),
|
||||
"watchlist": stem in watch,
|
||||
"wanted": stem in wanted,
|
||||
"watchlist": nstem in watch,
|
||||
"wanted": nstem in wanted,
|
||||
})
|
||||
return jobs
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
from __future__ import annotations
|
||||
from update_swarm.versions import compare_versions
|
||||
|
||||
def judge_one(job: dict, census: dict, scout: dict) -> dict:
|
||||
installed = census.get("installed_version")
|
||||
latest = scout.get("latest_english_version")
|
||||
gate = scout.get("gate")
|
||||
url = scout.get("url")
|
||||
out = {
|
||||
"stem": job["stem"],
|
||||
"bucket": "current",
|
||||
"reason": "",
|
||||
"fetch_url": None,
|
||||
"installed_version": installed,
|
||||
"latest_english_version": latest,
|
||||
"gate": gate,
|
||||
"incomparable": False,
|
||||
"bump_status": None,
|
||||
"remove_from_watchlist": False,
|
||||
}
|
||||
if not latest:
|
||||
out["reason"] = "no-latest"
|
||||
return out
|
||||
if census.get("source") == "unknown" and census.get("sha256") and scout.get("sha256"):
|
||||
if census["sha256"] == scout["sha256"]:
|
||||
out["reason"] = "hash-match"
|
||||
return out
|
||||
cmp = compare_versions(installed or "", latest) if installed else "lt"
|
||||
if installed and cmp == "incomparable":
|
||||
out["bucket"] = "incomparable"
|
||||
out["incomparable"] = True
|
||||
out["reason"] = "incomparable"
|
||||
return out
|
||||
newer = (not installed) or cmp == "lt"
|
||||
if not newer:
|
||||
out["reason"] = "up-to-date"
|
||||
return out
|
||||
complete = (scout.get("upstream_status") == "Complete")
|
||||
ungated = gate == "ungated" and url
|
||||
if job.get("watchlist"):
|
||||
if complete and ungated:
|
||||
out["bucket"] = "watchlist_promote"
|
||||
out["fetch_url"] = url
|
||||
out["remove_from_watchlist"] = True
|
||||
out["reason"] = "watchlist-complete-ungated"
|
||||
return out
|
||||
if not ungated:
|
||||
out["bucket"] = "gated_queue"
|
||||
out["bump_status"] = "Complete" if complete else None
|
||||
out["reason"] = "watchlist-gated"
|
||||
return out
|
||||
out["bucket"] = "watchlist_report"
|
||||
out["reason"] = "watchlist-demo"
|
||||
return out
|
||||
if ungated:
|
||||
out["bucket"] = "update"
|
||||
out["fetch_url"] = url
|
||||
out["reason"] = "newer-ungated"
|
||||
return out
|
||||
out["bucket"] = "gated_queue"
|
||||
out["bump_status"] = "Complete" if complete else None
|
||||
out["reason"] = "newer-gated"
|
||||
return out
|
||||
|
||||
def judge_all(jobs: list[dict], census_by_stem: dict, scouts_by_stem: dict) -> list[dict]:
|
||||
verdicts = []
|
||||
for job in jobs:
|
||||
stem = job["stem"]
|
||||
c = census_by_stem.get(stem) or {"stem": stem, "installed_version": job.get("note_version"), "source": "note" if job.get("note_version") else "unknown", "sha256": None}
|
||||
s = scouts_by_stem.get(stem) or {"stem": stem, "latest_english_version": None, "url": None, "gate": None, "upstream_status": None}
|
||||
verdicts.append(judge_one(job, c, s))
|
||||
return verdicts
|
||||
@@ -0,0 +1,42 @@
|
||||
from __future__ import annotations
|
||||
import os, sys
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
import enrich_vault as E
|
||||
import enrich_web as W
|
||||
|
||||
ROMM_PLATFORM_IDS = {"GBA": 72, "PC": 200, "windows": 200}
|
||||
|
||||
def require_platform_id(platform: str) -> int:
|
||||
if platform not in ROMM_PLATFORM_IDS:
|
||||
raise KeyError(f"no RomM platform_id for {platform!r}; add it to ROMM_PLATFORM_IDS")
|
||||
return ROMM_PLATFORM_IDS[platform]
|
||||
|
||||
def superseded_name(live_basename: str, old_version: str) -> str:
|
||||
root, ext = os.path.splitext(live_basename)
|
||||
return f"{root} ({old_version}){ext}"
|
||||
|
||||
def romm_scan_argv(platform_ids: list[int]) -> list[str]:
|
||||
if not platform_ids:
|
||||
raise ValueError("platform_ids is required; refusing a full-library walk")
|
||||
ids = "[" + ", ".join(str(i) for i in platform_ids) + "]"
|
||||
py = (
|
||||
"import asyncio; from endpoints.sockets.scan import scan_platforms; "
|
||||
"from handler.scan_handler import ScanType; "
|
||||
f"asyncio.run(scan_platforms(platform_ids={ids}, metadata_sources=[], scan_type=ScanType.QUICK))"
|
||||
)
|
||||
return ["docker", "exec", "-w", "/backend", "romm", "python3", "-c", py]
|
||||
|
||||
def patch_note(path: str, version: str, release_date: str | None,
|
||||
source_url: str | None, history_md: str | None, status: str | None) -> str:
|
||||
fm_text, body, _ = E.read_note(path)
|
||||
fm = E.parse_fm(fm_text)
|
||||
fm["version"] = version
|
||||
if release_date:
|
||||
fm["release_date"] = release_date
|
||||
if source_url:
|
||||
fm["source"] = source_url
|
||||
if status:
|
||||
fm["status"] = status
|
||||
if history_md:
|
||||
body = W.set_section(body, "Version history", history_md.strip())
|
||||
return f"---\n{E.emit_fm(fm)}\n---\n{body}"
|
||||
@@ -0,0 +1,14 @@
|
||||
from __future__ import annotations
|
||||
import os
|
||||
|
||||
def write_reports(run_dir: str, verdicts: list[dict]) -> None:
|
||||
gated = [v for v in verdicts if v["bucket"] == "gated_queue"]
|
||||
watch = [v for v in verdicts if v["bucket"] == "watchlist_report"]
|
||||
def table(path, title, rows):
|
||||
lines = [f"# {title}", "", "| Stem | Latest English | Reason |", "|---|---|---|"]
|
||||
for v in rows:
|
||||
lines.append(f"| {v['stem']} | {v.get('latest_english_version') or ''} | {v.get('reason') or ''} |")
|
||||
lines.append("")
|
||||
open(path, "w", encoding="utf-8").write("\n".join(lines))
|
||||
table(os.path.join(run_dir, "gated.md"), "Gated queue", gated)
|
||||
table(os.path.join(run_dir, "watchlist-report.md"), "Watchlist check-in", watch)
|
||||
@@ -0,0 +1,24 @@
|
||||
# Scout agent prompt
|
||||
|
||||
You are a version scout for one Pokémon ROM hack or fangame. Do not download binaries. Do not invent versions.
|
||||
|
||||
Installed version (may be wrong if `source` is `note`): {installed_version} ({installed_source})
|
||||
Homepage: {homepage}
|
||||
Source URL: {source}
|
||||
|
||||
Find the latest **English** playable build, even if Spanish/French/etc. is newer.
|
||||
|
||||
Source order: official site / GitHub releases / project page → HackDex → PokeCommunity → other.
|
||||
If HackDex is Cloudflare-blocked, set hackdex to "blocked" and continue. Never guess.
|
||||
|
||||
Write scouts/{stem}.json with exactly these keys:
|
||||
- stem (string)
|
||||
- latest_english_version (string or null)
|
||||
- url (direct download if ungated, else the page URL, or null)
|
||||
- host (github|archive|mediafire|mega|itch|drive|discord|kofi|hackdex|pokecommunity|other or null)
|
||||
- gate (ungated|gated|null)
|
||||
- language_matrix (object, e.g. {"en": "2.13", "es": "2.18"}; empty object if unknown)
|
||||
- source_used (website|hackdex|pokecommunity|other or null)
|
||||
- hackdex (ok|blocked|skipped)
|
||||
- upstream_status (Complete|Ongoing|Beta or null)
|
||||
- notes (string)
|
||||
@@ -3,7 +3,7 @@ import re
|
||||
|
||||
_LANG = re.compile(r"\s*\((EN|ES|FR|DE|IT|PT|JP)\)\s*", re.I)
|
||||
_LEADING_V = re.compile(r"^\s*v", re.I)
|
||||
_NUMERIC = re.compile(r"^(\d+(?:\.\d+)*)")
|
||||
_NUMERIC = re.compile(r"^(\d+(?:\.\d+)*)\s*$")
|
||||
|
||||
def normalize_version(s: str) -> str:
|
||||
s = _LANG.sub(" ", s or "")
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[Game]
|
||||
Title=Both Sidecars
|
||||
Version=9.9.9
|
||||
@@ -0,0 +1 @@
|
||||
Current Version: 3.3.1
|
||||
Whitespace-only changes.
@@ -0,0 +1 @@
|
||||
Current Version: 3.3.1
|
||||
Whitespace-only changes.
@@ -0,0 +1,3 @@
|
||||
[Game]
|
||||
Title=Ini Game
|
||||
Version=1.74.1
|
||||
Whitespace-only changes.
Binary file not shown.
@@ -1,3 +1,5 @@
|
||||
| Hack | Vault note |
|
||||
|---|---|
|
||||
| **DemoOnly** | [[DemoOnly]] |
|
||||
| Hack | Vault note | Why parked | Where to watch |
|
||||
|---|---|---|---|
|
||||
| **DemoOnly** | [[DemoOnly]] | Essentials demo v0.6.2 | Eevee Expo |
|
||||
| **Odyssey II / Heroes of Lemuria** | [[Odyssey]] (related) | Demo / early build | Discord |
|
||||
| **Light Platinum DS** | [[Light Platinum]] (GBA complete; DS is separate) | DS remake — media/teasers only | Twitter |
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
title: "Pokémon Light Platinum"
|
||||
platform: GBA
|
||||
version: "1.0"
|
||||
status: Complete
|
||||
---
|
||||
|
||||
# Pokémon Light Platinum
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
title: "Pokémon Odyssey"
|
||||
platform: GBA
|
||||
version: "1.0"
|
||||
status: Complete
|
||||
---
|
||||
|
||||
# Pokémon Odyssey
|
||||
@@ -1 +1,15 @@
|
||||
# Wanted — Manual Acquisition List
|
||||
|
||||
See [[FakeHack]] still gated.
|
||||
|
||||
## Acquired
|
||||
|
||||
| Hack | Path |
|
||||
|---|---|
|
||||
| **FakeHack** | `gba/Hacks/Pokemon - FakeHack (Hack).gba` |
|
||||
|
||||
## Still wanted
|
||||
|
||||
| Hack | Notes |
|
||||
|---|---|
|
||||
| **DemoOnly** | demo-only entry, not in library yet |
|
||||
@@ -0,0 +1,73 @@
|
||||
import hashlib, os, sys, tempfile, unittest, zipfile
|
||||
from unittest.mock import patch
|
||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
sys.path.insert(0, os.path.join(ROOT, "scripts"))
|
||||
from update_swarm.census import census_job
|
||||
|
||||
FIX = os.path.join(os.path.dirname(__file__), "fixtures", "library")
|
||||
|
||||
def job(stem, note_version=None):
|
||||
return {"stem": stem, "library_path": None, "note_version": note_version}
|
||||
|
||||
class TestCensus(unittest.TestCase):
|
||||
def test_changelog_current_version_line(self):
|
||||
rec = census_job(job("C"), os.path.join(FIX, "changelog-game", "dummy.bin"))
|
||||
self.assertEqual(rec["installed_version"], "3.3.1")
|
||||
self.assertEqual(rec["source"], "file")
|
||||
|
||||
def test_game_ini_version(self):
|
||||
rec = census_job(job("I"), os.path.join(FIX, "ini-game", "dummy.bin"))
|
||||
self.assertEqual(rec["installed_version"], "1.74.1")
|
||||
self.assertEqual(rec["source"], "file")
|
||||
|
||||
@patch(
|
||||
"update_swarm.census.os.listdir",
|
||||
return_value=["Game.ini", "changelog.txt", "dummy.bin"],
|
||||
)
|
||||
def test_sidecar_prefers_changelog_over_game_ini(self, _listdir):
|
||||
rec = census_job(job("B"), os.path.join(FIX, "both-sidecars", "dummy.bin"))
|
||||
self.assertEqual(rec["installed_version"], "3.3.1")
|
||||
self.assertEqual(rec["source"], "file")
|
||||
self.assertEqual(rec["evidence"], "sidecar")
|
||||
|
||||
def test_filename_token(self):
|
||||
rec = census_job(job("N"), os.path.join(FIX, "named", "Pokemon - Named [Hack][3.3.1].zip"))
|
||||
self.assertEqual(rec["installed_version"], "3.3.1")
|
||||
|
||||
def test_zip_inner_changelog(self):
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
zpath = os.path.join(td, "game.zip")
|
||||
with zipfile.ZipFile(zpath, "w") as z:
|
||||
z.writestr("README.txt", "Current Version: 2.13\n")
|
||||
rec = census_job(job("Z"), zpath)
|
||||
self.assertEqual(rec["installed_version"], "2.13")
|
||||
|
||||
def test_note_fallback_then_unknown(self):
|
||||
rec = census_job(job("X", note_version="9.9"), None)
|
||||
self.assertEqual(rec["source"], "note")
|
||||
self.assertEqual(rec["installed_version"], "9.9")
|
||||
rec2 = census_job(job("Y"), None)
|
||||
self.assertEqual(rec2["source"], "unknown")
|
||||
self.assertIsNone(rec2["installed_version"])
|
||||
|
||||
@patch(
|
||||
"update_swarm.census.os.listdir",
|
||||
return_value=["changelog.txt", "dummy.bin"],
|
||||
)
|
||||
def test_rom_version_oserror_keeps_sidecar(self, _listdir):
|
||||
# A later OSError must not discard an earlier sidecar hit.
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
cpath = os.path.join(td, "changelog.txt")
|
||||
with open(cpath, "w", encoding="utf-8") as fh:
|
||||
fh.write("Current Version: 3.3.1\n")
|
||||
rom_path = os.path.join(td, "dummy.bin")
|
||||
with open(rom_path, "wb") as fh:
|
||||
fh.write(b"\x00")
|
||||
with patch("update_swarm.census._rom_version", side_effect=OSError("boom")):
|
||||
rec = census_job(job("S"), rom_path)
|
||||
self.assertEqual(rec["installed_version"], "3.3.1")
|
||||
self.assertEqual(rec["source"], "file")
|
||||
self.assertEqual(rec["evidence"], "sidecar")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,80 @@
|
||||
import json, os, sys, tempfile, unittest
|
||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
sys.path.insert(0, os.path.join(ROOT, "scripts"))
|
||||
from update_swarm.cli import deploy_argv, validate_scout, main
|
||||
from update_swarm.reports import write_reports
|
||||
from update_swarm.schema import write_json
|
||||
|
||||
class TestCli(unittest.TestCase):
|
||||
def test_validate_scout_missing_keys(self):
|
||||
errs = validate_scout({"stem": "Z"})
|
||||
self.assertIn("latest_english_version", " ".join(errs))
|
||||
|
||||
def test_validate_scout_ok(self):
|
||||
obj = {
|
||||
"stem": "Z", "latest_english_version": "2.13", "url": "https://example.com/z.zip",
|
||||
"host": "other", "gate": "gated", "language_matrix": {"en": "2.13", "es": "2.18"},
|
||||
"source_used": "website", "hackdex": "skipped", "upstream_status": "Complete", "notes": "",
|
||||
}
|
||||
self.assertEqual(validate_scout(obj), [])
|
||||
|
||||
def test_reports(self):
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
verdicts = [
|
||||
{"stem": "A", "bucket": "gated_queue", "latest_english_version": "2.0", "fetch_url": None, "gate": "itch", "reason": "newer-gated"},
|
||||
{"stem": "B", "bucket": "watchlist_report", "latest_english_version": "0.7", "reason": "watchlist-demo"},
|
||||
]
|
||||
write_reports(td, verdicts)
|
||||
gated = open(os.path.join(td, "gated.md"), encoding="utf-8").read()
|
||||
wl = open(os.path.join(td, "watchlist-report.md"), encoding="utf-8").read()
|
||||
self.assertIn("A", gated)
|
||||
self.assertIn("B", wl)
|
||||
|
||||
def test_deploy_argv(self):
|
||||
cmds = deploy_argv("/pokemon", "/site")
|
||||
self.assertEqual(cmds[0], ["python", "scripts/build-vault-mocs.py"])
|
||||
self.assertEqual(cmds[1], ["python", "scripts/build-wiki-data.py"])
|
||||
self.assertEqual(cmds[2][-1], "scripts/deploy-site.ps1")
|
||||
|
||||
def test_prompt_file_exists(self):
|
||||
path = os.path.join(ROOT, "scripts", "update_swarm", "scout_prompt.md")
|
||||
text = open(path, encoding="utf-8").read()
|
||||
self.assertIn("latest_english_version", text)
|
||||
self.assertIn("Do not invent versions", text)
|
||||
|
||||
def _valid_scout(self, stem):
|
||||
return {
|
||||
"stem": stem, "latest_english_version": "1.0", "url": "https://example.com/z.zip",
|
||||
"host": "other", "gate": "gated", "language_matrix": {"en": "1.0"},
|
||||
"source_used": "website", "hackdex": "skipped", "upstream_status": "Complete", "notes": "",
|
||||
}
|
||||
|
||||
def test_validate_scouts_fails_when_jobs_but_no_scouts(self):
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
run = os.path.join(td, "2026-08-14")
|
||||
os.makedirs(os.path.join(run, "scouts"))
|
||||
write_json(os.path.join(run, "jobs.json"),
|
||||
{"run_date": "2026-08-14", "jobs": [{"stem": "X"}]})
|
||||
with self.assertRaises(SystemExit):
|
||||
main(["--run", run, "validate-scouts"])
|
||||
|
||||
def test_validate_scouts_ok_when_scouts_present(self):
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
run = os.path.join(td, "2026-08-14")
|
||||
scouts = os.path.join(run, "scouts")
|
||||
os.makedirs(scouts)
|
||||
write_json(os.path.join(run, "jobs.json"),
|
||||
{"run_date": "2026-08-14", "jobs": [{"stem": "X"}]})
|
||||
write_json(os.path.join(scouts, "X.json"), self._valid_scout("X"))
|
||||
self.assertEqual(main(["--run", run, "validate-scouts"]), 0)
|
||||
|
||||
def test_validate_scouts_ok_when_no_jobs(self):
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
run = os.path.join(td, "2026-08-14")
|
||||
os.makedirs(os.path.join(run, "scouts"))
|
||||
write_json(os.path.join(run, "jobs.json"),
|
||||
{"run_date": "2026-08-14", "jobs": []})
|
||||
self.assertEqual(main(["--run", run, "validate-scouts"]), 0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,65 @@
|
||||
import os, sys, tempfile, unittest, zipfile
|
||||
from unittest.mock import patch
|
||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
sys.path.insert(0, os.path.join(ROOT, "scripts"))
|
||||
from update_swarm.fetch import GatedHostError, download, english_mismatch, resolve_mediafire
|
||||
|
||||
class TestFetch(unittest.TestCase):
|
||||
def test_mediafire_regex(self):
|
||||
html = '<a href="https://download123.mediafire.com/abc/file.zip">dl</a>'
|
||||
self.assertEqual(resolve_mediafire(html), "https://download123.mediafire.com/abc/file.zip")
|
||||
|
||||
def test_refuses_gated(self):
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
with self.assertRaises(GatedHostError):
|
||||
download("https://foo.itch.io/x", os.path.join(td, "x.zip"))
|
||||
|
||||
def test_download_writes_bytes(self):
|
||||
class Resp:
|
||||
def __init__(self):
|
||||
self._done = False
|
||||
def __enter__(self): return self
|
||||
def __exit__(self, *a): pass
|
||||
def read(self, n=-1):
|
||||
if self._done:
|
||||
return b""
|
||||
self._done = True
|
||||
return b"rombytes"
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
dest = os.path.join(td, "g.gba")
|
||||
with patch("update_swarm.fetch.urllib.request.urlopen", return_value=Resp()) as mock_urlopen:
|
||||
rec = download("https://github.com/a/b/releases/download/v1/g.gba", dest)
|
||||
self.assertTrue(os.path.isfile(dest))
|
||||
self.assertEqual(rec["size"], 8)
|
||||
# timeout kwarg must be forwarded to urlopen
|
||||
self.assertEqual(mock_urlopen.call_args.kwargs.get("timeout"), 60)
|
||||
|
||||
def test_download_failure_leaves_no_dest(self):
|
||||
class Resp:
|
||||
def __enter__(self): return self
|
||||
def __exit__(self, *a): pass
|
||||
def read(self, n=-1):
|
||||
raise OSError("network died")
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
dest = os.path.join(td, "g.gba")
|
||||
with patch("update_swarm.fetch.urllib.request.urlopen", return_value=Resp()):
|
||||
with self.assertRaises(OSError):
|
||||
download("https://github.com/a/b/releases/download/v1/g.gba", dest)
|
||||
self.assertFalse(os.path.exists(dest))
|
||||
self.assertFalse(os.path.exists(dest + ".part"))
|
||||
|
||||
def test_mega_not_implemented(self):
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
with self.assertRaises(NotImplementedError):
|
||||
download("https://mega.nz/file/abc#key", os.path.join(td, "x"))
|
||||
|
||||
def test_changelog_mismatch(self):
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
zpath = os.path.join(td, "g.zip")
|
||||
with zipfile.ZipFile(zpath, "w") as z:
|
||||
z.writestr("changelog.txt", "Current Version: 2.16\n")
|
||||
self.assertTrue(english_mismatch(zpath, "2.13"))
|
||||
self.assertFalse(english_mismatch(zpath, "v2.16 (ES)"))
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -20,5 +20,16 @@ class TestClassify(unittest.TestCase):
|
||||
self.assertEqual(classify_url("https://www.pokecommunity.com/threads/x.1/"), ("pokecommunity", "gated"))
|
||||
self.assertEqual(classify_url("https://mystery.example/file.zip"), ("other", "gated"))
|
||||
|
||||
def test_lookalike_hosts_are_gated(self):
|
||||
self.assertEqual(classify_url("https://notmediafire.com/x"), ("other", "gated"))
|
||||
self.assertEqual(classify_url("https://evilmega.nz/file/a#k"), ("other", "gated"))
|
||||
self.assertEqual(classify_url("https://notarchive.org/x"), ("other", "gated"))
|
||||
self.assertEqual(classify_url("https://notitch.io/x"), ("other", "gated"))
|
||||
|
||||
def test_real_hosts_still_classified(self):
|
||||
self.assertEqual(classify_url("https://www.mediafire.com/file/abc/x.zip/file"), ("mediafire", "ungated"))
|
||||
self.assertEqual(classify_url("https://mega.nz/file/a#k"), ("mega", "ungated"))
|
||||
self.assertEqual(classify_url("https://sub.archive.org/download/x"), ("archive", "ungated"))
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -13,9 +13,21 @@ class TestJobs(unittest.TestCase):
|
||||
self.assertFalse(jobs["FakeHack"]["watchlist"])
|
||||
self.assertEqual(jobs["FakeHack"]["note_version"], "1.0.0")
|
||||
self.assertTrue(jobs["DemoOnly"]["watchlist"])
|
||||
self.assertFalse(jobs["DemoOnly"]["wanted"])
|
||||
self.assertTrue(jobs["DemoOnly"]["wanted"])
|
||||
self.assertIsNone(jobs["DemoOnly"]["library_path"])
|
||||
|
||||
def test_watchlist_skips_parenthetical_notes(self):
|
||||
jobs = {j["stem"]: j for j in build_jobs(FIXTURE)}
|
||||
# `[[Odyssey]] (related)` and `[[Light Platinum]] (GBA complete; DS is separate)`
|
||||
# appear in Demo Watchlist table rows but are parenthetical notes, not watchlist stems.
|
||||
self.assertFalse(jobs["Odyssey"]["watchlist"])
|
||||
self.assertFalse(jobs["Light Platinum"]["watchlist"])
|
||||
|
||||
def test_wanted_matches_bold_names(self):
|
||||
jobs = {j["stem"]: j for j in build_jobs(FIXTURE)}
|
||||
# `**DemoOnly**` in Wanted.md (no wikilink) should still flag wanted.
|
||||
self.assertTrue(jobs["DemoOnly"]["wanted"])
|
||||
|
||||
def test_init_run_creates_dirs(self):
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
run = os.path.join(td, "2026-08-14")
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import os, sys, unittest
|
||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
sys.path.insert(0, os.path.join(ROOT, "scripts"))
|
||||
from update_swarm.judge import judge_one
|
||||
|
||||
def job(**kw):
|
||||
base = {"stem": "X", "watchlist": False, "wanted": False, "note_version": None}
|
||||
base.update(kw)
|
||||
return base
|
||||
|
||||
def census(**kw):
|
||||
base = {"stem": "X", "installed_version": "1.0", "source": "file", "sha256": "aa"}
|
||||
base.update(kw)
|
||||
return base
|
||||
|
||||
def scout(**kw):
|
||||
base = {"stem": "X", "latest_english_version": "1.1", "url": "https://github.com/a/b/releases/download/v1.1/x.zip",
|
||||
"host": "github", "gate": "ungated", "upstream_status": "Complete", "sha256": None}
|
||||
base.update(kw)
|
||||
return base
|
||||
|
||||
class TestJudge(unittest.TestCase):
|
||||
def test_update_ungated(self):
|
||||
v = judge_one(job(), census(), scout())
|
||||
self.assertEqual(v["bucket"], "update")
|
||||
self.assertEqual(v["fetch_url"], scout()["url"])
|
||||
|
||||
def test_current_when_installed_newer_or_equal(self):
|
||||
v = judge_one(job(), census(installed_version="1.1"), scout())
|
||||
self.assertEqual(v["bucket"], "current")
|
||||
|
||||
def test_gated_queue_and_complete_bump(self):
|
||||
v = judge_one(job(), census(), scout(gate="gated", url="https://foo.itch.io/x"))
|
||||
self.assertEqual(v["bucket"], "gated_queue")
|
||||
self.assertEqual(v["bump_status"], "Complete")
|
||||
self.assertIsNone(v["fetch_url"])
|
||||
|
||||
def test_watchlist_promote_and_report(self):
|
||||
p = judge_one(job(watchlist=True), census(), scout(upstream_status="Complete"))
|
||||
self.assertEqual(p["bucket"], "watchlist_promote")
|
||||
self.assertTrue(p["remove_from_watchlist"])
|
||||
r = judge_one(job(watchlist=True), census(), scout(upstream_status="Beta"))
|
||||
self.assertEqual(r["bucket"], "watchlist_report")
|
||||
self.assertFalse(r["remove_from_watchlist"])
|
||||
|
||||
def test_watchlist_complete_but_gated_is_queue(self):
|
||||
v = judge_one(job(watchlist=True), census(), scout(gate="gated", url="https://foo.itch.io/x"))
|
||||
self.assertEqual(v["bucket"], "gated_queue")
|
||||
|
||||
def test_no_latest_and_incomparable(self):
|
||||
self.assertEqual(judge_one(job(), census(), scout(latest_english_version=None))["bucket"], "current")
|
||||
self.assertEqual(judge_one(job(), census(installed_version="Final"), scout())["bucket"], "incomparable")
|
||||
|
||||
def test_unknown_installed_hash_match(self):
|
||||
v = judge_one(job(), census(installed_version=None, source="unknown", sha256="dead"),
|
||||
scout(sha256="dead"))
|
||||
self.assertEqual(v["bucket"], "current")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,43 @@
|
||||
import os, sys, tempfile, unittest
|
||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
sys.path.insert(0, os.path.join(ROOT, "scripts"))
|
||||
from update_swarm.librarian import patch_note, require_platform_id, romm_scan_argv, superseded_name
|
||||
|
||||
class TestLibrarian(unittest.TestCase):
|
||||
def test_superseded_name(self):
|
||||
self.assertEqual(
|
||||
superseded_name("Pokemon - Z [Hack].zip", "v2.16 ES"),
|
||||
"Pokemon - Z [Hack] (v2.16 ES).zip",
|
||||
)
|
||||
|
||||
def test_romm_requires_platform_ids(self):
|
||||
argv = romm_scan_argv([72, 200])
|
||||
joined = " ".join(argv)
|
||||
self.assertIn("platform_ids=[72,200]", joined.replace(" ", ""))
|
||||
with self.assertRaises(ValueError):
|
||||
romm_scan_argv([])
|
||||
self.assertEqual(require_platform_id("GBA"), 72)
|
||||
self.assertEqual(require_platform_id("PC"), 200)
|
||||
with self.assertRaises(KeyError):
|
||||
require_platform_id("GameCube")
|
||||
|
||||
def test_patch_note_version_and_history(self):
|
||||
src = (
|
||||
"---\n"
|
||||
'title: "Pokémon Z"\n'
|
||||
'version: "2.17"\n'
|
||||
"status: Complete\n"
|
||||
"---\n\n"
|
||||
"## Summary\n\nKeep me.\n"
|
||||
)
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
path = os.path.join(td, "Z.md")
|
||||
open(path, "w", encoding="utf-8").write(src)
|
||||
text = patch_note(path, "v2.13 (EN)", "2026-03-30", "https://example.com/z", "- EN 2.13\n", None)
|
||||
self.assertIn('version: "v2.13 (EN)"', text)
|
||||
self.assertIn("## Version history", text)
|
||||
self.assertIn("## Summary\n\nKeep me.", text)
|
||||
self.assertNotIn("**bold**", text.split("## Summary")[1].split("##")[0])
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -20,6 +20,13 @@ class TestCompare(unittest.TestCase):
|
||||
self.assertEqual(compare_versions("Final", "1.2"), "incomparable")
|
||||
self.assertEqual(compare_versions("2026-03-30", "Nightly"), "incomparable")
|
||||
|
||||
def test_dates_are_incomparable(self):
|
||||
self.assertEqual(compare_versions("2026-03-30", "2026-04-01"), "incomparable")
|
||||
self.assertEqual(compare_versions("2026-03-30", "1.2"), "incomparable")
|
||||
|
||||
def test_hotfix_suffix_is_incomparable(self):
|
||||
self.assertEqual(compare_versions("1.0.2 Hotfix", "1.0.2"), "incomparable")
|
||||
|
||||
def test_equal_non_numeric_after_normalize(self):
|
||||
self.assertEqual(compare_versions("Final", "final"), "eq")
|
||||
|
||||
|
||||
+111
-39
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"generated": "2026-08-14",
|
||||
"count": 411,
|
||||
"generated": "2026-10-31",
|
||||
"count": 412,
|
||||
"facets": {
|
||||
"platform": {
|
||||
"GBA": 205,
|
||||
"GBA": 206,
|
||||
"PC": 86,
|
||||
"NDS": 52,
|
||||
"GBC": 37,
|
||||
@@ -16,7 +16,7 @@
|
||||
},
|
||||
"base": {
|
||||
"FireRed": 101,
|
||||
"Emerald": 88,
|
||||
"Emerald": 89,
|
||||
"RPG Maker XP / Pokemon Essentials": 83,
|
||||
"Crystal": 27,
|
||||
"Ruby": 10,
|
||||
@@ -67,13 +67,13 @@
|
||||
"Ultra Sun": 1
|
||||
},
|
||||
"status": {
|
||||
"Complete": 348,
|
||||
"Complete": 349,
|
||||
"Beta": 32,
|
||||
"Ongoing": 30,
|
||||
"Complete (beta)": 1
|
||||
},
|
||||
"engine": {
|
||||
"pokeemerald-expansion": 8,
|
||||
"pokeemerald-expansion": 9,
|
||||
"pokeemerald-expansion (likely)": 6,
|
||||
"CFRU + DPE": 3,
|
||||
"CFRU + DPE (likely)": 2,
|
||||
@@ -85,8 +85,8 @@
|
||||
"pokeemerald (decomp, likely)": 1
|
||||
},
|
||||
"type": {
|
||||
"New Experience": 179,
|
||||
"Expansion": 169,
|
||||
"New Experience": 180,
|
||||
"Expansion": 170,
|
||||
"Difficulty": 127,
|
||||
"QoL": 97,
|
||||
"Vanilla+": 30,
|
||||
@@ -96,7 +96,7 @@
|
||||
"Crossover": 2
|
||||
},
|
||||
"play_status": {
|
||||
"Unplayed": 399,
|
||||
"Unplayed": 400,
|
||||
"Completed": 7,
|
||||
"Backlog": 3,
|
||||
"Dropped": 1,
|
||||
@@ -106,7 +106,7 @@
|
||||
"image_base": "https://romhacks-files.ginnoir.com",
|
||||
"hacks": [
|
||||
{
|
||||
"stem": "A FarfetchΓÇÖD Story",
|
||||
"stem": "A Farfetch’D Story",
|
||||
"title": "Pokémon A Farfetch’D Story",
|
||||
"platform": "PC",
|
||||
"base": "RPG Maker XP / Pokemon Essentials",
|
||||
@@ -165,7 +165,7 @@
|
||||
"title": "Pokémon A Star in the Desert",
|
||||
"platform": "PC",
|
||||
"base": "RPG Maker XP / Pokemon Studio / SDK",
|
||||
"version": "1.2",
|
||||
"version": "1.4",
|
||||
"status": "Complete",
|
||||
"generation": "Joiplay/RPGXP",
|
||||
"fakemon": "No",
|
||||
@@ -287,14 +287,14 @@
|
||||
"title": "Pokémon Acceptance",
|
||||
"platform": "PC",
|
||||
"base": "RPG Maker XP / Pokemon Essentials",
|
||||
"version": "4.0",
|
||||
"version": "4.2",
|
||||
"status": "Complete",
|
||||
"generation": "Joiplay/RPGXP",
|
||||
"fakemon": "No",
|
||||
"developer": "Tpick",
|
||||
"release_date": "2020",
|
||||
"banner": "https://romhacks-files.ginnoir.com/_meta/Pokemon_Acceptance/IMG_9441-980e54cad6d5e40a.png",
|
||||
"source": "https://www.pokecommunity.com/threads/pok%C3%A9mon-acceptance.378280/",
|
||||
"source": "https://eeveeexpo.com/threads/4889/",
|
||||
"library_path": "roms/windows/Pokemon - Acceptance [Hack].zip",
|
||||
"play_status": "Unplayed",
|
||||
"scrape_dir": "Pokemon_Acceptance",
|
||||
@@ -1412,7 +1412,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"stem": "A├▒il",
|
||||
"stem": "Añil",
|
||||
"title": "Pokémon Añil",
|
||||
"platform": "PC",
|
||||
"base": "RPG Maker XP / Pokemon Essentials",
|
||||
@@ -1726,7 +1726,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"stem": "BirchΓÇÖs Folly",
|
||||
"stem": "Birch’s Folly",
|
||||
"title": "Pokémon Birch’s Folly",
|
||||
"platform": "PC",
|
||||
"base": "RPG Maker XP / Pokemon Essentials",
|
||||
@@ -6513,7 +6513,7 @@
|
||||
"title": "Pokémon Eon Guardians",
|
||||
"platform": "PC",
|
||||
"base": "RPG Maker XP / Pokemon Essentials",
|
||||
"version": "2.0.9",
|
||||
"version": "2.0.26",
|
||||
"status": "Complete",
|
||||
"generation": "Gen IV",
|
||||
"fakemon": "No",
|
||||
@@ -7864,8 +7864,8 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"stem": "Fused Dimensions",
|
||||
"title": "Pokémon Fused Dimensions",
|
||||
"stem": "Fused Dimensions",
|
||||
"title": "Pokémon Fused Dimensions",
|
||||
"platform": "GBA",
|
||||
"base": "FireRed",
|
||||
"version": null,
|
||||
@@ -8112,7 +8112,7 @@
|
||||
"title": "Pokémon Gadir Deluxe",
|
||||
"platform": "PC",
|
||||
"base": "RPG Maker XP / Pokemon Essentials",
|
||||
"version": null,
|
||||
"version": "1.3.1",
|
||||
"status": "Complete",
|
||||
"generation": "Joiplay/RPGXP",
|
||||
"fakemon": "Yes",
|
||||
@@ -8938,7 +8938,7 @@
|
||||
"title": "Pokémon HGSS Sevii",
|
||||
"platform": "PC",
|
||||
"base": "RPG Maker XP / Pokemon Essentials",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.0",
|
||||
"status": "Complete",
|
||||
"generation": "Gen IV",
|
||||
"fakemon": "No",
|
||||
@@ -9255,7 +9255,7 @@
|
||||
"title": "Pokémon Hero Legacy",
|
||||
"platform": "PC",
|
||||
"base": "RPG Maker XP / Pokemon Essentials",
|
||||
"version": "3.0.7",
|
||||
"version": "3.0.8",
|
||||
"status": "Complete",
|
||||
"generation": "Gen 1–8",
|
||||
"fakemon": "No",
|
||||
@@ -9263,7 +9263,7 @@
|
||||
"release_date": "2025",
|
||||
"banner": "https://pokehostel.com/wp-content/uploads/2025/11/Pokemon-Hero-Legacy.png",
|
||||
"source": "https://www.pokecommunity.com/threads/pok%C3%A9mon-hero-legacy-eng-de-now-with-new-game-mode.538518/",
|
||||
"library_path": "roms/windows/Pokemon - Hero Legacy (Hack).zip",
|
||||
"library_path": "roms/windows/Pokemon - Hero Legacy [Hack].zip",
|
||||
"play_status": "Unplayed",
|
||||
"generations": [
|
||||
"Gen I",
|
||||
@@ -10090,13 +10090,14 @@
|
||||
"title": "Pokémon Infinity",
|
||||
"platform": "PC",
|
||||
"base": "RPG Maker XP / Pokemon Essentials",
|
||||
"version": "3.3.1",
|
||||
"version": "3.3.4",
|
||||
"status": "Complete",
|
||||
"fakemon": "Yes",
|
||||
"release_date": "2026-07-07",
|
||||
"banner": "https://www.pokeharbor.com/wp-content/uploads/2025/02/7DRXXBq.gif",
|
||||
"homepage": "https://pokemoninfinity.miraheze.org/wiki/Pokemon_Infinity_Wiki",
|
||||
"source": "https://p-infinity.fandom.com/wiki/Pokemon_Infinity_Wiki",
|
||||
"library_path": "roms/windows/Pokemon - Infinity 3.3.1 (Hack).zip",
|
||||
"source": "https://pokemoninfinity.miraheze.org/wiki/Pokemon_Infinity_Wiki",
|
||||
"library_path": "roms/windows/Pokemon - Infinity [Hack].zip",
|
||||
"play_status": "Playing",
|
||||
"scrape_dir": "Pokemon_Infinity",
|
||||
"generations": [
|
||||
@@ -10125,17 +10126,17 @@
|
||||
"Large custom Pokédex and RPG Maker XP fan-game structure."
|
||||
],
|
||||
"links": [
|
||||
{
|
||||
"label": "Link",
|
||||
"url": "https://1fichier.com/?n6v1eej3pipn1ts9sx69&af=2885774"
|
||||
},
|
||||
{
|
||||
"label": "Link",
|
||||
"url": "https://p-infinity.fandom.com/wiki/Pokemon_Infinity_Wiki"
|
||||
},
|
||||
{
|
||||
"label": "Miraheze wiki",
|
||||
"url": "https://pokemoninfinity.miraheze.org/wiki/Pokemon_Infinity_Wiki"
|
||||
},
|
||||
{
|
||||
"label": "MediaFire current English build",
|
||||
"url": "https://www.mediafire.com/file/hp0wuz6vx1abyst/Infinity+3.3.4.zip/file"
|
||||
},
|
||||
{
|
||||
"label": "Fandom wiki",
|
||||
"url": "https://p-infinity.fandom.com/wiki/Pokemon_Infinity_Wiki"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -10418,7 +10419,7 @@
|
||||
"title": "Pokémon Jam Festival",
|
||||
"platform": "PC",
|
||||
"base": "RPG Maker XP / Pokemon Essentials",
|
||||
"version": "1.0",
|
||||
"version": "1.4",
|
||||
"status": "Complete",
|
||||
"generation": "Gen III",
|
||||
"fakemon": "Yes",
|
||||
@@ -11409,7 +11410,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"stem": "LetΓÇÖs Beat Mew",
|
||||
"stem": "Let’s Beat Mew",
|
||||
"title": "Pokémon Let’s Beat Mew",
|
||||
"platform": "GBA",
|
||||
"base": "FireRed",
|
||||
@@ -12459,6 +12460,77 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"stem": "Monomyth",
|
||||
"title": "Pokémon Monomyth",
|
||||
"platform": "GBA",
|
||||
"base": "Emerald",
|
||||
"version": "1.0",
|
||||
"status": "Complete",
|
||||
"generation": "Athanto",
|
||||
"fakemon": "Yes",
|
||||
"developer": "Team Monomyth",
|
||||
"release_date": "2026-10-30",
|
||||
"banner": "https://cdn.monomyth.jp/assets/promo.png",
|
||||
"homepage": "https://monomyth.jp/",
|
||||
"source": "https://monomyth.jp/download",
|
||||
"library_path": "roms/gba/Pokemon - Monomyth [Hack].gba",
|
||||
"play_status": "Unplayed",
|
||||
"engine": "pokeemerald-expansion",
|
||||
"generations": [
|
||||
"Gen I",
|
||||
"Gen II",
|
||||
"Gen III",
|
||||
"Fakemon"
|
||||
],
|
||||
"type": [
|
||||
"New Experience",
|
||||
"Expansion"
|
||||
],
|
||||
"tags": [
|
||||
"hack",
|
||||
"platform/gba",
|
||||
"base/emerald",
|
||||
"status/complete",
|
||||
"type/newexperience",
|
||||
"type/expansion"
|
||||
],
|
||||
"summary": "Monomyth is Team Monomyth's original, character-driven Emerald hack, built over more than six years and released complete at version 1.0 on 30 October 2026. It drops the official games entirely in favour of the Athanto Region, a wilderness-heavy setting where the emphasis falls on exploration, storytelling and a deliberately dangerous overworld — the team's own framing is that finding civilisation again before sunset is not always a guarantee. It ships with a dex of over 360 brand new and returning Pokémon, a 200-plus track original soundtrack, and a full suite of Gen III side content, and it is designed to run on real Game Boy Advance and Game Boy Micro hardware rather than emulator-only.",
|
||||
"notability": "A fan project of unusual scale and finish: six-plus years of development by a credited team of well over a hundred contributors, with its own Pokémon designs, portrait art, animation work from an outside studio, and an original score. The Fakemon design work in particular has drawn attention from players who normally avoid original species in hacks. It is also one of the few hacks of this size that is complete at launch rather than released in episodic betas.",
|
||||
"story": "An original story set in the Athanto Region, a largely untamed land whose wilds are teeming with dangerous Pokémon. The player is a traveller answering a call to adventure across sprawling environments that hide a great many secrets, with dozens of sidequests layered over the main route and a substantial postgame act.",
|
||||
"features": [
|
||||
"Over 360 brand new and returning Pokémon, with new moves, abilities and battle animations.",
|
||||
"An entirely new region, Athanto, with sprawling environments, dense secrets and dozens of sidequests.",
|
||||
"200+ track original soundtrack from a dedicated sound team.",
|
||||
"Thousands of wild Pokémon coat variations — per-encounter palette variety beyond the usual shiny system.",
|
||||
"Contest Halls, Trainer Hill and the Battle Frontier all return as side content.",
|
||||
"Asynchronous multiplayer features plus Link Cable trading, with code-based trading offered as a workaround for the GBA's local-only link.",
|
||||
"Playable on original Game Boy Advance and Game Boy Micro hardware, not just emulators.",
|
||||
"Built on pret's pokeemerald decomp with DizzyEggg's Emerald Expansion."
|
||||
],
|
||||
"links": [
|
||||
{
|
||||
"label": "Official site",
|
||||
"url": "https://monomyth.jp/"
|
||||
},
|
||||
{
|
||||
"label": "Download and in browser patcher",
|
||||
"url": "https://monomyth.jp/download"
|
||||
},
|
||||
{
|
||||
"label": "FAQ and development blog",
|
||||
"url": "https://monomyth.jp/blog/"
|
||||
},
|
||||
{
|
||||
"label": "Credits and distribution terms",
|
||||
"url": "https://monomyth.jp/about"
|
||||
},
|
||||
{
|
||||
"label": "GBAtemp launch thread",
|
||||
"url": "https://gbatemp.net/threads/highly-anticipated-rom-hack-pokemon-monomyth-is-now-available.686007/"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"stem": "Moon Black 2",
|
||||
"title": "Pokémon Moon Black 2",
|
||||
@@ -13332,7 +13404,7 @@
|
||||
"title": "Pokémon Nebula 1",
|
||||
"platform": "PC",
|
||||
"base": "RPG Maker XP / Pokemon Essentials",
|
||||
"version": "v1.3.7",
|
||||
"version": "1.4",
|
||||
"status": "Complete",
|
||||
"generation": "Joiplay/RPGXP",
|
||||
"fakemon": "No",
|
||||
@@ -13480,7 +13552,7 @@
|
||||
"title": "Pokémon Nebula 3",
|
||||
"platform": "PC",
|
||||
"base": "RPG Maker XP / Pokemon Essentials",
|
||||
"version": "v1.1.3",
|
||||
"version": "1.1.5",
|
||||
"status": "Complete",
|
||||
"generation": "Joiplay/RPGXP",
|
||||
"fakemon": "No",
|
||||
@@ -16627,7 +16699,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"stem": "Recharged Yellow (previously known as Pokémon Yellow Cross)",
|
||||
"stem": "Recharged Yellow (previously known as Pokémon Yellow Cross)",
|
||||
"title": "Pokémon Recharged Yellow (previously known as Pokémon Yellow Cross)",
|
||||
"platform": "GBA",
|
||||
"base": "Emerald",
|
||||
@@ -24096,7 +24168,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"stem": "Yu-Gi-Oh PokéDuel",
|
||||
"stem": "Yu-Gi-Oh PokéDuel",
|
||||
"title": "Pokémon Yu-Gi-Oh PokéDuel",
|
||||
"platform": "GBA",
|
||||
"base": "FireRed",
|
||||
|
||||
Reference in new issue
Block a user