| from __future__ import annotations | |
| import os | |
| def stored_path(path: str) -> str: | |
| return os.path.abspath(path) | |
| def prefix_case_paths(root: str) -> list[tuple[str, bool]]: | |
| parent = os.path.dirname(root) | |
| name = os.path.basename(root) | |
| upper = name.upper() | |
| assert upper != name, f"root basename {name!r} has no distinct uppercase form" | |
| return [ | |
| (root, True), | |
| (os.path.join(root, "child.png"), True), | |
| (os.path.join(root, "sub", "deep.png"), True), | |
| (os.path.join(root, "meta%_*?[].png"), True), | |
| (os.path.join(parent, upper), False), | |
| (os.path.join(parent, upper, "case.png"), False), | |
| (root + "-other" + os.sep + "lexical.png", False), | |
| (root + "extra", False), | |
| (os.path.join(parent, "unrelated.png"), False), | |
| (os.path.join(root, os.pardir, "escaped.png"), False), | |
| (os.path.join(root, "sub", os.pardir, "in.png"), True), | |
| (os.path.join(name, "relative.png"), False), | |
| (root + os.sep + os.sep + "doubled.png", True), | |
| (os.path.join(root, "trailing.png") + os.sep, True), | |
| ] | |
| def expected_prefix_case_paths(root: str) -> set[str]: | |
| return {os.path.abspath(path) for path, expected in prefix_case_paths(root) if expected} | |
| def anchor_case_paths() -> list[tuple[str, str, bool]]: | |
| """(path, prefix, Path(path).is_relative_to(prefix)) across POSIX anchors. | |
| abspath keeps exactly two leading slashes, and pathlib treats "//" as its own | |
| anchor, so "//server/..." is not under "/". Three or more collapse to "/". | |
| """ | |
| return [ | |
| ("//server/file", "/", False), | |
| ("//server/file", "//server", True), | |
| ("//server", "//", True), | |
| ("/x", "//", False), | |
| ("///x/y", "/", True), | |
| ("/x/y", "/", True), | |
| ] | |
Xet Storage Details
- Size:
- 1.79 kB
- Xet hash:
- 222da5b874478aecc6835890e7ab73e7a00f0e0a1648ff7ac8d31e44fbc8b910
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.