관리-도구
편집 파일: autocompletion.cpython-39.opt-1.pyc
a ����[��f�����������������������@���s����d�Z�ddlZddlZddlZddlmZ�ddlmZmZm Z m Z �ddlmZ�ddl mZmZ�ddlmZ�dd�d d �Ze e�eee�e e�d�dd �Zeeee�d�dd�ZdS�)zBLogic that powers autocompletion installed by ``pip completion``. �����N)�chain)�Any�Iterable�List�Optional)�create_main_parser)� commands_dict�create_command)�get_default_environment)�returnc���������������������s���dt�jvrdS�t�jd����dd���tt�jd��}�z�|�d����W�n�tyX���d��Y�n0�t��}tt�}g�}d}�D�]}||v�rt|}�q�qt|du�r|dkr�t� d����� d��o�|d v�}|�rt��}��������fd d�|j dd �D��}|�r|D�]} t| ��q�t� d��t|�} | jjD�]8}|jtjk�r|j|j�D�]}|�||jf���q:�qdd���d|�d���D����fdd�|D��}��fdd�|D��}t�|�| jj�} | �r�t��| �}dd��|D��}|D�]>}|d�}|d��r�|d�dd��dk�r�|d7�}t|���q�n�dd��|jD��}|�|j��t�|�}��� d��rf|D�]$}|jtjk�r>||j|j�7�}�q>n t�|�|�} | �r�tt��| ��}td���fdd�|D�����t� d��dS�)z:Entry Point for completion of main and subcommand options.ZPIP_AUTO_COMPLETENZ COMP_WORDS����Z COMP_CWORD���help�-)ZshowZ uninstallc��������������������s0���g�|�](}|j����r|j���d�d��vr|j��qS�)r���N)Zcanonical_name� startswith)�.0�dist)�cwords�lc���D/usr/lib/python3.9/site-packages/pip/_internal/cli/autocompletion.py� <listcomp>2���s����z autocomplete.<locals>.<listcomp>T)Z local_onlyc�����������������S���s���g�|�]}|��d��d��qS�)�=r���)�split�r����xr���r���r���r���F��������c��������������������s ���g�|�]\}}|��vr||f�qS�r���r���)r���r����v)� prev_optsr���r���r���G���r���c��������������������s"���g�|�]\}}|�����r||f�qS�r����r���)r����kr�����currentr���r���r���I���r���c�����������������S���s���g�|�]}|d�f�qS�)r���r���)r����pathr���r���r���r���T���r���r�������z--r���c�����������������S���s���g�|�] }|j��qS�r���)�option_list)r����ir���r���r���r���^���r���� c��������������������s���g�|�]}|�����r|�qS�r���r���r���r!���r���r���r���k���r���) �os�environr����int� IndexErrorr����listr����sys�exitr���r ����lowerZiter_installed_distributions�printr ����parserZoption_list_allr����optparse� SUPPRESS_HELPZ _long_optsZ_short_opts�append�nargs�get_path_completion_type�auto_complete_pathsZ option_groupsr%���r���� from_iterable�join)�cwordr1����subcommands�optionsZsubcommand_nameZwordZshould_list_installed�envZ installedr���Z subcommand�optZopt_str�completion_type�paths�optionZ opt_label�optsZflattened_optsr���)r"���r���r���r���r����autocomplete���s~���� � � rC���)r���r:���rB���r���c�����������������C���s����|dk�s|�|d����d�sdS�|D�]n}|jtjkr4q"t|��d�D�]L}|�|d���d�d�|krB|jr�tdd��|j�d�D���rB|j����S�qBq"dS�) 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�v�V��qdS�))r#����file�dirNr���r���r���r���r���� <genexpr>����s���z+get_path_completion_type.<locals>.<genexpr>)r���r���r2���r3����strr����metavar�any)r���r:���rB���r>����or���r���r���r6���o���s���� �r6���)r"���r?���r���c�����������������#���s����t�j�|��\}��t�j�|�}t��|t�j�s.dS�t�j��������fdd�t��|�D��}|D�]`}t�j�||�}t�j�t�j�||��}|dkr�t�j� |�r�|V��qVt�j� |�rVt�j�|d�V��qVdS�)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��qd�S�)N)r(���r#����normcaser���r�����filenamer���r���rG�������s���z&auto_complete_paths.<locals>.<genexpr>rF���r ���)r(���r#���r����abspath�access�R_OKrL����listdirr9����isfile�isdir)r"���r?���Z directoryZcurrent_pathZ file_list�fr>���Z comp_filer���rM���r���r7�������s���� �r7���)�__doc__r2���r(���r-���� itertoolsr����typingr���r���r���r���Zpip._internal.cli.main_parserr���Zpip._internal.commandsr���r ���Zpip._internal.metadatar ���rC���rH���r*���r6���r7���r���r���r���r����<module>���s���a