refactor: make the names pack modules share public

This commit is contained in:
Abdessamad Derraz committed 2026-11-24 06:17:48 +01:00
1 parent 6c48409912
commit c186a2acbd
11 files changed
+92 -92

No files matched your search

+21 -21
View File
@@ -175,13 +175,13 @@ def _builder_placement(
return shipped, occupied
def _dest_key(file_entry: dict, sys_id: str) -> str:
def dest_key(file_entry: dict, sys_id: str) -> str:
"""The path a declaration occupies, as the builder keys its pack."""
dest = declared_destination(file_entry)
return dest or f"{sys_id}/{file_entry.get('name', '')}"
def _twin_index(
def twin_index(
verify_systems: dict, db: dict, base_dest: str, zip_contents: dict,
) -> tuple[dict[str, int], dict[int, tuple[str, dict]]]:
"""Which declaration the pack ships at each destination, and every declaration by id."""
@@ -202,7 +202,7 @@ def _twin_index(
@dataclass(frozen=True)
class _DeclarationResolver:
class DeclarationResolver:
"""How a platform run resolves its declarations, as the builder does."""
db: dict
@@ -212,14 +212,14 @@ class _DeclarationResolver:
mode: str
platform_profiles: dict
# Which declaration the pack ships at each destination, and every
# declaration by id (_twin_index).
# declaration by id (twin_index).
preferred_entries: dict[str, int]
winners: dict[int, tuple[str, dict]]
base_dest: str
def _resolve_declaration(
file_entry: dict, sys_id: str, resolver: _DeclarationResolver,
file_entry: dict, sys_id: str, resolver: DeclarationResolver,
) -> tuple[str | None, str, str | None, dict]:
"""Resolve a declaration to the file the pack ships at its destination.
@@ -338,7 +338,7 @@ def _resolve_for_platform(
@dataclass(frozen=True)
class _PlatformRun:
class PlatformRun:
"""The inputs of one verify_platform run, read by each of its stages."""
config: dict
@@ -359,12 +359,12 @@ class _PlatformRun:
@dataclass
class _PlatformTally:
class PlatformTally:
"""Each declaration's verdict, and the verdicts aggregated by destination."""
run: _PlatformRun
run: PlatformRun
platform: str
resolver: _DeclarationResolver
resolver: DeclarationResolver
region_drops: set[str]
validation_index: dict
validation_owners: dict[str, list[tuple[str, str]]]
@@ -415,7 +415,7 @@ class _PlatformTally:
)[1] is None
):
self.packed_order.append((sys_id, self.run.full(destination), local_path))
self.shipped_keys.add(_dest_key(file_entry, sys_id))
self.shipped_keys.add(dest_key(file_entry, sys_id))
if _twin_unmet(
result, held_by, file_entry, sys_id, self.run.full(destination), holder,
):
@@ -445,7 +445,7 @@ class _PlatformTally:
# stayed out of pack_destinations and step 5 read the pack's
# copy as a file only the pack holds.
self.packed_order.append((sys_id, self.run.full(destination), local_path))
self.shipped_keys.add(_dest_key(file_entry, sys_id))
self.shipped_keys.add(dest_key(file_entry, sys_id))
return result, None
if stored is not None:
# The builder keeps the slot: instructions for a user_provided
@@ -490,7 +490,7 @@ class _PlatformTally:
# A declaration that finds nothing leaves the path to one that
# holds a file: the builder packs that file there, whatever the
# order the two are read in.
dest = _dest_key(file_entry, sys_id)
dest = dest_key(file_entry, sys_id)
self.results_at.setdefault(dest, []).append(result)
required = file_entry.get("required", True)
cur = result["status"]
@@ -530,7 +530,7 @@ class _PlatformTally:
for sys_id, system in self.run.config.get("systems", {}).items():
for file_entry in system.get("files", []):
if file_entry.get("group"):
dest = _dest_key(file_entry, sys_id)
dest = dest_key(file_entry, sys_id)
if dest in self.file_status:
members.setdefault((sys_id, file_entry["group"]), []).append(dest)
for dests in members.values():
@@ -610,7 +610,7 @@ def _required_declarations(verify_systems: dict) -> dict:
def _region_pass(
run: _PlatformRun, verify_systems: dict, pack_overrides: dict, regions: list[str],
run: PlatformRun, verify_systems: dict, pack_overrides: dict, regions: list[str],
) -> tuple[set[str], list[str], dict[tuple[str, str, str], str]]:
"""The destinations a region run withdraws, the groups no file answers,
and the destination of each core extra."""
@@ -652,7 +652,7 @@ def _region_pass(
def _narrowed(
run: _PlatformRun,
run: PlatformRun,
rows: list[dict],
region_drops: set[str],
region_extra_dests: dict[tuple[str, str, str], str],
@@ -678,7 +678,7 @@ def _narrowed(
def _platform_gaps(
run: _PlatformRun,
run: PlatformRun,
occupied: dict[str, str | None],
region_drops: set[str],
region_extra_dests: dict[tuple[str, str, str], str],
@@ -750,7 +750,7 @@ def _profile_coverage(
dest_to_name: dict[str, str] = {}
for sys_id, system in verify_systems.items():
for fe in system.get("files", []):
dest_to_name.setdefault(_dest_key(fe, sys_id), fe.get("name", ""))
dest_to_name.setdefault(dest_key(fe, sys_id), fe.get("name", ""))
with_validation = sum(
1 for dest in file_status if dest_to_name.get(dest, "") in gt_filenames
)
@@ -858,7 +858,7 @@ def verify_platform(
verify_systems = _required_declarations(verify_systems)
categories = EntryCategories(config, profiles, data_dir_registry)
run = _PlatformRun(
run = PlatformRun(
config, db, emulators_dir, emu_profiles, profiles, target_cores,
data_dir_registry, zip_contents, system_filter, required_only, mode, base_dest,
)
@@ -875,12 +875,12 @@ def verify_platform(
# one the builder prefers. The other declaration is scored against that
# file, as the frontend will score it after installation: RetroDECK's
# xroar component hashes bios/disk.rom and finds the PC-88 ROM.
preferred_entries, winners = _twin_index(
preferred_entries, winners = twin_index(
verify_systems, db, base_dest, zip_contents
)
tally = _PlatformTally(
tally = PlatformTally(
run, platform,
_DeclarationResolver(
DeclarationResolver(
db, zip_contents, data_dir_registry, slot_overrides, mode,
platform_profiles, preferred_entries, winners, base_dest,
),
+2 -2
View File
@@ -322,7 +322,7 @@ def entry_source(f: dict, index: dict) -> str | None:
return "bios" if held is not None else found
def _resolve_archive_source(
def resolve_archive_source(
archive_name: str,
by_name: dict[str, list],
by_name_lower: dict[str, str],
@@ -522,7 +522,7 @@ class _ProfileComparison:
f.get("mode", "both"),
)
if archive_key not in self.archive_gaps:
source = _resolve_archive_source(
source = resolve_archive_source(
archive, self.index["by_name"], self.index["by_name_lower"],
self.index["data_names"], self.index["by_path_suffix"],
)
+19 -19
View File
@@ -508,7 +508,7 @@ def _record_placed(
placed_local[full] = local
def _extra_dest(u: dict) -> str:
def extra_dest(u: dict) -> str:
"""Where a report entry lands before any platform prefix.
An archive entry goes by the archive's name, and a directory path takes
@@ -542,7 +542,7 @@ def unplaceable_extras(
if (not placement.slug_based and u.get("root") not in ("save", *OUTER_ROOTS)
and not u.get("unplaced")):
continue
dest = _extra_dest(u)
dest = extra_dest(u)
if not placement.places(u, dest):
key = (u.get("emulator", ""), u.get("name", ""), u.get("path") or "")
unplaced[key] = placement.unplaced_reason(u, dest)
@@ -586,7 +586,7 @@ class _ScanSeed:
folder: str
def _agnostic_scan_extras(
def agnostic_scan_extras(
profiles: dict,
relevant: set,
db: dict,
@@ -842,7 +842,7 @@ def _seed_extras(context: _ScanContext, seed: _ScanSeed) -> list[dict]:
if full_dest in context.seen_dests and (taken is None or full_dest not in taken):
continue
extra = _scan_extra(seed, scan_name, dest, sha1)
if _take(extra, full_dest, context.seen_dests, taken):
if take(extra, full_dest, context.seen_dests, taken):
extras.append(extra)
else:
# The image another core's scan placed is this core's
@@ -960,7 +960,7 @@ def expand_agnostic_entries(
layout = (entry.get("standalone_path") if standalone else None) or entry.get("path") or ""
return layout.rsplit("/", 1)[0] if "/" in layout else ""
scanned = _agnostic_scan_extras(
scanned = agnostic_scan_extras(
{emu_name: {**profile, "files": files}}, {emu_name}, db,
db.get("indexes", {}).get("by_name", {}), set(), "",
PlatformLaunches(standalone=frozenset({emu_name})) if standalone else PlatformLaunches(),
@@ -1049,7 +1049,7 @@ def _companion_extras(
"agnostic_scan": True,
}
extra["claim_order"] = (4, 0, emu_name)
if _take(extra, companion_full, seen_dests, taken):
if take(extra, companion_full, seen_dests, taken):
extras.append(extra)
return extras
@@ -1160,7 +1160,7 @@ def _files_by_directory(files_db: dict) -> dict[str, list[tuple[str, dict]]]:
return _DIRECTORY_INDEX[1]
def _archive_prefix_extras(
def archive_prefix_extras(
profiles: dict,
relevant: set,
covered_names: set,
@@ -1253,7 +1253,7 @@ def _archive_prefix_copies(
if archive_entry.get("system_dir"):
extra["system_dir"] = archive_entry["system_dir"]
extra["claim_order"] = (3, 0, emu_name)
if _take(extra, full_dest, seen_dests, taken):
if take(extra, full_dest, seen_dests, taken):
extras.append(extra)
return extras
@@ -1576,18 +1576,18 @@ def collect_emulator_extras(
))
extras.extend(
extra for extra in claims
if _take(extra, full_dest, state.seen_dests, state.taken)
if take(extra, full_dest, state.seen_dests, state.taken)
)
extras.extend(
_archive_prefix_extras(
archive_prefix_extras(
profiles, relevant, covered_names, state.seen_dests, extras_prefix,
by_name, state.taken, launches,
)
)
extras.extend(
_agnostic_scan_extras(
agnostic_scan_extras(
profiles, relevant, db, by_name, state.seen_dests, extras_prefix,
launches, state.taken,
)
@@ -1615,7 +1615,7 @@ def _place_report_entry(state: _FirstPass, u: dict) -> None:
# For archive entries, use the archive name for resolution
archive = u.get("archive")
name = archive if archive else u["name"]
dest = _extra_dest(u)
dest = extra_dest(u)
# Slug-based platforms: prefix dest with system slug. A file read
# below a save directory kept per system goes below each system.
@@ -1673,12 +1673,12 @@ def _claim_placement(
)
candidates.sort(key=lambda item: item["claim_order"])
extra, claims = candidates[0], candidates[1:]
if not _take(extra, full_dest, state.seen_dests, state.taken):
if not take(extra, full_dest, state.seen_dests, state.taken):
for claim in claims:
_another_claim(state.taken.get(full_dest), claim)
another_claim(state.taken.get(full_dest), claim)
return
for claim in claims:
_another_claim(extra, claim)
another_claim(extra, claim)
state.extras.append(extra)
@@ -1814,7 +1814,7 @@ class _ClaimRanks:
counts: dict[str, int] = {}
for u in undeclared:
placed = (
placement.places(u, _extra_dest(u))
placement.places(u, extra_dest(u))
if u.get("in_repo") and not u.get("bundled") else []
)
self._placed[id(u)] = placed
@@ -1998,13 +1998,13 @@ def _report_extra(u: dict, name: str, dest: str) -> dict:
return extra
def _take(
def take(
extra: dict, full_dest: str, seen_dests: set[str], taken: dict[str, dict] | None
) -> bool:
"""Whether an extra takes its destination. A taken one records the claim."""
if full_dest in seen_dests:
if taken is not None:
_another_claim(taken.get(full_dest), extra)
another_claim(taken.get(full_dest), extra)
return False
seen_dests.add(full_dest)
if taken is not None:
@@ -2012,7 +2012,7 @@ def _take(
return True
def _another_claim(extra: dict | None, claim: dict) -> None:
def another_claim(extra: dict | None, claim: dict) -> None:
"""Record a core that reads a destination another core's extra took.
The pack ships one file per destination, so the first claimant's extra
+6 -6
View File
@@ -112,7 +112,7 @@ def _settle_untracked(
return "untracked", file_name
def _same_members(pack: zipfile.ZipFile, name: str, source: str) -> bool:
def same_members(pack: zipfile.ZipFile, name: str, source: str) -> bool:
"""Whether a ZIP inside the pack holds the members of a ZIP on disk.
A rebuilt archive (TorrentZip) differs byte for byte and is the same
@@ -164,7 +164,7 @@ def _rebuilt_from(zf: zipfile.ZipFile, name: str, by_name: dict, files_db: dict)
_src_path = files_db[_src_sha1]["path"]
if not os.path.exists(_src_path):
continue
if _same_members(zf, name, _src_path):
if same_members(zf, name, _src_path):
return _bn
return None
@@ -200,7 +200,7 @@ def _cached_as(
return _bn
if (
name.endswith(".zip") and _dp.endswith(".zip")
and _same_members(zf, name, _dp)
and same_members(zf, name, _dp)
):
return _bn
return None
@@ -604,7 +604,7 @@ def _same_content(zf: zipfile.ZipFile, member: str, local: str) -> bool:
with open(local, "rb") as handle:
if zf.read(member) == handle.read():
return True
return is_archive_path(local) and _same_members(zf, member, local)
return is_archive_path(local) and same_members(zf, member, local)
class ConformanceOptions(TypedDict, total=False):
@@ -853,7 +853,7 @@ def _count_baseline(
return count
def _native_hash_errors(
def native_hash_errors(
zf: zipfile.ZipFile, decl_by_member: dict[str, list[dict]], config: dict, db: dict | None,
) -> list[str]:
"""The platform's native hash check replayed on the pack's bytes."""
@@ -1001,7 +1001,7 @@ def verify_pack_against_platform(
# 1. Baseline file presence + native hash check
baseline_groups, system_of = _baseline_groups(expect, view.is_flat)
baseline = _count_baseline(expect, view, baseline_groups, system_of, errors)
errors.extend(_native_hash_errors(zf, baseline.decl_by_member, expect.config, db))
errors.extend(native_hash_errors(zf, baseline.decl_by_member, expect.config, db))
core_checked, core_present = _check_core_extras(expect, view, baseline_groups, errors)
return (
+9 -9
View File
@@ -101,7 +101,7 @@ class ManifestOptions(InstallListOptions, total=False):
@dataclass(frozen=True)
class _ManifestSettings:
class ManifestSettings:
"""ManifestOptions with their defaults."""
emulators_dir: str = EMULATORS_DIR
@@ -123,7 +123,7 @@ class _ManifestSettings:
@dataclass
class _ManifestBuild:
class ManifestBuild:
"""One install manifest being listed: its files, omissions and the slots
they take, settled by the rules the pack builder follows."""
@@ -131,7 +131,7 @@ class _ManifestBuild:
platforms_dir: str
db: dict
bios_dir: str
opts: _ManifestSettings
opts: ManifestSettings
config: dict
emu_profiles: dict
zip_contents: dict
@@ -582,8 +582,8 @@ def _start_manifest(
db: dict,
bios_dir: str,
registry_path: str,
opts: _ManifestSettings,
) -> tuple[_ManifestBuild, dict]:
opts: ManifestSettings,
) -> tuple[ManifestBuild, dict]:
"""The manifest's configuration and scope, and the profiles before the
game data cut."""
config = load_platform_config(platform_name, platforms_dir)
@@ -610,7 +610,7 @@ def _start_manifest(
plat_registry = platform_registry_at(registry_path).get(platform_name) or {}
pack_systems = platform_scope_systems(config, emu_profiles, opts.target_cores)
build = _ManifestBuild(
build = ManifestBuild(
platform_name, platforms_dir, db, bios_dir, opts, config, emu_profiles,
zip_contents, data_registry, game_entries, plat_registry.get("install", {}),
str(REPO_ROOT), pack_systems,
@@ -625,7 +625,7 @@ def _start_manifest(
return build, full_profiles
def _settle_manifest_scope(build: _ManifestBuild) -> None:
def _settle_manifest_scope(build: ManifestBuild) -> None:
"""Game data destinations, slot choices and the region selection."""
opts, config, emu_profiles = build.opts, build.config, build.emu_profiles
# A destination is game data when every declaration of it is: a firmware
@@ -698,7 +698,7 @@ def generate_manifest(
does not hold to its cache folder: the caller reports it.
"""
reject_unknown("generate_manifest", options, ManifestOptions.__optional_keys__)
opts = _ManifestSettings(**options)
opts = ManifestSettings(**options)
build, full_profiles = _start_manifest(
platform_name, platforms_dir, db, bios_dir, registry_path, opts
)
@@ -779,7 +779,7 @@ def generate_install_list(
built under a case fold override, is no list install.py reads by default
and gets neither.
"""
settings = _ManifestSettings(**options)
settings = ManifestSettings(**options)
built: dict = {}
result = generate_manifest(platform_name, platforms_dir, db, bios_dir, registry_path,
build_out=built, **options)
+16 -16
View File
@@ -209,7 +209,7 @@ def _matches_an_alternative(fe: dict, local_path: str, profiles: dict) -> bool:
return False
def _left_out_lines(cut: GameDataCut, systems: set[str], cores: bool) -> list[str]:
def left_out_lines(cut: GameDataCut, systems: set[str], cores: bool) -> list[str]:
"""The game data a --no-game-data build left out, and why, one line each.
``systems`` limits the platform layer to the systems this pack covers,
@@ -261,7 +261,7 @@ class PackOptions(PackNarrowing, _PartScope, total=False):
@dataclass(frozen=True)
class _PackSettings:
class PackSettings:
"""PackOptions with their defaults."""
emulators_dir: str = EMULATORS_DIR
@@ -288,14 +288,14 @@ class _PackSettings:
@dataclass
class _PlatformPlan:
class PlatformPlan:
"""What a platform pack is built from, settled before its first member."""
platform_name: str
platforms_dir: str
db: dict
bios_dir: str
opts: _PackSettings
opts: PackSettings
config: dict
emu_profiles: dict
zip_contents: dict
@@ -333,14 +333,14 @@ class _PlatformPlan:
return self.config.get("case_insensitive_fs", False)
def _plan_platform_pack(
def plan_platform_pack(
platform_name: str,
platforms_dir: str,
db: dict,
bios_dir: str,
output_dir: str,
opts: _PackSettings,
) -> _PlatformPlan | str:
opts: PackSettings,
) -> PlatformPlan | str:
"""The configuration, scope and checks a platform pack reads, or the
reason the systems asked for leave nothing to build."""
config = load_platform_config(platform_name, platforms_dir)
@@ -402,7 +402,7 @@ def _plan_platform_pack(
# owns: the platform's own files and trees went to the other parts.
pack_systems = {}
plan = _PlatformPlan(
plan = PlatformPlan(
platform_name, platforms_dir, db, bios_dir, opts, config, emu_profiles,
zip_contents, cut, narrowings, zip_path, validation_index, platform_profiles,
validation_owners, slot_overrides, pack_systems,
@@ -411,7 +411,7 @@ def _plan_platform_pack(
return plan
def _settle_pack_choices(plan: _PlatformPlan) -> None:
def _settle_pack_choices(plan: PlatformPlan) -> None:
"""The declaration each destination takes and the variants left out."""
opts = plan.opts
if opts.source != "truth":
@@ -473,14 +473,14 @@ class PlatformPackOutcome:
@dataclass
class _PlatformPackBuild:
class PlatformPackBuild:
"""One platform pack being written: its members and what each slot came to.
A platform file is settled by the DeclarationJudge the install manifest
reads too, and a core extra by the lookup build_platform_pack binds.
"""
plan: _PlatformPlan
plan: PlatformPlan
zf: zipfile.ZipFile | PackRecord
declarations: DeclarationJudge
resolve_extra: Callable[[dict, str], tuple[str | None, str, str]]
@@ -1013,7 +1013,7 @@ class _PlatformPackBuild:
slot_undecidable=plan.slot_undecidable,
uncached=self.uncached,
left_out=(
_left_out_lines(
left_out_lines(
plan.cut,
systems=set(plan.pack_systems) if opts.source != "truth" else set(),
cores=opts.source != "platform" and opts.precomputed_extras is None,
@@ -1063,8 +1063,8 @@ def build_platform_pack(
for leave nothing to build.
"""
reject_unknown("generate_pack", options, PackOptions.__optional_keys__)
opts = _PackSettings(**options)
plan = _plan_platform_pack(platform_name, platforms_dir, db, bios_dir, output_dir, opts)
opts = PackSettings(**options)
plan = plan_platform_pack(platform_name, platforms_dir, db, bios_dir, output_dir, opts)
if isinstance(plan, str):
return PlatformPackOutcome(zip_path=None, refusal=plan)
@@ -1086,7 +1086,7 @@ def build_platform_pack(
contextlib.nullcontext(opts.record) if opts.record is not None
else writing_pack(plan.zip_path)
) as zf:
build = _PlatformPackBuild(plan, zf, declarations, resolve_extra)
build = PlatformPackBuild(plan, zf, declarations, resolve_extra)
build.run()
if opts.counts is not None:
opts.counts.append(
@@ -1161,7 +1161,7 @@ def _split_extras(
else:
all_extras = []
left_out = (
_left_out_lines(cut, systems=set(), cores=True)
left_out_lines(cut, systems=set(), cores=True)
if cut is not None and source != "platform" else []
)
return all_extras, left_out
+2 -2
View File
@@ -292,7 +292,7 @@ class ArchivePrefixCopies(unittest.TestCase):
],
}
}
return packextras._archive_prefix_extras(
return packextras.archive_prefix_extras(
profiles, {"fbneo"}, {"neogeo.zip"}, set(), "", by_name
)
@@ -313,7 +313,7 @@ class ArchivePrefixCopies(unittest.TestCase):
"system": "arcade"}],
}
}
extras = packextras._archive_prefix_extras(
extras = packextras.archive_prefix_extras(
profiles, {"fbneo"}, {"neogeo.zip"}, {"fbneo/neogeo.zip"}, "",
{"neogeo.zip": ["abc"]},
)
+6 -6
View File
@@ -22,7 +22,7 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
class AgnosticScan(unittest.TestCase):
def test_only_the_bios_directory_seeds_and_finds_keep_its_folder(self):
from packs.extras import _agnostic_scan_extras
from packs.extras import agnostic_scan_extras
with tempfile.TemporaryDirectory() as tmp:
previous = os.getcwd()
@@ -48,7 +48,7 @@ class AgnosticScan(unittest.TestCase):
{"name": "scph1.bin", "path": "pcsx2/bios/scph1.bin", "size": 64},
{"name": "message.wav", "path": "pcsx2/resources/message.wav", "size": 8},
]}
extras = _agnostic_scan_extras({"y": profile}, {"y"}, db, by_name, set(), "")
extras = agnostic_scan_extras({"y": profile}, {"y"}, db, by_name, set(), "")
self.assertEqual(sorted(e["destination"] for e in extras),
["pcsx2/bios/scph1.bin", "pcsx2/bios/scph2.bin"])
@@ -61,7 +61,7 @@ class AgnosticScan(unittest.TestCase):
folder where another profile of the system resolves a hashed dump of
that shape is the evidence, that folder only.
"""
from packs.extras import _agnostic_scan_extras
from packs.extras import agnostic_scan_extras
with tempfile.TemporaryDirectory() as tmp:
previous = os.getcwd()
@@ -95,7 +95,7 @@ class AgnosticScan(unittest.TestCase):
{"name": "scph1.bin", "size": 64,
"sha1": hashlib.sha1(b"a" * 64).hexdigest()},
]}
extras = _agnostic_scan_extras(
extras = agnostic_scan_extras(
{"l": placeholders, "s": pinned}, {"l"}, db, by_name, set(), "")
self.assertEqual(sorted(e["destination"] for e in extras), [
"pcsx2/bios/scph1.bin", "pcsx2/bios/scph1.nvm", "pcsx2/bios/scph2.bin",
@@ -105,12 +105,12 @@ class AgnosticScan(unittest.TestCase):
# An image the platform already ships there still gets its
# companion: RetroBat lists pcsx2/bios/scph39001.bin itself.
shipped = {"pcsx2/bios/scph1.bin"}
extras = _agnostic_scan_extras(
extras = agnostic_scan_extras(
{"l": placeholders, "s": pinned}, {"l"}, db, by_name, shipped, "")
self.assertIn("pcsx2/bios/scph1.nvm", {e["destination"] for e in extras})
# Nothing proves the folder: nothing is scanned.
self.assertEqual(
_agnostic_scan_extras({"l": placeholders}, {"l"}, db, by_name, set(), ""), [])
agnostic_scan_extras({"l": placeholders}, {"l"}, db, by_name, set(), ""), [])
class OneContentTwoPaths(unittest.TestCase):
+4 -4
View File
@@ -66,7 +66,7 @@ class Companions(unittest.TestCase):
import os
import tempfile
from packs.extras import _agnostic_scan_extras
from packs.extras import agnostic_scan_extras
profile = {
"emulator": "PCSX2", "bios_mode": "agnostic", "files": [
@@ -99,7 +99,7 @@ class Companions(unittest.TestCase):
db = {"files": files, "indexes": {
"by_name": by_name, "by_md5": {}, "by_crc32": {}, "by_path_suffix": {},
}}
extras = _agnostic_scan_extras(
extras = agnostic_scan_extras(
{"pcsx2": profile}, {"pcsx2"}, db, by_name, set(), "",
)
finally:
@@ -117,7 +117,7 @@ class Companions(unittest.TestCase):
import os
import tempfile
from packs.extras import _agnostic_scan_extras
from packs.extras import agnostic_scan_extras
def profile(name: str, ext: str) -> dict:
return {"emulator": name, "bios_mode": "agnostic", "files": [
@@ -148,7 +148,7 @@ class Companions(unittest.TestCase):
"by_name": by_name, "by_md5": {}, "by_crc32": {}, "by_path_suffix": {},
}}
profiles = {"a": profile("A", "rom1"), "b": profile("B", "erom")}
extras = _agnostic_scan_extras(
extras = agnostic_scan_extras(
profiles, {"a", "b"}, db, by_name, set(), "", taken={},
)
finally:
+3 -3
View File
@@ -314,13 +314,13 @@ class PackCarriesADirectory(DirectoryFixture):
class UnansweredDirectoryDestination(unittest.TestCase):
def test_a_directory_gap_is_named_by_its_path(self):
from packs.extras import _extra_dest
from packs.extras import extra_dest
tree = {"name": "registered/", "type": "directory",
"path": "nand/system/Contents/registered/"}
self.assertEqual(_extra_dest(tree), "nand/system/Contents/registered/")
self.assertEqual(extra_dest(tree), "nand/system/Contents/registered/")
folder = {"name": "snd_user.rpl", "path": "cafeLibs/"}
self.assertEqual(_extra_dest(folder), "cafeLibs/snd_user.rpl")
self.assertEqual(extra_dest(folder), "cafeLibs/snd_user.rpl")
@unittest.skipUnless(HAS_JSONSCHEMA, "validating a schema needs jsonschema")
+4 -4
View File
@@ -92,7 +92,7 @@ class OneComparisonOfArchiveMembers(unittest.TestCase):
import tempfile
import zipfile
from packs.integrity import _same_members
from packs.integrity import same_members
def archive(members: dict) -> bytes:
buffer = io.BytesIO()
@@ -110,9 +110,9 @@ class OneComparisonOfArchiveMembers(unittest.TestCase):
zf.writestr("other.zip", archive({"a.rom": b"X"}))
zf.writestr("broken.zip", b"not a zip")
with zipfile.ZipFile(pack) as zf:
self.assertTrue(_same_members(zf, "same.zip", str(held)))
self.assertFalse(_same_members(zf, "other.zip", str(held)))
self.assertFalse(_same_members(zf, "broken.zip", str(held)))
self.assertTrue(same_members(zf, "same.zip", str(held)))
self.assertFalse(same_members(zf, "other.zip", str(held)))
self.assertFalse(same_members(zf, "broken.zip", str(held)))
source = (Path(__file__).resolve().parents[1] / "scripts" / "packs" / "integrity.py").read_text()
self.assertNotIn("import io as _io", source)