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

+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)