MCPcopy Create free account
hub / github.com/mlco2/codecarbon / _match_local_file

Function _match_local_file

scripts/check_docs_links.py:88–122  ·  view source on GitHub ↗

Return (ok, detail) after checking candidate against built site layout.

(
    site_root: Path, candidate: Path, fragment: str
)

Source from the content-addressed store, hash-verified

86
87
88def _match_local_file(
89 site_root: Path, candidate: Path, fragment: str
90) -> tuple[bool, str]:
91 """Return (ok, detail) after checking candidate against built site layout."""
92 if candidate.is_dir():
93 index_file = candidate / "index.html"
94 if index_file.is_file():
95 ok = _fragment_ok(index_file, fragment)
96 return ok, str(index_file) + (f"#{fragment}" if fragment else "")
97 if candidate.name == "how-to" and candidate == site_root / "how-to":
98 return True, "skip-how-to-section-root-without-index"
99 return False, f"missing index in directory {candidate}"
100
101 if candidate.is_file():
102 ok = _fragment_ok(candidate, fragment)
103 return ok, str(candidate) + (f"#{fragment}" if fragment else "")
104
105 if candidate.suffix == ".md":
106 html_dir = candidate.with_suffix("")
107 idx = html_dir / "index.html"
108 if idx.is_file():
109 return _fragment_ok(idx, fragment), str(idx)
110 if html_dir.is_dir() and (html_dir / "index.html").is_file():
111 idx2 = html_dir / "index.html"
112 return _fragment_ok(idx2, fragment), str(idx2)
113
114 html_path = candidate.with_suffix(".html")
115 if html_path.is_file():
116 return _fragment_ok(html_path, fragment), str(candidate)
117
118 nested = candidate.parent / candidate.name / "index.html"
119 if candidate.parent.is_dir() and nested.is_file():
120 return _fragment_ok(nested, fragment), str(nested)
121
122 return False, f"not found: {candidate}"
123
124
125def _local_target_exists(

Callers 1

_local_target_existsFunction · 0.85

Calls 1

_fragment_okFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…