For every `--no-OPTION` in `no_options`, set `args.OPTION` to its default value. This allows for un-setting of options, e.g., specified in config.
(self, no_options)
| 355 | self.args.auth = ExplicitNullAuth() |
| 356 | |
| 357 | def _apply_no_options(self, no_options): |
| 358 | """For every `--no-OPTION` in `no_options`, set `args.OPTION` to |
| 359 | its default value. This allows for un-setting of options, e.g., |
| 360 | specified in config. |
| 361 | |
| 362 | """ |
| 363 | invalid = [] |
| 364 | |
| 365 | for option in no_options: |
| 366 | if not option.startswith('--no-'): |
| 367 | invalid.append(option) |
| 368 | continue |
| 369 | |
| 370 | # --no-option => --option |
| 371 | inverted = '--' + option[5:] |
| 372 | for action in self._actions: |
| 373 | if inverted in action.option_strings: |
| 374 | setattr(self.args, action.dest, action.default) |
| 375 | break |
| 376 | else: |
| 377 | invalid.append(option) |
| 378 | |
| 379 | if invalid: |
| 380 | self.error(f'unrecognized arguments: {" ".join(invalid)}') |
| 381 | |
| 382 | def _body_from_file(self, fd): |
| 383 | """Read the data from a file-like object. |