MCPcopy Index your code
hub / github.com/RustPython/RustPython / _parse_args

Function _parse_args

Lib/test/libregrtest/cmdline.py:428–585  ·  view source on GitHub ↗
(args, **kwargs)

Source from the content-addressed store, hash-verified

426
427
428def _parse_args(args, **kwargs):
429 # Defaults
430 ns = Namespace()
431 for k, v in kwargs.items():
432 if not hasattr(ns, k):
433 raise TypeError('%r is an invalid keyword argument '
434 'for this function' % k)
435 setattr(ns, k, v)
436
437 parser = _create_parser()
438 # Issue #14191: argparse doesn't support "intermixed" positional and
439 # optional arguments. Use parse_known_args() as workaround.
440 ns.args = parser.parse_known_args(args=args, namespace=ns)[1]
441 for arg in ns.args:
442 if arg.startswith('-'):
443 parser.error("unrecognized arguments: %s" % arg)
444
445 if ns.timeout is not None:
446 # Support "--timeout=" (no value) so Makefile.pre.pre TESTTIMEOUT
447 # can be used by "make buildbottest" and "make test".
448 if ns.timeout != "":
449 try:
450 ns.timeout = float(ns.timeout)
451 except ValueError:
452 parser.error(f"invalid timeout value: {ns.timeout!r}")
453 else:
454 ns.timeout = None
455
456 # Continuous Integration (CI): common options for fast/slow CI modes
457 if ns.slow_ci or ns.fast_ci:
458 # Similar to options:
459 # -j0 --randomize --fail-env-changed --rerun --slowest --verbose3
460 if ns.use_mp is None:
461 ns.use_mp = 0
462 ns.randomize = True
463 ns.fail_env_changed = True
464 if ns.python is None:
465 ns.rerun = True
466 ns.print_slow = True
467 if not ns.verbose:
468 ns.verbose3 = True
469 else:
470 # --verbose has the priority over --verbose3
471 pass
472 else:
473 ns._add_python_opts = False
474
475 # --singleprocess overrides -jN option
476 if ns.single_process:
477 ns.use_mp = None
478
479 # When both --slow-ci and --fast-ci options are present,
480 # --slow-ci has the priority
481 if ns.slow_ci:
482 # Similar to: -u "all" --timeout=1200
483 if ns.use is None:
484 ns.use = []
485 ns.use.insert(0, ['all'])

Callers 1

mainFunction · 0.70

Calls 14

hasattrFunction · 0.85
setattrFunction · 0.85
parse_known_argsMethod · 0.80
NamespaceClass · 0.70
_create_parserFunction · 0.70
printFunction · 0.50
itemsMethod · 0.45
startswithMethod · 0.45
errorMethod · 0.45
insertMethod · 0.45
splitMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected