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

Method parse_args

Lib/optparse.py:1345–1382  ·  view source on GitHub ↗

parse_args(args : [string] = sys.argv[1:], values : Values = None) -> (values : Values, args : [string]) Parse the command-line options found in 'args' (default: sys.argv[1:]). Any errors result in a call to 'error()', which by default pr

(self, args=None, values=None)

Source from the content-addressed store, hash-verified

1343 return args[:] # don't modify caller's list
1344
1345 def parse_args(self, args=None, values=None):
1346 """
1347 parse_args(args : [string] = sys.argv[1:],
1348 values : Values = None)
1349 -> (values : Values, args : [string])
1350
1351 Parse the command-line options found in 'args' (default:
1352 sys.argv[1:]). Any errors result in a call to 'error()', which
1353 by default prints the usage message to stderr and calls
1354 sys.exit() with an error message. On success returns a pair
1355 (values, args) where 'values' is a Values instance (with all
1356 your option values) and 'args' is the list of arguments left
1357 over after parsing options.
1358 """
1359 rargs = self._get_args(args)
1360 if values is None:
1361 values = self.get_default_values()
1362
1363 # Store the halves of the argument list as attributes for the
1364 # convenience of callbacks:
1365 # rargs
1366 # the rest of the command-line (the "r" stands for
1367 # "remaining" or "right-hand")
1368 # largs
1369 # the leftover arguments -- ie. what's left after removing
1370 # options and their arguments (the "l" stands for "leftover"
1371 # or "left-hand")
1372 self.rargs = rargs
1373 self.largs = largs = []
1374 self.values = values
1375
1376 try:
1377 self._process_args(largs, rargs, values)
1378 except (BadOptionError, OptionValueError) as err:
1379 self.error(str(err))
1380
1381 args = largs + rargs
1382 return self.check_values(values, args)
1383
1384 def check_values(self, values, args):
1385 """

Callers 8

mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.45
mainFunction · 0.45
code.pyFile · 0.45
deccheck.pyFile · 0.45
asdl_c.pyFile · 0.45
make_symlinks.pyFile · 0.45

Calls 6

_get_argsMethod · 0.95
get_default_valuesMethod · 0.95
_process_argsMethod · 0.95
errorMethod · 0.95
check_valuesMethod · 0.95
strFunction · 0.85

Tested by

no test coverage detected