Remove header from php and go files
(path: str)
| 242 | |
| 243 | |
| 244 | def remove_header(path: str): |
| 245 | """Remove header from php and go files""" |
| 246 | print(f"[remove header] path: {path}") |
| 247 | with open(path, "r", encoding="utf-8") as f: |
| 248 | content = f.read() |
| 249 | if path.endswith(".php"): |
| 250 | content = content.rstrip() |
| 251 | content = content.replace("<?php\n", "") |
| 252 | elif path.endswith(".go"): |
| 253 | content = content.rstrip() |
| 254 | if "sorting" not in path: |
| 255 | content = content.replace("package main\n\n", "").replace( |
| 256 | "package main\n", "" |
| 257 | ) |
| 258 | else: |
| 259 | return |
| 260 | with open(path, "w", encoding="utf-8") as f: |
| 261 | f.write(content) |
| 262 | |
| 263 | |
| 264 | def find_all_paths() -> List[str]: |
no test coverage detected