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

Function _script

Lib/site.py:725–777  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

723 main()
724
725def _script():
726 help = """\
727 %s [--user-base] [--user-site]
728
729 Without arguments print some useful information
730 With arguments print the value of USER_BASE and/or USER_SITE separated
731 by '%s'.
732
733 Exit codes with --user-base or --user-site:
734 0 - user site directory is enabled
735 1 - user site directory is disabled by user
736 2 - user site directory is disabled by super user
737 or for security reasons
738 >2 - unknown error
739 """
740 args = sys.argv[1:]
741 if not args:
742 user_base = getuserbase()
743 user_site = getusersitepackages()
744 print("sys.path = [")
745 for dir in sys.path:
746 print(" %r," % (dir,))
747 print("]")
748 def exists(path):
749 if path is not None and os.path.isdir(path):
750 return "exists"
751 else:
752 return "doesn't exist"
753 print(f"USER_BASE: {user_base!r} ({exists(user_base)})")
754 print(f"USER_SITE: {user_site!r} ({exists(user_site)})")
755 print(f"ENABLE_USER_SITE: {ENABLE_USER_SITE!r}")
756 sys.exit(0)
757
758 buffer = []
759 if '--user-base' in args:
760 buffer.append(USER_BASE)
761 if '--user-site' in args:
762 buffer.append(USER_SITE)
763
764 if buffer:
765 print(os.pathsep.join(buffer))
766 if ENABLE_USER_SITE:
767 sys.exit(0)
768 elif ENABLE_USER_SITE is False:
769 sys.exit(1)
770 elif ENABLE_USER_SITE is None:
771 sys.exit(2)
772 else:
773 sys.exit(3)
774 else:
775 import textwrap
776 print(textwrap.dedent(help % (sys.argv[0], os.pathsep)))
777 sys.exit(10)
778
779if __name__ == '__main__':
780 _script()

Callers 1

site.pyFile · 0.85

Calls 8

getuserbaseFunction · 0.85
getusersitepackagesFunction · 0.85
dedentMethod · 0.80
existsFunction · 0.70
printFunction · 0.50
exitMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected