MCPcopy Create free account
hub / github.com/FastLED/FastLED / main

Function main

ci/replace_extern_c.py:127–190  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

125
126
127def main():
128 import argparse
129
130 parser = argparse.ArgumentParser(
131 description='Replace extern "C" patterns with FL_EXTERN_C macros'
132 )
133 parser.add_argument(
134 "--dry-run",
135 action="store_true",
136 help="Show what would be changed without modifying files",
137 )
138 parser.add_argument(
139 "--exclude-third-party",
140 action="store_true",
141 default=True,
142 help="Exclude third_party directories (default: True)",
143 )
144 parser.add_argument(
145 "--include-third-party",
146 action="store_false",
147 dest="exclude_third_party",
148 help="Include third_party directories",
149 )
150 parser.add_argument(
151 "files",
152 nargs="*",
153 help="Specific files to process (if empty, processes all src/ files)",
154 )
155
156 args = parser.parse_args()
157
158 root = Path(__file__).parent.parent
159
160 if args.files:
161 files_to_process = [Path(f) for f in args.files]
162 else:
163 # Find all .h, .hpp, .cpp files in src/
164 patterns = ["**/*.h", "**/*.hpp", "**/*.cpp"]
165 files_to_process: list[Path] = []
166 for pattern in patterns:
167 files_to_process.extend((root / "src").rglob(pattern))
168
169 # Filter out third_party if requested
170 if args.exclude_third_party:
171 files_to_process = [f for f in files_to_process if "third_party" not in f.parts]
172
173 total_files = len(files_to_process)
174 modified_count = 0
175 total_replacements = 0
176
177 print(f"Processing {total_files} files...")
178 if args.dry_run:
179 print("DRY RUN - No files will be modified\n")
180
181 for filepath in sorted(files_to_process):
182 was_modified, count = replace_extern_c_in_file(filepath, dry_run=args.dry_run)
183 if was_modified:
184 modified_count += 1

Callers 1

Calls 3

replace_extern_c_in_fileFunction · 0.85
parse_argsMethod · 0.80
printFunction · 0.50

Tested by

no test coverage detected