
    khf                         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y)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j                  dj                  |             d|j                        }t        dj                  |             t        j                  |      }|r|d   j                  d      r|d   }t        dj                  |             	 t        dj                  |             |j                  |      }t        d
j                  |             |r|d   s|}n|d   }t        dj                  |             t        dj                  ||j                               ||j                  vrt        d       |j                  d      r1t        d |j                               D ]  }t        |        t$        |dk(  r&|j                         D ]  }t        |        t$        	 t$        |j                  |   j                   rt        d       	 t$        t        d       t#        |       t$        t        d       t#        |       t$        # t        $ rM}	d	}
t        |
j                  |	|	j                               |	j                  |	j                  gng }Y d }	~	d }	~	ww xY w)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                 $    | j                  d      S )Nr   )
startswith)xs    l/var/www/pru.catia.catastroantioquia-mas.com/tasa/lib/python3.12/site-packages/invoke/completion/complete.py<lambda>zcomplete.<locals>.<lambda>@   s    all4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      s5    	((%92t~~NJ	
+
2
2:
>?[[$F&*'',bz3::4@A	D8??GH((0H 	188BCx|%GrlG&--g67 	(//gmmDEw}}$9:t$"0'2D2D2F  D $K > J5 #..0  D$K 2 J% $ J }}T"..EF J BC , J 	DE$
Jc  	DPC#**Q		*+&'ii&;		{H	Ds   '+H* *	J 3AI;;J c                     t        | j                  t              D ],  }t        |       | j                  |   D ]  }t        |        . y )N)key)sorted
task_namesr	   r,   )r   r5   aliass      r   r.   r.   a   sI    z,,2DE d  **40 	E%L		r   shellc                    t        j                   t        j                  j                  t        j                  j	                  t        j                  j                  t                    d            D ci c]B  }t        j                  j                  t        j                  j                  |            d   |D }}	 ||    }t        dj                  |             |d   }t        |d      5 }t        |j!                         j                  |dj                  |                   d d d        y c c}w # t        $ r6 d}t        |j                  | dj                  t        |                        w xY w# 1 sw Y   y xY w)	Nz*.completionr   z:Completion for shell "{}" not supported (options are: {}).z, z"Printing completion script from {}r )binaryspaced_names)globospathr#   dirnamerealpath__file__splitextbasenameKeyErrorr   r"   r9   r   openr,   read)r<   r   r   completionsrD   errr@   scripts           r   print_completion_scriptrP   j   sC   
 GGLL 0 0 :;^
 	))!,-a0!3K L5! 

.
5
5d
;< 1XF	dC 
FKKM  SXXe_ M	

 
#  LJE499VK5H+IJKKL
 
s   4AD1>D6 .:E86?E58F)r   r
   r   N)__doc__typingr   rB   rC   r    r%   r   
exceptionsr   r   utilr   r	   r   r
   r   r   r   r   strr6   r.   rP    r   r   <module>rW      s      	 	    ) ,';;J9J
J %J 	J
 J 
JZ
3 
tCy 
T 
r   