$10 GRAYBYTE WORDPRESS FILE MANAGER $78

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.217.254 | ADMIN IP 216.73.216.157
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : mail

/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/cli/

HOME
Current File : /opt/alt/python311/lib/python3.11/site-packages/pip/_internal/cli//main_parser.py
"""A single place for constructing and exposing the main parser
"""

import os
import sys
from typing import List, Tuple

from pip._internal.cli import cmdoptions
from pip._internal.cli.parser import ConfigOptionParser, UpdatingDefaultsHelpFormatter
from pip._internal.commands import commands_dict, get_similar_commands
from pip._internal.exceptions import CommandError
from pip._internal.utils.misc import get_pip_version, get_prog

__all__ = ["create_main_parser", "parse_command"]


def create_main_parser() -> ConfigOptionParser:
    """Creates and returns the main parser for pip's CLI"""

    parser = ConfigOptionParser(
        usage="\n%prog <command> [options]",
        add_help_option=False,
        formatter=UpdatingDefaultsHelpFormatter(),
        name="global",
        prog=get_prog(),
    )
    parser.disable_interspersed_args()

    parser.version = get_pip_version()

    # add the general options
    gen_opts = cmdoptions.make_option_group(cmdoptions.general_group, parser)
    parser.add_option_group(gen_opts)

    # so the help formatter knows
    parser.main = True  # type: ignore

    # create command listing for description
    description = [""] + [
        f"{name:27} {command_info.summary}"
        for name, command_info in commands_dict.items()
    ]
    parser.description = "\n".join(description)

    return parser


def parse_command(args: List[str]) -> Tuple[str, List[str]]:
    parser = create_main_parser()

    # Note: parser calls disable_interspersed_args(), so the result of this
    # call is to split the initial args into the general options before the
    # subcommand and everything else.
    # For example:
    #  args: ['--timeout=5', 'install', '--user', 'INITools']
    #  general_options: ['--timeout==5']
    #  args_else: ['install', '--user', 'INITools']
    general_options, args_else = parser.parse_args(args)

    # --version
    if general_options.version:
        sys.stdout.write(parser.version)
        sys.stdout.write(os.linesep)
        sys.exit()

    # pip || pip help -> print_help()
    if not args_else or (args_else[0] == "help" and len(args_else) == 1):
        parser.print_help()
        sys.exit()

    # the subcommand name
    cmd_name = args_else[0]

    if cmd_name not in commands_dict:
        guess = get_similar_commands(cmd_name)

        msg = [f'unknown command "{cmd_name}"']
        if guess:
            msg.append(f'maybe you meant "{guess}"')

        raise CommandError(" - ".join(msg))

    # all the args without the subcommand
    cmd_args = args[:]
    cmd_args.remove(cmd_name)

    return cmd_name, cmd_args


Current_dir [ NOT WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
10 Feb 2026 9.37 AM
root / linksafe
0755
__pycache__
--
10 Feb 2026 9.37 AM
root / linksafe
0755
__init__.py
0.129 KB
7 Jan 2026 11.10 PM
root / linksafe
0644
autocompletion.py
6.249 KB
7 Jan 2026 11.10 PM
root / linksafe
0644
base_command.py
7.607 KB
7 Jan 2026 11.10 PM
root / linksafe
0644
cmdoptions.py
27.726 KB
7 Jan 2026 11.10 PM
root / linksafe
0644
command_context.py
0.742 KB
7 Jan 2026 11.10 PM
root / linksafe
0644
main.py
2.414 KB
7 Jan 2026 11.10 PM
root / linksafe
0644
main_parser.py
2.553 KB
7 Jan 2026 11.10 PM
root / linksafe
0644
parser.py
10.535 KB
7 Jan 2026 11.10 PM
root / linksafe
0644
progress_bars.py
8.105 KB
7 Jan 2026 11.10 PM
root / linksafe
0644
req_command.py
16.696 KB
7 Jan 2026 11.10 PM
root / linksafe
0644
spinners.py
4.957 KB
7 Jan 2026 11.10 PM
root / linksafe
0644
status_codes.py
0.113 KB
7 Jan 2026 11.10 PM
root / linksafe
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF