(self, rargs, values)
| 1455 | return _match_abbrev(opt, self._long_opt) |
| 1456 | |
| 1457 | def _process_long_opt(self, rargs, values): |
| 1458 | arg = rargs.pop(0) |
| 1459 | |
| 1460 | # Value explicitly attached to arg? Pretend it's the next |
| 1461 | # argument. |
| 1462 | if "=" in arg: |
| 1463 | (opt, next_arg) = arg.split("=", 1) |
| 1464 | rargs.insert(0, next_arg) |
| 1465 | had_explicit_value = True |
| 1466 | else: |
| 1467 | opt = arg |
| 1468 | had_explicit_value = False |
| 1469 | |
| 1470 | opt = self._match_long_opt(opt) |
| 1471 | option = self._long_opt[opt] |
| 1472 | if option.takes_value(): |
| 1473 | nargs = option.nargs |
| 1474 | if len(rargs) < nargs: |
| 1475 | self.error(ngettext( |
| 1476 | "%(option)s option requires %(number)d argument", |
| 1477 | "%(option)s option requires %(number)d arguments", |
| 1478 | nargs) % {"option": opt, "number": nargs}) |
| 1479 | elif nargs == 1: |
| 1480 | value = rargs.pop(0) |
| 1481 | else: |
| 1482 | value = tuple(rargs[0:nargs]) |
| 1483 | del rargs[0:nargs] |
| 1484 | |
| 1485 | elif had_explicit_value: |
| 1486 | self.error(_("%s option does not take a value") % opt) |
| 1487 | |
| 1488 | else: |
| 1489 | value = None |
| 1490 | |
| 1491 | option.process(opt, value, values, self) |
| 1492 | |
| 1493 | def _process_short_opts(self, rargs, values): |
| 1494 | arg = rargs.pop(0) |
no test coverage detected