HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/click_repl/__pycache__/utils.cpython-310.pyc
o

%we��@s�ddlZddlZddlZddlZddlmZddlmZmZgd�Z	ej
dkr0ddlmZm
Z
nddlmZm
Z
d!dd	�ZiZd"dd�Zd!d
d�Zd!dd�Zdd�Zdd�Zegd�ed�egd�ed�	
	
d#dd�Zdd�Zdd�Zdd �ZdS)$�N)�defaultdict�)�CommandLineParserError�ExitReplException)
�_execute_internal_and_sys_cmds�_exit_internal�_get_registered_target�_help_internal�_resolve_context�_register_internal_command�dispatch_repl_commands�handle_internal_commands�split_arg_string�exit)�r)�Iterable�MappingcCs�|r^|j}t|tj�rY|js-|�||�\}}}|dur|S|j|||dd�}|j|j}n/|rN|�||�\}}}|dur>|S|j|||dddd�}|j}|s/|}g|j�|j�}n	|S|s|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 args: List of complete args before the incomplete value.
    :param cli_ctx: `click.Context` object of the CLI group
    NT)�parent�resilient_parsingF)r�allow_extra_args�allow_interspersed_argsr)	�command�
isinstance�click�MultiCommand�chain�resolve_command�make_context�protected_args�args)r�ctxr�name�cmd�sub_ctx�r$�I/home/arjun/projects/env/lib/python3.10/site-packages/click_repl/utils.pyr
 s:	���"r
TcCsZtj||d�}d|_d|_g}z
|D]}|�|�qW|Sty,|�|j�Y|Sw)a�Split an argument string as with :func:`shlex.split`, but don't
    fail if the string is incomplete. Ignores a missing closing quote or
    incomplete escape sequence and uses the partial token as-is.
    .. code-block:: python
        split_arg_string("example 'my file")
        ["example", "my file"]
        split_arg_string("example my\")
        ["example", "my"]
    :param string: String to split.
    )�posixT�)�shlex�whitespace_split�
commenters�append�
ValueError�token)�stringr&�lex�outr-r$r$r%rQs���rcCsft|d�s	td��t|t�r|g}nt|t�st|t�s&td�t|�j���|D]}||ft	|<q(dS)N�__call__z#Internal command must be a callablez="names" must be a string, or an iterable object, but got "{}")
�hasattrr,r�strrr�format�type�__name__�_internal_commands)�names�target�descriptionr!r$r$r%rns

���rcCst�|�}|r|dS|S)Nr)r7�get)r!�default�target_infor$r$r%r�s
rcCst���N)rr$r$r$r%r�srcCs�t��}|�d�|��|�d��
|�d�Wd�n1s"wY|�d��/|�d�tt�}t�	�D]
\}}||d�
|�q:|�dd�|�	�D��Wd�n1s^wY|��}|S)	Nz	REPL helpzExternal Commandsz!prefix external commands with "!"zInternal Commandsz!prefix internal commands with ":"rcss.�|]\}}d�tdjt|���|fVqdS)z, z:{}N)�join�mapr4�sorted)�.0r:�	mnemonicsr$r$r%�	<genexpr>�s���
�z!_help_internal.<locals>.<genexpr>)
r�
HelpFormatter�
write_heading�indent�section�
write_textr�listr7�itemsr+�write_dl�getvalue)�	formatter�
info_table�mnemonicr=�valr$r$r%r	�s"
�


��r	)�q�quitrzexits the repl)�?�h�helpz!displays general help informationc
Csf|rt|�rdS|rt|�}t|t�rt�|�dSzt|�WSty2}ztd�	|���d}~ww)z_
    Executes internal, system, and all the other registered click commands from the input
    Nz{})
rr
rr3r�echorr,rr4)r�allow_internal_commands�allow_system_commands�result�er$r$r%r�s


��rcCs
t�dS)z
Exit the replN)rr$r$r$r%r�s
rcCs$|�d�rt�|dd��dSdS)zo
    Execute system commands entered in the repl.

    System commands are all commands starting with "!".
    �!rNTF)�
startswith�os�system)rr$r$r%r�s
rcCs0|�d�rt|dd�dd�}|r|�SdSdS)ze
    Run repl-internal commands.

    Repl-internal commands are all commands starting with ":".
    �:rN)r<)r]r)rr9r$r$r%r
�s
�r
r>)T)TT)rr^r(�sys�collectionsr�
exceptionsrr�__all__�version_info�collections.abcrrr
r7rrrrr	rrrr
r$r$r$r%�<module>s6

.



�
