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

Function _script

Lib/site.py:724–776  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

site.pyFile · 0.85

Calls 7

getuserbaseFunction · 0.85
getusersitepackagesFunction · 0.85
existsFunction · 0.70
exitMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45
dedentMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…