Add header to php and go files
(path: str)
| 223 | |
| 224 | |
| 225 | def 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 | |
| 244 | def remove_header(path: str): |