MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _normalize_path

Function _normalize_path

graphify/cache.py:536–552  ·  view source on GitHub ↗

Normalize a path for cache identity without folding case. Windows spellings can differ in separators and in the optional extended-length prefix. Case is not equivalent on every volume a Windows process can reach, so the key keeps the caller's case. Use paths.os_long_path() for the p

(path: Path)

Source from the content-addressed store, hash-verified

534
535
536def _normalize_path(path: Path) -> Path:
537 """Normalize a path for cache identity without folding case.
538
539 Windows spellings can differ in separators and in the optional
540 extended-length prefix. Case is not equivalent on every volume a Windows
541 process can reach, so the key keeps the caller's case. Use
542 paths.os_long_path() for the path handed to the filesystem.
543 """
544 import sys
545 if sys.platform != "win32":
546 return path
547 s = str(path)
548 if s.startswith("\\\\?\\UNC\\"):
549 s = "\\\\" + s[8:] # \\?\UNC\server\share -> \\server\share
550 elif s.startswith("\\\\?\\"):
551 s = s[4:] # strip extended-length prefix \\?\
552 return Path(os.path.normpath(s))
553
554
555def _file_salt(

Callers 10

_ensure_stat_indexFunction · 0.85
_resolved_keyFunction · 0.85
_file_saltFunction · 0.85
file_hashFunction · 0.85
cached_word_countFunction · 0.85
_root_keyFunction · 0.85
_semantic_source_matcherFunction · 0.85
source_identityFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected