(self, args)
| 687 | raise argparse.ArgumentTypeError(f"{path} is not a valid path") |
| 688 | |
| 689 | def _parse_options(self, args): |
| 690 | parser = argparse.ArgumentParser( |
| 691 | description="Upgrade C extension modules to newer Python C API") |
| 692 | parser.add_argument( |
| 693 | '-o', '--operations', action="store", |
| 694 | default="all", |
| 695 | help='Space separated list of operation names to apply') |
| 696 | parser.add_argument( |
| 697 | '-q', '--quiet', action="store_true", |
| 698 | help='Quiet mode') |
| 699 | parser.add_argument( |
| 700 | '-c', '--to-stdout', action="store_true", |
| 701 | help='Write output into stdout instead of modifying files ' |
| 702 | 'in-place (imply quiet mode)') |
| 703 | parser.add_argument( |
| 704 | '-B', '--no-backup', action="store_true", |
| 705 | help="Don't create .old backup files") |
| 706 | parser.add_argument( |
| 707 | '-C', '--no-compat', action="store_true", |
| 708 | help=f"Don't add: {INCLUDE_PYTHONCAPI_COMPAT}") |
| 709 | parser.add_argument( |
| 710 | '-d', '--download', metavar='PATH', |
| 711 | help=f'Download latest pythoncapi_compat.h file to designated PATH', |
| 712 | type=self._parse_dir_path) |
| 713 | parser.add_argument( |
| 714 | metavar='file_or_directory', dest="paths", nargs='*') |
| 715 | |
| 716 | args = parser.parse_args(args) |
| 717 | if not args.paths and not args.download: |
| 718 | self.usage(parser) |
| 719 | sys.exit(1) |
| 720 | |
| 721 | if args.to_stdout: |
| 722 | args.quiet = True |
| 723 | |
| 724 | self.args = args |
| 725 | self.operations = self._get_operations(parser) |
| 726 | |
| 727 | def main(self): |
| 728 | if self.args.paths: |
no test coverage detected