(in_file: str, lines: List[str])
| 75 | |
| 76 | |
| 77 | def 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 | |
| 113 | def sanitize_path(path: str) -> str: |
no test coverage detected