mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-29 21:08:53 -06:00
refactor: read declared hashes with one helper
core.hashing.declared_hash_lists gives an entry's declared values per field in the order written, and declared_hashes builds its sets on it. The gap page, the doubled-destination report and the file lookup used their own copies of that reader. The wanted page keeps its filters on top of it. sitegen.lookup.hash_pairs replaces sorted_hash_values for the lookup, the data exports and the structured data. The one-field aliases parse_md5_list and reconcile.hash_values are gone, and model.profiles reads HASH_FIELDS instead of a fourth tuple.
This commit is contained in:
1 parent
ea68e85c06
commit
02969dda06
30 files changed
+176
-195
No files matched your search
+17
-2
@@ -93,8 +93,18 @@ class TheSiteReadsAHashFieldTheResolversWay(unittest.TestCase):
|
||||
("0xDEADBEEF", ["deadbeef"]), (12345678, ["12345678"]),
|
||||
):
|
||||
with self.subTest(raw=raw):
|
||||
self.assertEqual(lookup.sorted_hash_values(raw), expected)
|
||||
self.assertEqual(lookup.sorted_hash_values(raw), sorted(hashing.parse_hash_list(raw)))
|
||||
pairs = lookup.hash_pairs({"md5": raw})
|
||||
self.assertEqual([value for _algo, value in pairs], expected)
|
||||
self.assertEqual({algo for algo, _value in pairs}, {"md5"} if expected else set())
|
||||
|
||||
def test_algorithms_keep_the_order_given(self):
|
||||
from sitegen import lookup
|
||||
|
||||
entry = {"crc32": "0xAB", "sha1": "b, a", "md5": ""}
|
||||
self.assertEqual(lookup.hash_pairs(entry),
|
||||
[("sha1", "a"), ("sha1", "b"), ("crc32", "ab")])
|
||||
self.assertEqual(lookup.hash_pairs(entry, ("crc32", "sha1")),
|
||||
[("crc32", "ab"), ("sha1", "a"), ("sha1", "b")])
|
||||
|
||||
|
||||
|
||||
@@ -106,6 +116,11 @@ class DeclaredHashes(unittest.TestCase):
|
||||
self.assertFalse(hashing.lists_hashes({"sha1": " , "}))
|
||||
self.assertTrue(hashing.lists_hashes({"crc32": "1234abcd"}))
|
||||
|
||||
def test_lists_keep_the_written_order(self):
|
||||
entry = {"crc32": "0xAB", "md5": "B, a, b", "sha1": ""}
|
||||
self.assertEqual(hashing.declared_hash_lists(entry), {"md5": ["b", "a"], "crc32": ["ab"]})
|
||||
self.assertEqual(list(hashing.declared_hash_lists(entry, ("crc32", "md5"))), ["crc32", "md5"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user