()
| 395 | |
| 396 | |
| 397 | def main() -> int: |
| 398 | parser = argparse.ArgumentParser() |
| 399 | parser.add_argument( |
| 400 | "stdlib_root", |
| 401 | nargs="?", |
| 402 | default="/tmp/python-lsp-references/typeshed/stdlib", |
| 403 | ) |
| 404 | parser.add_argument( |
| 405 | "output", |
| 406 | nargs="?", |
| 407 | default="internal/cbm/lsp/generated/python_stdlib_data.c", |
| 408 | ) |
| 409 | args = parser.parse_args() |
| 410 | |
| 411 | root = Path(args.stdlib_root).resolve() |
| 412 | if not root.is_dir(): |
| 413 | print(f"error: {root} is not a directory", file=sys.stderr) |
| 414 | return 1 |
| 415 | |
| 416 | stubs = list(iter_module_stubs(root)) |
| 417 | out_path = Path(args.output).resolve() |
| 418 | out_path.parent.mkdir(parents=True, exist_ok=True) |
| 419 | emit(stubs, out_path) |
| 420 | |
| 421 | n_classes = sum(len(s.classes) for s in stubs) |
| 422 | n_methods = sum(sum(len(c.methods) for c in s.classes) for s in stubs) |
| 423 | n_funcs = sum(len(s.functions) for s in stubs) |
| 424 | print( |
| 425 | f"wrote {out_path}: {len(stubs)} modules, " |
| 426 | f"{n_classes} classes ({n_methods} methods), {n_funcs} free functions" |
| 427 | ) |
| 428 | return 0 |
| 429 | |
| 430 | |
| 431 | if __name__ == "__main__": |
no test coverage detected