| 35 | |
| 36 | |
| 37 | def file_has_license(file_path: str) -> None: |
| 38 | path = Path(file_path) |
| 39 | if not path.name.endswith(".py"): |
| 40 | return |
| 41 | if not path.exists(): |
| 42 | raise Exception(f"File {file_path} does not exist") |
| 43 | content = path.read_text(encoding="utf-8") |
| 44 | if content.strip() == "": |
| 45 | return |
| 46 | if content.startswith("#!"): |
| 47 | # flake8: noqa: E203 |
| 48 | content = content[content.find("\n") + 1 :] |
| 49 | if not content.startswith(LICENSE_HEADER): |
| 50 | raise Exception(f"File {file_path} does not have license header") |
| 51 | |
| 52 | |
| 53 | def main() -> None: |