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)
| 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 | """ |
no test coverage detected