(self, arg: str, state: _ParsingState)
| 468 | return value |
| 469 | |
| 470 | def _process_opts(self, arg: str, state: _ParsingState) -> None: |
| 471 | explicit_value = None |
| 472 | # Long option handling happens in two parts. The first part is |
| 473 | # supporting explicitly attached values. In any case, we will try |
| 474 | # to long match the option first. |
| 475 | if "=" in arg: |
| 476 | long_opt, explicit_value = arg.split("=", 1) |
| 477 | else: |
| 478 | long_opt = arg |
| 479 | norm_long_opt = _normalize_opt(long_opt, self.ctx) |
| 480 | |
| 481 | # At this point we will match the (assumed) long option through |
| 482 | # the long option matching code. Note that this allows options |
| 483 | # like "-foo" to be matched as long options. |
| 484 | try: |
| 485 | self._match_long_opt(norm_long_opt, explicit_value, state) |
| 486 | except NoSuchOption: |
| 487 | # At this point the long option matching failed, and we need |
| 488 | # to try with short options. However there is a special rule |
| 489 | # which says, that if we have a two character options prefix |
| 490 | # (applies to "--foo" for instance), we do not dispatch to the |
| 491 | # short option code and will instead raise the no option |
| 492 | # error. |
| 493 | if arg[:2] not in self._opt_prefixes: |
| 494 | self._match_short_opt(arg, state) |
| 495 | return |
| 496 | |
| 497 | if not self.ignore_unknown_options: |
| 498 | raise |
| 499 | |
| 500 | state.largs.append(arg) |
| 501 | |
| 502 | |
| 503 | def __getattr__(name: str) -> object: |
no test coverage detected