(path: str)
| 51 | |
| 52 | |
| 53 | def Process(path: str): |
| 54 | with open(path, "r", encoding="utf-8", newline="\r\n") as f: |
| 55 | input = f.read().splitlines() |
| 56 | |
| 57 | columns_state = ColumnsState() |
| 58 | output_lines = [] |
| 59 | state = LineState.NONE |
| 60 | begin = 0 |
| 61 | for i in range(len(input)): |
| 62 | prev_state = state |
| 63 | state = ProcessLine(input[i], state, columns_state) |
| 64 | if prev_state != state: |
| 65 | columns_state.has_header = False |
| 66 | for j in range(begin, i): |
| 67 | output_line = FormatLine(input[j], prev_state, columns_state) |
| 68 | output_lines.append(output_line) |
| 69 | columns_state = ColumnsState() |
| 70 | begin = i |
| 71 | columns_state.has_header = False |
| 72 | for j in range(begin, len(input)): |
| 73 | output_line = FormatLine(input[j], state, columns_state) |
| 74 | output_lines.append(output_line) |
| 75 | |
| 76 | with open(path, "w", encoding="utf-8", newline="") as f: |
| 77 | f.writelines(f"{line}\r\n" for line in output_lines) |
| 78 | |
| 79 | |
| 80 | class CharState: |
no test coverage detected