MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _process_args

Method _process_args

tools/python-3.11.9-amd64/Lib/optparse.py:1407–1456  ·  view source on GitHub ↗

_process_args(largs : [string], rargs : [string], values : Values) Process command-line arguments and populate 'values', consuming options and arguments from 'rargs'. If 'allow_interspersed_args' is false, stop at the

(self, largs, rargs, values)

Source from the content-addressed store, hash-verified

1405 return (values, args)
1406
1407 def _process_args(self, largs, rargs, values):
1408 """_process_args(largs : [string],
1409 rargs : [string],
1410 values : Values)
1411
1412 Process command-line arguments and populate 'values', consuming
1413 options and arguments from 'rargs'. If 'allow_interspersed_args' is
1414 false, stop at the first non-option argument. If true, accumulate any
1415 interspersed non-option arguments in 'largs'.
1416 """
1417 while rargs:
1418 arg = rargs[0]
1419 # We handle bare "--" explicitly, and bare "-" is handled by the
1420 # standard arg handler since the short arg case ensures that the
1421 # len of the opt string is greater than 1.
1422 if arg == "--":
1423 del rargs[0]
1424 return
1425 elif arg[0:2] == "--":
1426 # process a single long option (possibly with value(s))
1427 self._process_long_opt(rargs, values)
1428 elif arg[:1] == "-" and len(arg) > 1:
1429 # process a cluster of short options (possibly with
1430 # value(s) for the last one only)
1431 self._process_short_opts(rargs, values)
1432 elif self.allow_interspersed_args:
1433 largs.append(arg)
1434 del rargs[0]
1435 else:
1436 return # stop now, leave this arg in rargs
1437
1438 # Say this is the original argument list:
1439 # [arg0, arg1, ..., arg(i-1), arg(i), arg(i+1), ..., arg(N-1)]
1440 # ^
1441 # (we are about to process arg(i)).
1442 #
1443 # Then rargs is [arg(i), ..., arg(N-1)] and largs is a *subset* of
1444 # [arg0, ..., arg(i-1)] (any options and their arguments will have
1445 # been removed from largs).
1446 #
1447 # The while loop will usually consume 1 or more arguments per pass.
1448 # If it consumes 1 (eg. arg is an option that takes no arguments),
1449 # then after _process_arg() is done the situation is:
1450 #
1451 # largs = subset of [arg0, ..., arg(i)]
1452 # rargs = [arg(i+1), ..., arg(N-1)]
1453 #
1454 # If allow_interspersed_args is false, largs will always be
1455 # *empty* -- still a subset of [arg0, ..., arg(i-1)], but
1456 # not a very interesting subset!
1457
1458 def _match_long_opt(self, opt):
1459 """_match_long_opt(opt : string) -> string

Callers 1

parse_argsMethod · 0.95

Calls 3

_process_long_optMethod · 0.95
_process_short_optsMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected