
    Rif                         d Z ddlmZ ddl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mZ erddlmZ dd	lmZmZmZ d
ee         ddddddddde	fdZddZded
ee         ddfdZdS )zO
Command-line completion mechanisms, executed by the core ``--complete`` flag.
    )ListN)TYPE_CHECKING   )Exit
ParseError)debugtask_name_sort_key)
Collection)ParserParseResultParserContextnamescorer   initial_contextr   
collectionr
   parserr   returnc                    t          j        d                    d                    |                     d|j                  }t          d                    |                     t          j        |          }|r$|d                             d          r|d         }t          d                    |                     	 t          d                    |                     |	                    |          }nR# t          $ rE}	d	}
t          |
                    |	|	j                             |	j        |	j        gng }Y d }	~	nd }	~	ww xY wt          d
                    |                     |r|d         s|}n|d         }t          d                    |                     t          d                    ||j                             ||j        vrt          d           |                    d          r6t          d |                                          D ]}t          |           n|dk    r'|                                D ]}t          |           n`n_|j        |         j        rt          d           n=t          d           t#          |           nt          d           t#          |           t$          )Nz^({}) | zCompleting for invocation: {!r}-z#Invocation's tail {!r} is flag-likez$Seeking context name in tokens: {!r}z<Got parser error ({!r}), grabbing its last-seen context {!r}z!Parsed invocation, contexts: {!r}zSelected context: {!r}zLooking for {!r} in {!r}z%Not found, completing with flag names--c                 ,    |                      d          S )Nr   )
startswith)xs    R/srv/django_bis/venv311/lib/python3.11/site-packages/invoke/completion/complete.py<lambda>zcomplete.<locals>.<lambda>@   s    all400     z-Found, and it takes a value, so no completionz*Found, takes no value, printing task namesz4Last token isn't flag-like, just printing task names)resubformatjoin	remainderr   shlexsplitr   
parse_argvr   contextflagsfilter
flag_namesprinttakes_valueprint_task_namesr   )r   r   r   r   r   
invocationtokenstailcontextsemsgr(   names                r   completer6      s    	((%992t~NNJ	
+
2
2:
>
>???[$$F ;%&*'',, ;%bz3::4@@AAA	D8??GGHHH((00HH 	D 	D 	DPC#**Q	**+++&'i&;	{{HHHHHH	D
 	188BBCCC 	#x| 	#%GGrlG&--g66777 	(//gmDDEEEw}$$9:::t$$ "00'2D2D2F2F     D $KKKK 
 #..00    D$KKKK   }T". -EFFF BCCC ,,,, 	DEEE$$$
Js   7C: :
E	;EE	c                     t          | j        t                    D ]0}t          |           | j        |         D ]}t          |           1d S )N)key)sorted
task_namesr	   r,   )r   r5   aliass      r   r.   r.   a   sb    z,2DEEE  d  *40 	 	E%LLLL		 r   shellc                    d t          j         t          j                            t          j                            t          j                            t                              d                    D             }	 ||          }nS# t          $ rF d}t          |	                    | d                    t          |                                        w xY wt          d	                    |                     |d         }t          |d          5 }t          |                                	                    |d                    |          	                     d d d            d S # 1 swxY w Y   d S )
Nc                     i | ]E}t           j                            t           j                            |                    d          |FS )r   )ospathsplitextbasename).0r   s     r   
<dictcomp>z+print_completion_script.<locals>.<dictcomp>m   sO        	))!,,--a0!  r   z*.completionz:Completion for shell "{}" not supported (options are: {}).z, z"Printing completion script from {}r   r )binaryspaced_names)globr?   r@   r#   dirnamerealpath__file__KeyErrorr   r"   r9   r   openr,   read)r<   r   completionsr@   errrG   scripts          r   print_completion_scriptrS   j   s    GLL 0 0 : :;;^ 
 
  KL5! L L LJE499VK5H5H+I+IJJKKKL 

.
5
5d
;
;<<< 1XF	dC 
FKKMM  SXXe__ MM	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s    =B ACA
E**E.1E.)r   r
   r   N)__doc__typingr   rI   r?   r    r%   r   
exceptionsr   r   utilr   r	   r   r
   r   r   r   r   strr6   r.   rS    r   r   <module>rZ      sg           				 				              ) ) ) ) ) ) ) ) , , , , , , , , <'''''';;;;;;;;;;J9J
J %J 	J
 J 
J J J JZ   
3 
tCy 
T 
 
 
 
 
 
r   