HEX
Server: LiteSpeed
System: Linux us-phx-web1284.main-hosting.eu 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: u300739242 (300739242)
PHP: 8.2.30
Disabled: system, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/click/__pycache__/shell_completion.cpython-37.pyc
B

�P�eH�@sUddlZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
ddlmZddlmZeejeejfeeeed
�dd�ZGdd�d�ZdZdZdZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�Zejdej ed�Z!eeed�Z"ej#eej efe$d <d6e!ej%ee!d!�d"d#�Z&eej%ej ed$�d%d&�Z'e	ee(d'�d(d)�Z)e	ee(d*�d+d,�Z*e	ej+eee(d-�d.d/�Z,eejeejfeej+ee	d0�d1d2�Z-e	ej+eeej.ej/eefefd3�d4d5�Z0dS)7�N)�gettext�)�Argument)�BaseCommand)�Context)�MultiCommand)�Option)�	Parameter)�ParameterSource)�split_arg_string)�echo)�cli�ctx_args�	prog_name�complete_var�instruction�returnc	Csf|�d�\}}}t|�}|dkr$dS|||||�}|dkrJt|���dS|dkrbt|���dSdS)aPerform shell completion for the given CLI program.

    :param cli: Command being called.
    :param ctx_args: Extra arguments to pass to
        ``cli.make_context``.
    :param prog_name: Name of the executable in the shell.
    :param complete_var: Name of the environment variable that holds
        the completion instruction.
    :param instruction: Value of ``complete_var`` with the completion
        instruction and shell, in the form ``instruction_shell``.
    :return: Status code to exit with.
    �_Nr�sourcer�complete)�	partition�get_completion_classrrr)	r
rrrr�shellrZcomp_cls�comp�r�G/opt/alt/python37/lib/python3.7/site-packages/click/shell_completion.py�shell_completesrc@sHeZdZdZdZdejeejeejdd�dd�Z	eejd�d	d
�Z
dS)�CompletionItema)Represents a completion value and metadata about the value. The
    default metadata is ``type`` to indicate special shell handling,
    and ``help`` if a shell supports showing a help string next to the
    value.

    Arbitrary parameters can be passed when creating the object, and
    accessed using ``item.attr``. If an attribute wasn't passed,
    accessing it returns ``None``.

    :param value: The completion suggestion.
    :param type: Tells the shell script to provide special completion
        support for the type. Click uses ``"dir"`` and ``"file"``.
    :param help: String shown next to the value if supported.
    :param kwargs: Arbitrary metadata. The built-in implementations
        don't use this, but custom type completions paired with custom
        shell support could use it.
    )�value�type�help�_info�plainN)rrr �kwargsrcKs||_||_||_||_dS)N)rrr r!)�selfrrr r#rrr�__init__LszCompletionItem.__init__)�namercCs|j�|�S)N)r!�get)r$r&rrr�__getattr__XszCompletionItem.__getattr__)r"N)�__name__�
__module__�__qualname__�__doc__�	__slots__�t�Any�str�Optionalr%r(rrrrr7sra�%(complete_func)s() {
    local IFS=$'\n'
    local response

    response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD %(complete_var)s=bash_complete $1)

    for completion in $response; do
        IFS=',' read type value <<< "$completion"

        if [[ $type == 'dir' ]]; then
            COMPREPLY=()
            compopt -o dirnames
        elif [[ $type == 'file' ]]; then
            COMPREPLY=()
            compopt -o default
        elif [[ $type == 'plain' ]]; then
            COMPREPLY+=($value)
        fi
    done

    return 0
}

%(complete_func)s_setup() {
    complete -o nosort -F %(complete_func)s %(prog_name)s
}

%(complete_func)s_setup;
a�#compdef %(prog_name)s

%(complete_func)s() {
    local -a completions
    local -a completions_with_descriptions
    local -a response
    (( ! $+commands[%(prog_name)s] )) && return 1

    response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) %(complete_var)s=zsh_complete %(prog_name)s)}")

    for type key descr in ${response}; do
        if [[ "$type" == "plain" ]]; then
            if [[ "$descr" == "_" ]]; then
                completions+=("$key")
            else
                completions_with_descriptions+=("$key":"$descr")
            fi
        elif [[ "$type" == "dir" ]]; then
            _path_files -/
        elif [[ "$type" == "file" ]]; then
            _path_files -f
        fi
    done

    if [ -n "$completions_with_descriptions" ]; then
        _describe -V unsorted completions_with_descriptions -U
    fi

    if [ -n "$completions" ]; then
        compadd -U -V unsorted -a completions
    fi
}

if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
    # autoload from fpath, call function directly
    %(complete_func)s "$@"
else
    # eval/source/. command, register function for later
    compdef %(complete_func)s %(prog_name)s
