Commit Graph
354 Commits
Author SHA1 Message Date
Abdessamad Derraz 12b00e024b refactor: read retropie module fields in one place
rp_registerModule sources the script: the id, section, flags and repo
are top-level assignments, the last one wins. The platform, target,
launcher, rom folder and export readers each kept their own pattern;
they now share module_fields. Same ids and flags over the 287
scriptmodules at 427e7621.
2026-11-21 16:43:46 +01:00
Abdessamad Derraz 24463647f6 fix: refresh buildbot updates from its registry
check_buildbot_system --update ran scripts/refresh_data_dirs.py by a
relative path and without --registry: the refresh read the default
registry, and outside the repository root the child was not found and
every updated entry was reported failed. The command now refreshes in
process through packs.datadirs.refresh_keys with the registry it
checked; buildbot_system keeps the check and its selectors.
2026-11-21 16:43:46 +01:00
Abdessamad Derraz e6295aba88 refactor: move es_systems readers out of batocera
es_systems.yml readers move to scraper/es_systems.py, which the board
target scraper imports at load time instead of inside a function to dodge
the cycle. The _default.remove_cores list is target override data: it is
model.targets.not_cores, no longer a private name of batocera_scraper.
2026-11-21 16:43:46 +01:00
Abdessamad Derraz 036a6ebf29 refactor: reuse the shared helpers left copied
Copies of helpers the first pass created, replaced by the helper:
- source_yaml_file for our YAML sources (generate_db read them in the
  locale's encoding, a syntax error named no file);
- data_dir_registry_at in registry_bundles, platform_registry_at (new,
  beside load_platform_registry) in the manifest;
- DATA_DIRS_FILE for the registry path five modules spelled;
- load_optional_database, sha1_at, VERSIONS_FILE, installer_module;
- DerivedView where a cache was keyed by id() of a dict;
- count_text and series where a plural or a list was written by hand.
2026-11-21 10:31:29 +01:00
Abdessamad Derraz 74fcdd2bc5 refactor: read archive members in one place
core.ziptools.zip_members lists the name, size and crc32 of each member once per archive revision. The site lookup and cards, the gap report, the pack check, the romset importer, the recipe identification and build, provenance, derivations and the atom pool read it instead of opening each archive again.

Each reader also tested a .zip suffix and skipped the .variants/ copies (x.zip.1a2b3c4d): the site lookup listed no member of a copy, the gap report's member index never saw one, the pack check never compared a copy's members, and the pack builders copied a copy without its CRC test. They now use is_archive_path. The inner ROM index of the resolver reads copies too, and a copy answers only for a member no primary holds.
2026-11-21 10:30:40 +01:00
Abdessamad Derraz 4acfd8f763 refactor: read mame release tags in the model
The tag and version helpers lived in the romset DAT importer, so the site cards, which may not import a scraper, matched the label with their own pattern. model.mamerelease now owns mame_tag, mame_version and tag_version. Both scrapers and the cards call it. check_freshness only lifts tags out of labels and converts nothing, so it keeps its own search.
2026-11-21 10:30:22 +01:00
Abdessamad Derraz 8a8fa71fbc refactor: route network access through upstream
Branch heads (scrapers, FBNeo import, data directories) resolve through
core.upstream.resolve_head, with cache_dir=None to keep nothing under
.cache/upstream. Streaming downloads (large files, external pack files,
data directory archives, scraper downloads, standalone probe) go through
one core.upstream.download: scratch then rename, size cap, retries of a
cut stream, a 5xx or a rate limit. The shared rate limit wait reads
GoatCounter's X-Rate-Limit-Reset, so site insights, download.py,
indexnow and the contributor list use the same retrying client.

list_gitlinks raises TruncatedListingError on a partial tree, read
from one tree walk shared with list_tree (Forgejo paging included).
The Recalbox configs/ listing is paged with the shared page cap.
2026-11-21 10:30:13 +01:00
Abdessamad Derraz bac3070228 fix: register every romfolders format 2026-11-21 06:45:11 +01:00
Abdessamad Derraz 30cd881ef3 refactor: convert mame tags and versions once 2026-11-21 06:02:01 +01:00
Abdessamad Derraz f8003e90c8 refactor: share first-boot config evidence 2026-11-21 06:02:01 +01:00
Abdessamad Derraz abbe267fb8 refactor: read game dats through logiqx_parser 2026-11-21 06:02:01 +01:00
Abdessamad Derraz fd0f6c7798 refactor: share the git blob check of downloads 2026-11-21 06:02:01 +01:00
Abdessamad Derraz 8d58a9edfd refactor: read dat packs through one helper 2026-11-21 06:01:53 +01:00
Abdessamad Derraz e16caf57b4 refactor: read c comments and calls through clex 2026-11-21 06:01:53 +01:00
Abdessamad Derraz 9f8ac141c1 refactor: share the hash scrapers' sparse clone 2026-11-21 06:01:53 +01:00
Abdessamad Derraz 91fe93c5a2 fix: read --db through load_database in importers 2026-11-21 06:01:53 +01:00
Abdessamad Derraz 0f602d5914 fix: give retropie modules the platform name flag 2026-11-21 06:01:53 +01:00
Abdessamad Derraz b80fc1919d refactor: read es-de commands through romfolders 2026-11-21 06:01:53 +01:00
Abdessamad Derraz 0548d3d823 refactor: group every scraper's systems one way 2026-11-21 06:01:53 +01:00
Abdessamad Derraz f245c210e0 refactor: read retrobat es_systems.cfg once 2026-11-21 06:01:53 +01:00
Abdessamad Derraz 3eb6bd81a1 refactor: read rocknix-systems as a checkBios list 2026-11-21 06:01:53 +01:00
Abdessamad Derraz c4d3506cf9 fix: read c# comments through one lexer 2026-11-21 06:01:53 +01:00
Abdessamad Derraz 2665e30bdf fix: stop the emudeck scrape on an unread sheet 2026-11-21 06:01:53 +01:00
Abdessamad Derraz 79c3c02885 fix: target scrapers exit on errors like scrapers 2026-11-21 06:01:53 +01:00
Abdessamad Derraz 39e6d57fcb refactor: walk gitlab trees in one place
core.upstream.gitlab_tree_entries serves _gitlab_tree, list_gitlinks
and the romfolders listing. The Recalbox systems listing becomes
Scraper.system_folders, so the targets scraper gets the page cap and
refuses an empty listing instead of writing boards without cores.
2026-11-21 06:00:53 +01:00
Abdessamad Derraz 95ed63a3f3 refactor: one etag probe for buildbot and refresh
The buildbot check now waits 30 s like the refresh, not 15.
2026-11-21 06:00:31 +01:00
Abdessamad Derraz fdd7595a71 refactor: one retrying fetch loop in core.upstream
fetch_bytes and fetch_body now share open_retrying and read_limited:
scrapers retry a 500 or a dropped connection like profile_sync, and
fetch_body caps the body it reads.
2026-11-21 06:00:20 +01:00
Abdessamad Derraz 67cb99606d refactor: read data dirs and inherits in one place 2026-11-21 05:59:51 +01:00
Abdessamad Derraz 7be8a7cd7b fix: stop on one line when pyyaml is missing 2026-11-21 05:59:51 +01:00
Abdessamad Derraz 35f335d001 refactor: read target overrides through one reader 2026-11-21 05:59:51 +01:00
Abdessamad Derraz 0bf9b04bc0 refactor: read rocknix-systems like batocera
parse_systems read the systems dict with regular expressions beside extract_systems_dict. It now uses the shared reader: on the cached rocknix-systems both give the same 14 systems and entries.
2026-11-20 20:05:47 +01:00
Abdessamad Derraz 1b0389f6ca refactor: share line spans with the shell readers
csharp_source formats a source_ref through shell_launchers.merge_lines
and finds lines through core.lines.LineIndex. Its span merge joined the
same one-line gaps, so retrobat.yml refs are unchanged.

retropie_launchers keeps its adjacent-only rule: merge_lines would
rewrite lr-prboom.sh:86, 88 in four committed retropie.yml records.
2026-11-20 20:03:20 +01:00
Abdessamad Derraz facebef9e5 refactor: index source lines once per file
core.lines.LineIndex answers the line of an offset by binary search.
mame_parser and fbneo_parser counted the newlines before each match,
O(n) per set, and csharp_source kept its own copy of the index.

arcade_parent_importer reads a profile's repository slug through
core.upstream.parse_repo and refuses a source that is not on GitHub,
the only forge its fetches reach.
2026-11-20 20:03:20 +01:00
Abdessamad Derraz 0332f6149a refactor: read RetroPie scripts from one tarball
script_members in retropie_scraper yields every shell script of a
RetroPie-Setup tarball. The platform scraper, the exporter and the target
scraper read the scripts through it. The target scraper fetched one
contents listing per section and about 200 raw files; it now reads the
tarball of the pinned revision in one request. On the cached tarball the
three produce the same module ids, scripts, BIOS-bearing scripts and
targets as before. The targets file keeps its source URL.
2026-11-20 20:03:09 +01:00
Abdessamad Derraz f7c08a6ca3 refactor: read md5 lists through parse_hash_list
The RetroDECK and Recalbox exporters compare md5 lists with
resolve.reconcile.hash_values, and the RetroDECK scraper reads an entry's
md5 with md5_field and parse_hash_list instead of its own copy.

Recalbox's comparison no longer keeps an empty item: md5="a,,b" states
a,b where it stated ,a,b. The RetroDECK scraper now splits a
comma-joined value and refuses an md5 that is neither a string nor a
list of strings, as the batocera-systems readers do. The ten cached
component manifests write neither form, so retrodeck.yml is unchanged.
2026-11-20 20:02:44 +01:00
Abdessamad Derraz e19025231e refactor: locate the systems dict once
systems_span in batocera_scraper finds the systems literal of a
batocera-systems script by reading strings of either quote and
comments, and accepts systems = OrderedDict({. The exporter cuts the
script at those braces and reads comments with the same comment_start,
in place of its line prefix rule, its ast fallback and a comment test
that only knew double quotes. Both give the same cut on the cached
Batocera, AmberELEC, EmuELEC, KNULLI and ROCKNIX scripts.

An unclosed dict is refused by name instead of failing in literal_eval.
2026-11-20 20:02:44 +01:00
Abdessamad Derraz db1446079a refactor: read listxml through one streamer
scripts/scraper/listxml.py holds the element window, attribute
reader, ROM member extraction and open_listxml that romset_dat_importer,
mame_devices and arcade_parent_importer each wrote. On mame0289lx.zip
and the 19 FBNeo DATs the three produce the same recipes, release and
sets as before.

Attribute values are entity-decoded everywhere: romset_dat_importer
kept f&m.basic.bin where the archive member is f&m.basic.bin. The
five comx_eb member names of recipes/mame.json are corrected to what a
re-import now writes. A release zip with no or several .xml members is
refused by name instead of raising StopIteration.
2026-11-20 20:02:44 +01:00
Abdessamad Derraz 3505eaa835 refactor: walk es_systems.yml once
es_systems_entries yields (system, emulator, core, spec) and the four
batocera_scraper readers and the target scraper's package map are built
on it. Output is identical on batocera-43.1's es_systems.yml.

The target scraper now raises on a file that is not a mapping or does not
parse, where it returned an empty map and failed later on 0 mappings.
2026-11-20 20:02:30 +01:00
Abdessamad Derraz f61c2cb7d4 refactor: one network layer for the scrapers
Each network job had several copies. One is kept per job and
every caller uses it.

- Source revision: model.sourcerevision (source_revision, required_revision,
  platform_revision) replaces BaseTargetScraper's pattern list, the
  exporter's _REVISION, the four launcher_revision copies and RetroBat's
  own YAML reader. It reads the union of the shapes: GitHub raw, blob and
  tree with or without a path after the revision, GitLab raw, blob, tree
  and archive, codeload tar.gz and zip. The target scrapers now answer
  for RetroDECK, NextUI, MinUI and MyMinUI, whose tree URLs end at the
  commit, and the exporter reads GitLab blob and tree and codeload zip.
  EmuDeck and RetroBat still require a 40-hex commit, and each launcher
  reader requires its own repository in the URL.
- Latest release: fetch_github_latest_version, type-checked, is the only
  lookup. mame_hash_scraper, romset_dat_importer and the Lakka target
  scraper call it. romset_dat_importer's NoReleaseError is gone: a
  release without a tag raises RuntimeError.
- Tree listing: github_tree and tree_entries refuse a truncated or
  unreadable listing. The libretro and core-info scrapers share
  core_info_files and fetch_info_file, with libretro's refusal of an empty
  listing. The core-info listing and the RetroDECK, ROCKNIX launcher and
  libretro listings were not checked for truncation before.
- GET: fetch_bytes is the one request path. fetch_text, fetch_present
  (None on 404 only), github_json and download are built on it, so every
  read retries 429 and 5xx, caps the body and raises FetchError, a
  ConnectionError carrying the HTTP status. The target scrapers' own
  fetch_text raised RuntimeError: they now raise FetchError, and an
  optional Batocera board include is skipped on 404 only, not on any
  failure. The exporter's originals, MiSTer, RetroPie, redump and the
  buildbot index go through it too.
- Headers: core.upstream.forge_headers is the one builder. The token goes
  to api.github.com and raw.githubusercontent.com, the host compared
  whole, as Bearer. A URL that only names api.github.com in its query
  got the scrapers' token before, and profile_sync sent its token to
  github.com, whose release downloads redirect to asset storage with the
  header. Scraper reads of raw files now carry the token.
- Submodule commit: submodule_commit checks that the path is a
  submodule. Batocera's target scraper accepted any contents answer with
  a sha, a directory's tree sha included.
- Download: download streams through a scratch file renamed into place,
  retries like fetch_bytes, can keep an existing file and returns the
  Content-Disposition. It replaces the _download of romset_dat_importer
  and game_dat_importer.
2026-11-20 20:02:15 +01:00
Abdessamad Derraz 7cd499531d refactor: share scraper and launcher helpers
BaseScraper reads JSON once (_fetch_json, json_object), every scraper files its requirements through systems_from_requirements, and the batocera-systems readers (Batocera, KNULLI, AmberELEC, EmuELEC) inherit CheckBiosScraper. Launcher modules share one Launcher record, one LauncherPatternMissing and one link_record. DAT importers build provenance entries from LogiqxDat.
2026-11-20 18:28:33 +01:00
Abdessamad Derraz 9ac3145c5e refactor: commands read the repository root 2026-11-18 23:14:52 +01:00
Abdessamad Derraz 3853ca2f1c refactor: public names for cross-module reads 2026-11-18 22:59:51 +01:00
Abdessamad Derraz 238f70c7a7 refactor: one copy of each duplicated helper 2026-11-18 22:16:55 +01:00
Abdessamad Derraz c4fdf12874 refactor: release, installer_build, devtools pkgs
The release tools, the installer build tools and the repository's
commit and PR checks keep their commands and move their code into
three packages. The release record readers move to model.releaserecord,
romfolders to model, the buildbot check to scraper. The site reads the
handheld launchers and the bootstrap pin from installer_build.
2026-11-18 20:44:12 +01:00
Abdessamad Derraz 92903eb4be refactor: split the C# reader from RetroBat's 2026-11-18 13:38:44 +01:00
Abdessamad Derraz 27333c154a refactor: hash the MAME pack with core.hashing 2026-11-18 13:38:44 +01:00
Abdessamad Derraz 738bb5bc07 refactor: share the target scrapers' fetch and CLI 2026-11-18 13:38:44 +01:00
Abdessamad Derraz 6f8b8dedb2 refactor: share the scrapers' fetch helpers 2026-11-18 13:38:44 +01:00
Abdessamad Derraz 8738179f42 refactor: move the region audit library down 2026-11-18 13:38:44 +01:00
Abdessamad Derraz a81c497e8d refactor: break the scraper import cycles 2026-11-18 13:38:34 +01:00