diff --git a/tests/test_report_paths.py b/tests/test_report_paths.py index 5a22fe2cc5..0d59ca3d5f 100644 --- a/tests/test_report_paths.py +++ b/tests/test_report_paths.py @@ -22,11 +22,10 @@ # Tools that use report_paths and must not define their own copy again. SHARED = ("anim_index", "awc_manifest", "bink_index", "gamedata_index", "gamedata_xml", "gen_d3d12_stubs", - "glb_inspect", "meshlet_page", "navmesh_index", "rpf_probe", "tile_probe", "world_index", - "world_lights_paths", "world_names") -# The one tool that still carries its own copy (an open pull request edits its call site). Do not add to this list: -# import report_paths instead. -LEGACY_COPIES = {"navmesh_decode"} + "glb_inspect", "meshlet_page", "navmesh_decode", "navmesh_index", "rpf_probe", "tile_probe", + "world_index", "world_lights_paths", "world_names") +# No tool carries its own copy any more: import report_paths instead. Do not add to this list. +LEGACY_COPIES = set() def touch(path): @@ -259,7 +258,7 @@ def test_no_new_copies_of_same_report_path(self): def test_tools_still_expose_same_report_path(self): # gamedata_xml.py and others call it by this name (and tests or sibling tools may import it). - for tool in ("gamedata_index", "gamedata_xml", "navmesh_index", "world_index"): + for tool in ("gamedata_index", "gamedata_xml", "navmesh_decode", "navmesh_index", "world_index"): with self.subTest(tool=tool): module = __import__(tool) self.assertIs(module.same_report_path, report_paths.same_report_path) diff --git a/tools/navmesh_decode.py b/tools/navmesh_decode.py index 6490dec125..dcb872098f 100644 --- a/tools/navmesh_decode.py +++ b/tools/navmesh_decode.py @@ -49,7 +49,6 @@ import struct import sys import time -import unicodedata import zlib from collections import Counter from collections.abc import Iterator @@ -57,6 +56,7 @@ ROOT = os.path.dirname(os.path.abspath(__file__)) if ROOT not in sys.path: sys.path.insert(0, ROOT) +from report_paths import same_report_path # noqa: E402 from zero_span import gap_split # noqa: E402 BASE = 0x50000000 @@ -1048,42 +1048,6 @@ def _offset(text): return value -_PC_CASE_SENSITIVE = 11 # on macOS; os.pathconf_names doesn't list it - - -def _case_insensitive_volume(path): - """True when the volume that will hold `path` ignores letter case, as macOS's default APFS volume does. - os.path.normcase folds case only on Windows, so on macOS `R.json` and `r.json` would pass as two reports.""" - if sys.platform != "darwin": - return False - while not os.path.exists(path): - parent = os.path.dirname(path) - if parent == path: - break - path = parent - try: - return os.pathconf(path, _PC_CASE_SENSITIVE) == 0 - except (OSError, ValueError): - return True # the macOS default; folding can only refuse a pair, never overwrite one - - -def _path_key(path): - path = os.path.normcase(os.path.realpath(path)) - if _case_insensitive_volume(path): - # APFS and HFS+ also treat composed and decomposed accents as one name. - path = unicodedata.normalize("NFD", path.casefold()) - return path - - -def same_report_path(first, second): - if _path_key(first) == _path_key(second): - return True - try: - return os.path.samefile(first, second) - except OSError: - return False - - def main(argv=None): ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) ap.add_argument("input", help="RPF9 archive (navmeshes.rpf) or directory of carved streams")