MCPcopy
hub / github.com/doocs/leetcode / add_header

Function add_header

run_format.py:225–241  ·  view source on GitHub ↗

Add header to php and go files

(path: str)

Source from the content-addressed store, hash-verified

223
224
225def add_header(path: str):
226 """Add header to php and go files"""
227 print(f"[add header] path: {path}")
228 with open(path, "r", encoding="utf-8") as f:
229 content = f.read()
230 if path.endswith(".php"):
231 content = "<?php\n" + content
232 elif path.endswith(".go") and "sorting" not in path:
233 content = "package main\n" + content
234 elif path.endswith(".sql"):
235 for func in functions_to_replace:
236 pattern = r"\b{}\s*\(".format(func)
237 content = re.sub(pattern, f"{func.upper()}(", content, flags=re.IGNORECASE)
238 else:
239 return
240 with open(path, "w", encoding="utf-8") as f:
241 f.write(content)
242
243
244def remove_header(path: str):

Callers 2

format_inline_codeFunction · 0.85
runFunction · 0.85

Calls 4

printFunction · 0.85
formatMethod · 0.80
readMethod · 0.45
subMethod · 0.45

Tested by

no test coverage detected