MCPcopy Index your code
hub / github.com/python/cpython / _process_long_opt

Method _process_long_opt

Lib/optparse.py:1457–1491  ·  view source on GitHub ↗
(self, rargs, values)

Source from the content-addressed store, hash-verified

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)

Callers 1

_process_argsMethod · 0.95

Calls 9

_match_long_optMethod · 0.95
errorMethod · 0.95
ngettextFunction · 0.90
takes_valueMethod · 0.80
_Function · 0.50
popMethod · 0.45
splitMethod · 0.45
insertMethod · 0.45
processMethod · 0.45

Tested by

no test coverage detected