MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / main

Function main

scripts/website/bulk_mechanical_fix.py:169–203  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

167
168
169def main():
170 ap = argparse.ArgumentParser(description=__doc__)
171 ap.add_argument("paths", nargs="+", help="Markdown files or directories")
172 ap.add_argument("--write", action="store_true",
173 help="Apply changes (default: dry run)")
174 ap.add_argument("--trailing-whitespace", action="store_true",
175 help="Also strip insignificant trailing whitespace "
176 "(hard-break-aware; off by default)")
177 ap.add_argument("--no-collapse-spaces", action="store_true")
178 args = ap.parse_args()
179
180 opts = {
181 "write": args.write,
182 "trailing_ws": args.trailing_whitespace,
183 "collapse_spaces": not args.no_collapse_spaces,
184 }
185 counts = {"trailing-whitespace": 0, "collapse-spaces": 0}
186 files = expand_paths(args.paths)
187 changed = []
188 for path in files:
189 try:
190 if process_file(path, opts, counts):
191 changed.append(path)
192 except AssertionError as exc:
193 print(f"SKIPPED (guardrail): {exc}", file=sys.stderr)
194
195 mode = "WROTE" if args.write else "DRY RUN — would change"
196 print(f"{mode} {len(changed)} file(s) of {len(files)} scanned.")
197 print("Changes by category (files touched per transform):")
198 for cat, n in counts.items():
199 print(f" {cat}: {n}")
200 if not args.write and changed:
201 print("\nRe-run with --write to apply. Land one batched PR; the guardrails "
202 "above guarantee front matter and code/links/words are untouched.")
203 return 0
204
205
206if __name__ == "__main__":

Callers 1

Calls 3

expand_pathsFunction · 0.70
process_fileFunction · 0.70
appendMethod · 0.65

Tested by

no test coverage detected