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

Function test

Lib/modulefinder.py:617–673  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

615
616
617def test():
618 # Parse command line
619 import getopt
620 try:
621 opts, args = getopt.getopt(sys.argv[1:], "dmp:qx:")
622 except getopt.error as msg:
623 print(msg)
624 return
625
626 # Process options
627 debug = 1
628 domods = 0
629 addpath = []
630 exclude = []
631 for o, a in opts:
632 if o == '-d':
633 debug = debug + 1
634 if o == '-m':
635 domods = 1
636 if o == '-p':
637 addpath = addpath + a.split(os.pathsep)
638 if o == '-q':
639 debug = 0
640 if o == '-x':
641 exclude.append(a)
642
643 # Provide default arguments
644 if not args:
645 script = "hello.py"
646 else:
647 script = args[0]
648
649 # Set the path based on sys.path and the script directory
650 path = sys.path[:]
651 path[0] = os.path.dirname(script)
652 path = addpath + path
653 if debug > 1:
654 print("path:")
655 for item in path:
656 print(" ", repr(item))
657
658 # Create the module finder and turn its crank
659 mf = ModuleFinder(path, debug, exclude)
660 for arg in args[1:]:
661 if arg == '-m':
662 domods = 1
663 continue
664 if domods:
665 if arg[-2:] == '.*':
666 mf.import_hook(arg[:-2], None, ["*"])
667 else:
668 mf.import_hook(arg)
669 else:
670 mf.load_file(arg)
671 mf.run_script(script)
672 mf.report()
673 return mf # for -i debugging
674

Callers 1

modulefinder.pyFile · 0.70

Calls 8

import_hookMethod · 0.95
load_fileMethod · 0.95
run_scriptMethod · 0.95
reportMethod · 0.95
ModuleFinderClass · 0.85
splitMethod · 0.45
appendMethod · 0.45
dirnameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…