normalize_generated.py 588 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env python3
  2. from pathlib import Path
  3. ROOT = Path(__file__).resolve().parent.parent
  4. GENERATED_DIRS = (
  5. ROOT / "service/gen",
  6. ROOT / "frontend/resources/scripts/gen",
  7. )
  8. def normalize_file(path: Path) -> None:
  9. content = path.read_bytes()
  10. normalized = content.rstrip(b"\r\n") + b"\n"
  11. if normalized != content:
  12. path.write_bytes(normalized)
  13. def main() -> None:
  14. for directory in GENERATED_DIRS:
  15. for path in directory.rglob("*"):
  16. if path.is_file():
  17. normalize_file(path)
  18. if __name__ == "__main__":
  19. main()