(prog=None)
| 1813 | raise ValueError('mutually exclusive groups cannot be nested') |
| 1814 | |
| 1815 | def _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 | |
| 1837 | class ArgumentParser(_AttributeHolder, _ActionsContainer): |
no test coverage detected