<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
U
    .e                     @   s`   d Z ddlZddlZddlZddlmZ ddlmZmZ ddl	m
Z
 dd Zdd	 Zd
d ZdS )zBLogic that powers autocompletion installed by ``pip completion``.
    N)create_main_parser)commands_dictcreate_command)get_installed_distributionsc                     s  dt jkrdS t jd  dd } tt jd }z| |d   W n tk
rZ   d Y nX ttg }zfdd| D d	 }W n tk
r   d}Y nX t }|r:|d
krt	d |dkö 
d }|r>g }  }tddD ].}|j
|r|j| dd kr||j q|r>|D ]}t| q$t	d t|}	|	jjD ]8}
|
jtjkrN|
j|
j D ]}|||
jf qlqNdd | d|d  D fdd|D } fdd|D }t| ||	jj}|rt |}dd |D }|D ]>}|d	 }|d r,|d	 dd dkr,|d7 }t| qndd |jD }||j dd |D } 
dr|D ]$}
|
jtjkrt|
j|
j 7 qtnt| ||}|rt |td fddD  t	d dS )z?Entry Point for completion of main and subcommand options.
    ZPIP_AUTO_COMPLETENZ
COMP_WORDS   Z
COMP_CWORD c                    s   g | ]}| kr|qS  r   ).0w)subcommandsr   D/usr/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py
<listcomp>!   s      z autocomplete.<locals>.<listcomp>r   help)ZshowZ	uninstall-T)Z
local_onlyc                 S   s   g | ]}| d d qS )=r   )splitr	   xr   r   r   r   D   s     c                    s    g | ]\}}| kr||fqS r   r   )r	   r   v)	prev_optsr   r   r   E   s      c                    s"   g | ]\}}|  r||fqS r   
startswith)r	   kr   currentr   r   r   G   s     
 c                 s   s   | ]}|d fV  qdS )r   Nr   )r	   optr   r   r   	<genexpr>P   s     zautocomplete.<locals>.<genexpr>   z--r   c                 S   s   g | ]
}|j qS r   )option_list)r	   ir   r   r   r   Z   s     c                 s   s   | ]}|D ]
}|V  q
qd S Nr   )r	   itor   r   r   r   \   s        c                    s   g | ]}|  r|qS r   r   r   r   r   r   r   g   s     
 )osenvironr   int
IndexErrorlistr   r   sysexitr   lowerr   keyappendprintr   parserZoption_list_allr   optparseSUPPRESS_HELPZ
_long_optsZ_short_optsnargsget_path_completion_typeauto_complete_pathsZoption_groupsr   join)cwordscwordZoptionsZsubcommand_namer/   Zshould_list_installedZ	installedZlcZdistZ
subcommandr   Zopt_strcompletion_typeZoptionZ	opt_labeloptsr   )r   r   r   r   autocomplete   s    





  
 
r:   c                 C   s   |dk s| |d   dsdS |D ]n}|jtjkr4q"t|dD ]L}| |d  dd |krB|jrtdd |jdD rB|j    S qBq"dS )	aL  Get the type of path completion (``file``, ``dir``, ``path`` or None)

    :param cwords: same as the environmental variable ``COMP_WORDS``
    :param cword: same as the environmental variable ``COMP_CWORD``
    :param opts: The available options to check
    :return: path completion type (``file``, ``dir``, ``path`` or None)
    r   r   N/r   r   c                 s   s   | ]}|d kV  qdS ))pathfiledirNr   r   r   r   r   r   z   s   z+get_path_completion_type.<locals>.<genexpr>)r   r   r0   r1   strr   metavarany)r6   r7   r9   r   r"   r   r   r   r3   k   s    
r3   c                 #   s   t j| \} t j|}t |t js.dS t j   fddt |D }|D ]`}t j||}t jt j||}|dkrt j	|r|V  qVt j
|rVt j|dV  qVdS )ao  If ``completion_type`` is ``file`` or ``path``, list all regular files
    and directories starting with ``current``; otherwise only list directories
    starting with ``current``.

    :param current: The word to be completed
    :param completion_type: path completion type(`file`, `path` or `dir`)i
    :return: A generator of regular files and/or directories
    Nc                 3   s$   | ]}t j| r|V  qd S r    )r$   r<   normcaser   r   filenamer   r   r      s    z&auto_complete_paths.<locals>.<genexpr>r>   r   )r$   r<   r   abspathaccessR_OKrB   listdirr5   isfileisdir)r   r8   Z	directoryZcurrent_pathZ	file_listfr   Z	comp_filer   rC   r   r4      s    	r4   )__doc__r0   r$   r)   Zpip._internal.cli.main_parserr   Zpip._internal.commandsr   r   Zpip._internal.utils.miscr   r:   r3   r4   r   r   r   r   <module>   s   [