ó vÆ_c@sÊdZddlZddlZddlZddlmZddlmZddlm Z m Z ddl m Z ddl mZer«ddlmZmZmZmZnd „Zd „Zd „ZdS( sBLogic that powers autocompletion installed by ``pip completion``. iÿÿÿÿN(tchain(tcreate_main_parser(t commands_dicttcreate_command(tget_installed_distributions(tMYPY_CHECK_RUNNING(tAnytIterabletListtOptionalcCs%dtjkrdStjdjƒd}ttjdƒ}y||d}Wntk rhd}nXtƒ}ttƒ}g}d}x$|D]}||kr‘|}Pq‘q‘W|dk r*|dkrÙt j dƒn|dkoò|j d ƒ }|rŽg} |j ƒ} xOt d tƒD]>} | jj | ƒr| j|dkr| j| jƒqqW| rŽx| D] } | GHqlWt j dƒqŽnt|ƒ} xZ| jjD]L} | jtjkr§x1| j| jD]}|j|| jfƒqÐWq§q§Wg|d|d!D]}|jd ƒd ^q }g|D]$\}}||kr/||f^q/}g|D]'\}}|j |ƒr`||f^q`}t||| jjƒ}|rÜt||ƒ}g|D]}|d f^qÁ}nx5|D]@}|d }|dr|d d dkr|d 7}n|GHqãWnêg|jD]}|j^q4}|j|jƒtj|ƒ}|j d ƒr´xj|D]/} | jtjkr~|| j| j7}q~q~Wn0t|||ƒ}|rätt||ƒƒ}ndj g|D]}|j |ƒrñ|^qñƒGHt j dƒdS(s?Entry Point for completion of main and subcommand options. tPIP_AUTO_COMPLETENt COMP_WORDSit COMP_CWORDtthelptshowt uninstallt-t local_onlyt=iis--t (RR(!tostenvirontsplittintt IndexErrorRtlistRtNonetsystexitt startswithtlowerRtTruetkeytappendRtparsertoption_list_allRtoptparset SUPPRESS_HELPt _long_optst _short_optstnargstget_path_completion_typetauto_complete_pathst option_groupst option_listRt from_iterabletjoin(tcwordstcwordtcurrentR#t subcommandstoptionstsubcommand_nametwordtshould_list_installedt installedtlctdistt subcommandtopttopt_strtxt prev_optstvtktcompletion_typetpathstpathtoptiont opt_labeltitoptstflattened_opts((sQ/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.pyt autocompletes~          %   !114"        0cCsÌ|dks$||djdƒ r(dSx|D]•}|jtjkrMq/nxtt|ƒjdƒD]]}||djdƒd|krc|j s¶td„|jjdƒDƒƒrÀ|jSqcqcWq/WdS(sLGet 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) iRt/Ricss|]}|dkVqdS(RDtfiletdirN(spathsfilesdir((t.0R>((sQ/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.pys ‚sN( RRRR%R&tstrRtmetavartany(R0R1RHR<to((sQ/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.pyR*qs $ ! c#stjj|ƒ\}‰tjj|ƒ}tj|tjƒsCdStjjˆƒ‰‡fd†tj|ƒDƒ}x“|D]‹}tjj||ƒ}tjjtjj||ƒƒ}|dkrÝtjj |ƒrÝ|Vq{tjj |ƒr{tjj|dƒVq{q{WdS(soIf ``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 Nc3s0|]&}tjj|ƒjˆƒr|VqdS(N(RRDtnormcaseR(RNR>(tfilename(sQ/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.pys ™sRMR ( RRDRtabspathtaccesstR_OKRStlistdirR/tisfiletisdir(R2RBt directoryt current_patht file_listtfR<t comp_file((RTsQ/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.pyR+ˆs  !(t__doc__R%RRt itertoolsRtpip._internal.cli.main_parserRtpip._internal.commandsRRtpip._internal.utils.miscRtpip._internal.utils.typingRttypingRRRR RJR*R+(((sQ/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.pyts   % _