mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-31 08:04:36 +01:00
28 lines
922 B
Python
28 lines
922 B
Python
""" Script that sorts warnings generated by doxygen to maintain consistent order. """
|
|
import sys
|
|
|
|
def read_by_line(file_path):
|
|
with open(file_path, "r") as f:
|
|
while line := f.readline():
|
|
yield line[:-1]
|
|
|
|
def main():
|
|
if len(sys.argv) != 3:
|
|
print("Wrong number of arguments provided, expected two.")
|
|
print("Usage: python3 sort_doxygen_warnings.py [input_file] [output_file]")
|
|
sys.exit(1)
|
|
warnings = []
|
|
for line in read_by_line(sys.argv[1]):
|
|
if "warning:" in line or "error:" in line:
|
|
warnings.append(line)
|
|
continue
|
|
# Doxygen warnings can span multiple lines, keep these lines together.
|
|
warnings[-1] = f"{warnings[-1]}\n{line}"
|
|
warnings.sort()
|
|
with open(sys.argv[2], "w") as out:
|
|
out.write("\n".join(warnings))
|
|
print("Doxygen warnings sorted successfully.")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|