mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-26 11:28:51 -06:00
refactor: public names for cross-module reads
This commit is contained in:
1 parent
f371790dc6
commit
3853ca2f1c
254 files changed
+2955
-2969
No files matched your search
@@ -18,8 +18,8 @@ sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
from resolve.archives import contents_members, holds_required_members
|
||||
from resolve.standalone import platform_layouts, standalone_set
|
||||
from resolve.cores import resolve_platform_cores
|
||||
from resolve.reconcile import HASH_FIELDS, _hash_values
|
||||
from resolve.collisions import _accepted_by_all, _lists_hashes, find_collisions
|
||||
from resolve.reconcile import HASH_FIELDS, hash_values
|
||||
from resolve.collisions import accepted_by_all, lists_hashes, find_collisions
|
||||
from resolve.validation import opens_by_name, outside_gap_scope
|
||||
|
||||
|
||||
@@ -58,13 +58,13 @@ def _reads(entry: dict, by_name: bool, local: str, db: dict) -> bool:
|
||||
"""
|
||||
if entry.get("contents"):
|
||||
return holds_required_members(local, contents_members(entry))
|
||||
if _lists_hashes(entry):
|
||||
return _accepted_by_all(local, [entry], db)
|
||||
if lists_hashes(entry):
|
||||
return accepted_by_all(local, [entry], db)
|
||||
return by_name and _size_fits(entry, local)
|
||||
|
||||
|
||||
def _hashes(entry: dict) -> dict[str, list[str]]:
|
||||
found = {f: _hash_values(entry, f) for f in HASH_FIELDS}
|
||||
found = {f: hash_values(entry, f) for f in HASH_FIELDS}
|
||||
return {f: values for f, values in found.items() if values}
|
||||
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
|
||||
from scraper.emudeck_scraper import FUNCTION_HASH_MAP, _RE_FUNC, _RE_LOCAL_HASHES
|
||||
from scraper.emudeck_scraper import FUNCTION_HASH_MAP, RE_FUNC, RE_LOCAL_HASHES
|
||||
|
||||
from .base_exporter import BaseExporter
|
||||
from resolve.reconcile import NativeFile, NativeSystem, Report, _hash_values
|
||||
from resolve.reconcile import NativeFile, NativeSystem, Report, hash_values
|
||||
|
||||
SOURCE_URL = (
|
||||
"https://raw.githubusercontent.com/dragoonDorise/EmuDeck/main"
|
||||
@@ -80,7 +80,7 @@ class Exporter(BaseExporter[str]):
|
||||
adds nothing, and the truth's extra accepted revisions are not
|
||||
appended: either would grow an array other consumers read too.
|
||||
"""
|
||||
theirs = _hash_values(fe.platform or {}, "md5")
|
||||
theirs = hash_values(fe.platform or {}, "md5")
|
||||
if not theirs:
|
||||
return []
|
||||
if "md5" in fe.corrections:
|
||||
@@ -124,7 +124,7 @@ class Exporter(BaseExporter[str]):
|
||||
if system.native_id == system_id
|
||||
for fe in system.files
|
||||
if "md5" in fe.corrections
|
||||
for value in _hash_values(fe.platform or {}, "md5")
|
||||
for value in hash_values(fe.platform or {}, "md5")
|
||||
}
|
||||
|
||||
@classmethod
|
||||
@@ -146,7 +146,7 @@ class Exporter(BaseExporter[str]):
|
||||
|
||||
def _function_spans(self, script: str) -> list[tuple[str, int, int]]:
|
||||
"""Name and byte span of every check the script defines."""
|
||||
matches = list(_RE_FUNC.finditer(script))
|
||||
matches = list(RE_FUNC.finditer(script))
|
||||
spans: list[tuple[str, int, int]] = []
|
||||
for index, match in enumerate(matches):
|
||||
end = (
|
||||
@@ -179,7 +179,7 @@ class Exporter(BaseExporter[str]):
|
||||
body = script[start:end]
|
||||
system_id = FUNCTION_HASH_MAP.get(name)
|
||||
md5s = self._md5s(systems, system_id) if system_id else []
|
||||
match = _RE_LOCAL_HASHES.search(body)
|
||||
match = RE_LOCAL_HASHES.search(body)
|
||||
if md5s and match:
|
||||
# An array compared by membership says nothing about order,
|
||||
# so the same set is left as the maintainer wrote it.
|
||||
@@ -226,7 +226,7 @@ class Exporter(BaseExporter[str]):
|
||||
for fname, start, end in self._function_spans(content)
|
||||
if fname == name
|
||||
)
|
||||
if not _RE_LOCAL_HASHES.search(body):
|
||||
if not RE_LOCAL_HASHES.search(body):
|
||||
# A check with no hash list is a path check, not a hash check.
|
||||
continue
|
||||
issues.extend(f"absent from {name}: {md5}" for md5 in md5s if md5 not in body)
|
||||
|
||||
@@ -6,7 +6,7 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from .base_exporter import BaseExporter
|
||||
from resolve.reconcile import HASH_FIELDS, NativeFile, _hash_values, _single_size
|
||||
from resolve.reconcile import HASH_FIELDS, NativeFile, hash_values, single_size
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -75,7 +75,7 @@ def _change(
|
||||
|
||||
|
||||
def _platform_value(entry: NativeFile, field_name: str) -> str | list[str]:
|
||||
values = _hash_values(entry.platform or {}, field_name)
|
||||
values = hash_values(entry.platform or {}, field_name)
|
||||
if (entry.platform or {}).get(f"{field_name}_list"):
|
||||
return values
|
||||
return ",".join(values)
|
||||
@@ -157,7 +157,7 @@ def landed_changes(exporter: BaseExporter, systems: dict) -> LandedChanges:
|
||||
listed is not None
|
||||
and field_name not in entry.corrections
|
||||
and field_name not in entry.filled
|
||||
and listed != _hash_values(entry.platform, field_name)
|
||||
and listed != hash_values(entry.platform, field_name)
|
||||
and exporter.states(entry, field_name)
|
||||
):
|
||||
records.append(_change(
|
||||
@@ -175,28 +175,28 @@ def landed_changes(exporter: BaseExporter, systems: dict) -> LandedChanges:
|
||||
if (
|
||||
theirs
|
||||
and ours
|
||||
and _single_size(theirs) not in (None, ours)
|
||||
and single_size(theirs) not in (None, ours)
|
||||
and exporter.states(entry, "size")
|
||||
):
|
||||
records.append(_change(
|
||||
"size_updated", entry, "size", _single_size(theirs), ours
|
||||
"size_updated", entry, "size", single_size(theirs), ours
|
||||
))
|
||||
elif (
|
||||
theirs
|
||||
and ours is None
|
||||
and _single_size(theirs) is not None
|
||||
and single_size(theirs) is not None
|
||||
and exporter.states(entry, "size")
|
||||
):
|
||||
# The truth took the entry over without a size of its own:
|
||||
# System.dat's neocdz.zip line went out without size 953078.
|
||||
records.append(_change(
|
||||
"size_removed", entry, "size", _single_size(theirs), None
|
||||
"size_removed", entry, "size", single_size(theirs), None
|
||||
))
|
||||
records.extend(
|
||||
_change("hash_cleared", entry, field_name,
|
||||
_platform_value(entry, field_name), None)
|
||||
for field_name in HASH_FIELDS
|
||||
if _hash_values(entry.platform, field_name)
|
||||
if hash_values(entry.platform, field_name)
|
||||
and not entry.hashes(field_name)
|
||||
and exporter.clears(entry, field_name)
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
from scraper.romm_scraper import SLUG_MAP
|
||||
|
||||
from .base_exporter import BaseExporter
|
||||
from resolve.reconcile import NativeFile, NativeSystem, Report, _hash_values
|
||||
from resolve.reconcile import NativeFile, NativeSystem, Report, hash_values
|
||||
|
||||
SOURCE_URL = (
|
||||
"https://raw.githubusercontent.com/rommapp/romm/master/backend/models"
|
||||
@@ -161,7 +161,7 @@ class Exporter(BaseExporter[str]):
|
||||
output[key] = OrderedDict(
|
||||
(field, value)
|
||||
for field, name in _FIELDS
|
||||
if (value := ",".join(_hash_values(fe.platform, name))
|
||||
if (value := ",".join(hash_values(fe.platform, name))
|
||||
if name != "size" else str(fe.platform["size"]))
|
||||
)
|
||||
continue
|
||||
@@ -185,7 +185,7 @@ class Exporter(BaseExporter[str]):
|
||||
def _contradicted(fe: NativeFile, name: str) -> bool:
|
||||
"""A hash the platform states and the truth, taking the entry over,
|
||||
does not keep."""
|
||||
return bool(_hash_values(fe.platform or {}, name)) and not fe.hashes(name)
|
||||
return bool(hash_values(fe.platform or {}, name)) and not fe.hashes(name)
|
||||
|
||||
def states(self, fe: NativeFile, field_name: str) -> bool:
|
||||
"""An entry left whole carries none of the truth's values."""
|
||||
|
||||
Reference in new issue
Block a user