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

Function _prog_name

Lib/argparse.py:1815–1834  ·  view source on GitHub ↗
(prog=None)

Source from the content-addressed store, hash-verified

1813 raise ValueError('mutually exclusive groups cannot be nested')
1814
1815def _prog_name(prog=None):
1816 if prog is not None:
1817 return prog
1818 arg0 = _sys.argv[0]
1819 try:
1820 modspec = _sys.modules['__main__'].__spec__
1821 except (KeyError, AttributeError):
1822 # possibly PYTHONSTARTUP or -X presite or other weird edge case
1823 # no good answer here, so fall back to the default
1824 modspec = None
1825 if modspec is None:
1826 # simple script
1827 return _os.path.basename(arg0)
1828 py = _os.path.basename(_sys.executable)
1829 if modspec.name != '__main__':
1830 # imported module or package
1831 modname = modspec.name.removesuffix('.__main__')
1832 return f'{py} -m {modname}'
1833 # directory or ZIP file
1834 return f'{py} {arg0}'
1835
1836
1837class ArgumentParser(_AttributeHolder, _ActionsContainer):

Callers 1

__init__Method · 0.85

Calls 2

basenameMethod · 0.80
removesuffixMethod · 0.45

Tested by

no test coverage detected