MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / test

Function test

tools/python-3.11.9-amd64/Lib/modulefinder.py:603–659  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

modulefinder.pyFile · 0.70

Calls 9

import_hookMethod · 0.95
load_fileMethod · 0.95
run_scriptMethod · 0.95
reportMethod · 0.95
ModuleFinderClass · 0.70
printFunction · 0.50
getoptMethod · 0.45
splitMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected