MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / _add_html_extensions

Function _add_html_extensions

scripts/freeze_viewer.py:227–252  ·  view source on GitHub ↗

Add .html extensions to files that don't have .html extensions but contain HTML

(build_dir: Path)

Source from the content-addressed store, hash-verified

225
226
227def _add_html_extensions(build_dir: Path):
228 """Add .html extensions to files that don't have .html extensions but contain HTML"""
229 build_path = Path(build_dir)
230
231 # Find files that might be HTML
232 for file_path in build_path.rglob("*"):
233 if file_path.is_file() and not file_path.name.endswith(".html"):
234 # Skip known non-HTML files
235 if file_path.name in ["load-readme"] or file_path.name.startswith("line-counts"):
236 continue
237
238 # Skip if it's in static directory
239 if "static" in file_path.parts:
240 continue
241
242 # Check if file contains HTML content
243 try:
244 content = file_path.read_text()
245 if content.strip().startswith("<!DOCTYPE html") or "<html" in content[:200]:
246 # Rename to add .html extension
247 new_path = file_path.with_name(file_path.name + ".html")
248 file_path.rename(new_path)
249 print(f" Renamed: {file_path.relative_to(build_path)} -> {new_path.relative_to(build_path)}")
250 except (UnicodeDecodeError, OSError):
251 # Skip binary files or files we can't read
252 continue
253
254
255if __name__ == "__main__":

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected