MCPcopy Create free account
hub / github.com/doldecomp/mkdd / process_file

Function process_file

tools/decompctx.py:77–110  ·  view source on GitHub ↗
(in_file: str, lines: List[str])

Source from the content-addressed store, hash-verified

75
76
77def process_file(in_file: str, lines: List[str]) -> str:
78 out_text = ""
79 for idx, line in enumerate(lines):
80 if idx == 0:
81 guard_match = guard_pattern.match(line.strip())
82 if guard_match:
83 if guard_match[1] in defines:
84 break
85 defines.add(guard_match[1])
86 else:
87 once_match = once_pattern.match(line.strip())
88 if once_match:
89 if in_file in defines:
90 break
91 defines.add(in_file)
92 print("Processing file", in_file)
93 include_match = include_pattern.match(line.strip())
94 if include_match and not include_match[1].endswith(".s"):
95 excluded = False
96 for glob in exclude_globs:
97 if fnmatch.fnmatch(include_match[1], glob):
98 excluded = True
99 break
100
101 out_text += f'/* "{in_file}" line {idx} "{include_match[1]}" */\n'
102 if excluded:
103 out_text += "/* Skipped excluded file */\n"
104 else:
105 out_text += import_h_file(include_match[1], os.path.dirname(in_file))
106 out_text += f'/* end "{include_match[1]}" */\n'
107 else:
108 out_text += line
109
110 return out_text
111
112
113def sanitize_path(path: str) -> str:

Callers 1

import_c_fileFunction · 0.85

Calls 2

import_h_fileFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected