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