mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 16:18:37 +00:00
bink_names: ignore commented-out movie mount entries
This commit is contained in:
@ -64,6 +64,16 @@ class TestListOrder(unittest.TestCase):
|
||||
# duplicates collapse case-insensitively; '_' (0x5F) sorts before 'e' (0x65)
|
||||
self.assertEqual(got, ["Aa/clip_x.bk2", "aa/clipe.bk2", "mm/one.bk2", "zz/b.bk2"])
|
||||
|
||||
def test_inactive_mount_entries_do_not_shift_names(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
active = mount_xml(["A.bk2", "C.bk2"])
|
||||
tag = "<filename>$(common)/movies/B.bk2</filename>"
|
||||
for ignored in ("<!--\n" + tag + "\n-->", "<![CDATA[" + tag + "]]>", "<?note " + tag + "?>"):
|
||||
with self.subTest(ignored=ignored):
|
||||
xml = active.replace("<filesToEnable>", "<filesToEnable>" + ignored)
|
||||
path = self.write(tmp, "list.xml", xml)
|
||||
self.assertEqual(names_mod.read_mount_lists([path]), ["A.bk2", "C.bk2"])
|
||||
|
||||
def test_name_without_extension_compared(self):
|
||||
# "ab" is a prefix of "ab-1", so it sorts first; with the extension '-' (0x2D) < '.' (0x2E) would flip them
|
||||
self.assertEqual(sorted(["f/ab-1.bk2", "f/ab.bk2"], key=names_mod.sort_key), ["f/ab.bk2", "f/ab-1.bk2"])
|
||||
|
||||
@ -125,7 +125,8 @@ def read_mount_lists(paths):
|
||||
for data in mount_documents(paths):
|
||||
if LIST_MARKER not in data.lower():
|
||||
continue
|
||||
text = data.decode("utf-8", errors="replace")
|
||||
# Filename-shaped text in comments, CDATA or processing instructions is not an element.
|
||||
text = gamedata_xml.COMMENT_MARKUP.sub(b" ", data).decode("utf-8", errors="replace")
|
||||
for name in LIST_ENTRY.findall(text):
|
||||
name = name.strip().replace("\\", "/")
|
||||
if name.lower() not in seen:
|
||||
|
||||
Reference in New Issue
Block a user