fi
affunction %(complete_func)s;
    set -l response (env %(complete_var)s=fish_complete COMP_WORDS=(commandline -cp) COMP_CWORD=(commandline -t) %(prog_name)s);

    for completion in $response;
        set -l metadata (string split "," $completion);

        if test $metadata[1] = "dir";
            __fish_complete_directories $metadata[2];
        else if test $metadata[1] = "file";
            __fish_complete_path $metadata[2];
        else if test $metadata[1] = "plain";
            echo $metadata[2];
        end;
    end;
end;

complete --no-files --command %(prog_name)s --arguments "(%(complete_func)s)";
c@s�eZdZUdZejeed<ejeed<eej	eej
feedd�dd�Zeed�d	d
��Z
ejeej
fd�dd�Zed�d
d�Zejejeefd�dd�Zejeeejed�dd�Zeed�dd�Zed�dd�ZdS)�
ShellCompletea�Base class for providing shell completion support. A subclass for
    a given shell will override attributes and methods to implement the
    completion instructions (``source`` and ``complete``).

    :param cli: Command being called.
    :param prog_name: Name of the executable in the shell.
    :param complete_var: Name of the environment variable that holds
        the completion instruction.

    .. versionadded:: 8.0
    r&�source_templateN)r
rrrrcCs||_||_||_||_dS)N)r
rrr)r$r
rrrrrrr%�szShellComplete.__init__)rcCs*tjdd|j�dd�tjd�}d|�d�S)zQThe name of the shell function defined by the completion
        script.
        z\W*��-r)�flagsZ_completion)�re�subr�replace�ASCII)r$�	safe_namerrr�	func_name�szShellComplete.func_namecCs|j|j|jd�S)z�Vars for formatting :attr:`source_template`.

        By default this provides ``complete_func``, ``complete_var``,
        and ``prog_name``.
        )Z
complete_funcrr)r<rr)r$rrr�source_vars�szShellComplete.source_varscCs|j|��S)z�Produce the shell script that defines the completion
        function. By default this ``%``-style formats
        :attr:`source_template` with the dict returned by
        :meth:`source_vars`.
        )r3r=)r$rrrr�szShellComplete.sourcecCst�dS)z�Use the env vars defined by the shell script to return a
        tuple of ``args, incomplete``. This must be implemented by
        subclasses.
        N)�NotImplementedError)r$rrr�get_completion_argssz!ShellComplete.get_completion_args)�args�
incompletercCs0t|j|j|j|�}t|||�\}}|�||�S)aTDetermine the context and last complete command or parameter
        from the complete args. Call that object's ``shell_complete``
        method to get the completions for the incomplete value.

        :param args: List of complete args before the incomplete value.
        :param incomplete: Value being completed. May be empty.
        )�_resolve_contextr
rr�_resolve_incompleter)r$r@rA�ctx�objrrr�get_completionss
zShellComplete.get_completions)�itemrcCst�dS)z�Format a completion item into the form recognized by the
        shell script. This must be implemented by subclasses.

        :param item: Completion item to format.
        N)r>)r$rGrrr�format_completionszShellComplete.format_completioncs4���\}}��||�}�fdd�|D�}d�|�S)z�Produce the completion data to send back to the shell.

        By default this calls :meth:`get_completion_args`, gets the
        completions, then calls :meth:`format_completion` for each
        completion.
        csg|]}��|��qSr)rH)�.0rG)r$rr�
<listcomp>&sz*ShellComplete.complete.<locals>.<listcomp>�
)r?rF�join)r$r@rAZcompletions�outr)r$rrszShellComplete.complete)r)r*r+r,r.�ClassVarr0�__annotations__r�MutableMappingr/r%�propertyr<�Dictr=r�Tuple�Listr?rrFrHrrrrrr2�s"

