(self,
option_strings,
dest,
default=None,
required=False,
help=None,
deprecated=False)
| 986 | |
| 987 | class BooleanOptionalAction(Action): |
| 988 | def __init__(self, |
| 989 | option_strings, |
| 990 | dest, |
| 991 | default=None, |
| 992 | required=False, |
| 993 | help=None, |
| 994 | deprecated=False): |
| 995 | |
| 996 | _option_strings = [] |
| 997 | neg_option_strings = [] |
| 998 | for option_string in option_strings: |
| 999 | _option_strings.append(option_string) |
| 1000 | |
| 1001 | if len(option_string) > 2 and option_string[0] == option_string[1]: |
| 1002 | # two-dash long option: '--foo' -> '--no-foo' |
| 1003 | if option_string.startswith('no-', 2): |
| 1004 | raise ValueError(f'invalid option name {option_string!r} ' |
| 1005 | f'for BooleanOptionalAction') |
| 1006 | option_string = option_string[:2] + 'no-' + option_string[2:] |
| 1007 | _option_strings.append(option_string) |
| 1008 | neg_option_strings.append(option_string) |
| 1009 | elif len(option_string) > 2 and option_string[0] != option_string[1]: |
| 1010 | # single-dash long option: '-foo' -> '-nofoo' |
| 1011 | if option_string.startswith('no', 1): |
| 1012 | raise ValueError(f'invalid option name {option_string!r} ' |
| 1013 | f'for BooleanOptionalAction') |
| 1014 | option_string = option_string[:1] + 'no' + option_string[1:] |
| 1015 | _option_strings.append(option_string) |
| 1016 | neg_option_strings.append(option_string) |
| 1017 | |
| 1018 | super().__init__( |
| 1019 | option_strings=_option_strings, |
| 1020 | dest=dest, |
| 1021 | nargs=0, |
| 1022 | default=default, |
| 1023 | required=required, |
| 1024 | help=help, |
| 1025 | deprecated=deprecated) |
| 1026 | self.neg_option_strings = neg_option_strings |
| 1027 | |
| 1028 | |
| 1029 | def __call__(self, parser, namespace, values, option_string=None): |
nothing calls this directly
no test coverage detected