MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / Process

Function Process

tools/cpp_format_struct_table.py:53–77  ·  view source on GitHub ↗
(path: str)

Source from the content-addressed store, hash-verified

51
52
53def 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
80class CharState:

Callers 1

MainFunction · 0.85

Calls 4

ColumnsStateClass · 0.85
ProcessLineFunction · 0.85
FormatLineFunction · 0.85
readMethod · 0.80

Tested by

no test coverage detected