r2csneZdZdZdZeZedd�dd��Ze	d��fdd�Z
ejej
e	e	fd�d	d
�Zee	d�dd
�Z�ZS)�BashCompletezShell completion for Bash.�bashN)rcCs�ddl}|jdddg|jd�}t�d|j���}|dk	rn|��\}}|dks\|dkr~|dkr~tt	d�d	d
�ntt	d�d	d
�dS)NrrVz-czecho "${BASH_VERSION}")�stdoutz^(\d+)\.(\d+)\.\d+�4zCShell completion is not supported for Bash versions older than 4.4.T)�errz@Couldn't detect Bash version, shell completion is not supported.)
�
subprocess�run�PIPEr7�searchrW�decode�groupsrr)rZ�output�match�major�minorrrr�_check_version0s
zBashComplete._check_versioncs|��t���S)N)rd�superr)r$)�	__class__rrrJszBashComplete.sourcecCsVttjd�}ttjd�}|d|�}y||}Wntk
rLd}YnX||fS)N�
COMP_WORDS�
COMP_CWORDrr4)r�os�environ�int�
IndexError)r$�cwords�cwordr@rArrrr?Ns
z BashComplete.get_completion_args)rGrcCs|j�d|j��S)N�,)rr)r$rGrrrrHZszBashComplete.format_completion)r)r*r+r,r&�_SOURCE_BASHr3�staticmethodrdr0rr.rSrTr?rrH�
__classcell__rr)rfrrU*srUc@sFeZdZdZdZeZejej	e
e
fd�dd�Zee
d�dd�Z
d	S)
�ZshCompletezShell completion for Zsh.�zsh)rcCsVttjd�}ttjd�}|d|�}y||}Wntk
rLd}YnX||fS)Nrgrhrr4)rrirjrkrl)r$rmrnr@rArrrr?ds
zZshComplete.get_completion_args)rGrcCs$|j�d|j�d|jr|jnd��S)NrKr)rrr )r$rGrrrrHpszZshComplete.format_completionN)r)r*r+r,r&�_SOURCE_ZSHr3r.rSrTr0r?rrHrrrrrs^s
rsc@sFeZdZdZdZeZejej	e
e
fd�dd�Zee
d�dd�Z
d	S)
�FishCompletezShell completion for Fish.�fish)rcCsHttjd�}tjd}|dd�}|r@|r@|d|kr@|��||fS)Nrgrhr���)rrirj�pop)r$rmrAr@rrrr?zs
z FishComplete.get_completion_args)rGrcCs2|jr |j�d|j�d|j��S|j�d|j��S)Nro�	)r rr)r$rGrrrrH�szFishComplete.format_completionN)r)r*r+r,r&�_SOURCE_FISHr3r.rSrTr0r?rrHrrrrrvts
rv�ShellCompleteType)�bound)rVrwrt�_available_shells)�clsr&rcCs|dkr|j}|t|<|S)amRegister a :class:`ShellComplete` subclass under the given name.
    The name will be provided by the completion instruction environment
    variable during completion.

    :param cls: The completion class that will handle completion for the
        shell.
    :param name: Name to register the class under. Defaults to the
        class's ``name`` attribute.
    N)r&r~)rr&rrr�add_completion_class�sr�)rrcCs
t�|�S)z�Look up a registered :class:`ShellComplete` subclass by the name
    provided by the completion instruction environment variable. If the
    name isn't registered, returns ``None``.

    :param shell: Name the class is registered under.
    )r~r')rrrrr�sr)rD�paramrcCslt|t�sdS|jdk	st�|j�|j�}|jdkpj|�|j�tj	k	pj|jdkojt|t
tf�ojt|�|jkS)z�Determine if the given parameter is an argument that can still
    accept values.

    :param ctx: Invocation context for the command represented by the
        parsed complete args.
    :param param: Argument object being checked.
    FNrxr)
�
isinstancerr&�AssertionError�paramsr'�nargsZget_parameter_sourcer
ZCOMMANDLINE�tuple�list�len)rDr�rrrr�_is_incomplete_argument�s


r�)rDrrcCs|sdS|d}||jkS)z5Check if the value looks like the start of an option.Fr)Z
_opt_prefixes)rDr�crrr�_start_of_option�sr�)rDr@r�rcCslt|t�sdS|js|jrdSd}x6tt|��D]&\}}|d|jkrHPt||�r0|}q0W|dk	oj||jkS)z�Determine if the given parameter is an option that needs a value.

    :param args: List of complete args before the incomplete value.
    :param param: Option object being checked.
    FNr)	r�rZis_flag�count�	enumerate�reversedr�r��opts)rDr@r�Zlast_option�index�argrrr�_is_incomplete_option�s

r�)r
rrr@rc	Cs�d|d<|j||��f|�}|j|j}x�|r�|j}t|t�r�|js�|�||�\}}}|dkrb|S|j|||dd�}|j|j}q�|}xB|r�|�||�\}}}|dkr�|S|j|||dddd�}|j}q�W|}|j|j�}q*Pq*W|S)a`Produce the context hierarchy starting with the command and
    traversing the complete arguments. This only follows the commands,
    it doesn't trigger input prompts or callbacks.

    :param cli: Command being called.
    :param prog_name: Name of the executable in the shell.
    :param args: List of complete args before the incomplete value.
    T�resilient_parsingN)�parentr�F)r�Zallow_extra_args�allow_interspersed_argsr�)	Zmake_context�copyZprotected_argsr@�commandr�r�chainZresolve_command)	r
rrr@rDr�r&�cmdZsub_ctxrrrrB�s:

rB)rDr@rArcCs�|dkrd}n,d|kr:t||�r:|�d�\}}}|�|�d|krVt||�rV|j|fS|j�|�}x |D]}t|||�rh||fSqhWx|D]}t||�r�||fSq�W|j|fS)ahFind the Click object that will handle the completion of the
    incomplete value. Return the object and the incomplete value.

    :param ctx: Invocation context for the command represented by
        the parsed complete args.
    :param args: List of complete args before the incomplete value.
    :param incomplete: Value being completed. May be empty.
    �=r4z--)r�r�appendr��
get_paramsr�r�)rDr@rAr&rr�r�rrrrC(s




rC)N)1rir7�typingr.rr�corerrrrrr	r
�parserr�utilsrrPr0r/rkrrrprur{r2rUrsrv�TypeVar�Typer|r~rRrOr1r�r�boolr�r�rTr�rBrS�UnionrCrrrr�<module>sX D,j4 
	5