
    Vh.                       d Z ddlmZ ddlZddlZddlZddlZ G d d      Z	 ddl	Z		 ddl
mZmZ e	j                  Z G d dej                        Zdd	Zdd
Z G d de      Zy# e$ r ddl	mZmZ Y Dw xY w# e$ r dZ	eZeZeZY Kw xY w)zGWrapper around argcomplete providing bug fixes and additional features.    )annotationsNc                      e Zd ZdZddZy)
Substitutez9Substitute for missing class which accepts all arguments.c                     y N )selfargskwargss      c/home/dcms/DCMS/lib/python3.12/site-packages/ansible_test/_internal/cli/argparsing/argcompletion.py__init__zSubstitute.__init__   s        NreturnNone)__name__
__module____qualname____doc__r   r   r   r   r   r   
   s
    Cr   r   )CompletionFinderdefault_validatorc                  @    e Zd ZdZdZ	 dZ	 dZ	 dZ	 dZ	 e	d	d       Z
y)
CompTypez
    Bash COMP_TYPE argument completion types.
    For documentation, see: https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html#index-COMP_005fTYPE
    	%?!@c                d    | t         j                  t         j                  t         j                  fv S )z<True if completion is running in list mode, otherwise False.)r   LISTLIST_AMBIGUOUSLIST_UNMODIFIED)r	   s    r   	list_modezCompType.list_modeK   s&     x'>'>@X@XYYYr   N)r   bool)r   r   r   r   
COMPLETIONMENU_COMPLETIONr    r!   r"   propertyr#   r   r   r   r   r   +   sY    
 J O D N
 O Z Zr   r   c                    t         rl| t         j                  vrYt        t         j                  t              r t         j                  j	                  |        yt         xj                  | fz  c_        yyy)ztRegister the given action as a safe action for argcomplete to use during completion if it is not already registered.N)argcompletesafe_actions
isinstancesetadd)action_types    r   register_safe_actionr/   Q   sU    {+*B*BBk..4 $$((5 $$6$ C{r   c                     t         j                  j                  d      } | rt        t	        t        |                   }|S d}|S )zdParse the COMP_TYPE environment variable (if present) and return the associated CompType enum value.	COMP_TYPEN)osenvirongetr   chrint)value	comp_types     r   get_comp_typer9   ]   s;    JJNN;'E-2SZ)I 9=Ir   c                  N     e Zd ZdZ ee      Zddd fdZ fdZ fdZ	 xZ
S )OptionCompletionFinderz
    Custom completion finder for argcomplete.
    It provides support for running completion in list mode, which argcomplete natively handles the same as standard completion.
    N)	validatorc                   |r
t               t               | _        | j                  r| j                  j                  nd| _        d| _        | fd}t        |   |d|i| y )NFc                6    j                   ryt        | |      S )z:Completion validator used to optionally bypass validation.T)disable_completion_manglingr   )
completionprefixfinders     r   custom_validatorz9OptionCompletionFinder.__init__.<locals>.custom_validatorv   s    11$Z88r   r<   )
ValueErrorr9   r8   r#   r?   superr   )r	   r<   r
   r   rC   rB   	__class__s        @r   r   zOptionCompletionFinder.__init__l   sf    ,&59^^11+0(	9 		
&	
 	
r   c                >    | j                   rt        |   |i | y y r   )enabledrE   __call__)r	   r
   r   rF   s      r   rI   zOptionCompletionFinder.__call__   s!    <<Gd-f- r   c                B    | j                   rd}t        | 	  |||      S )zVIntercept default quoting behavior to optionally block mangling of completion entries.N)r?   rE   quote_completions)r	   completionscword_prequotelast_wordbreak_posrF   s       r   rK   z(OptionCompletionFinder.quote_completions   s)    ++ "&w(nFXYYr   r   )r   r   r   r   r$   r)   rH   r   rI   rK   __classcell__)rF   s   @r   r;   r;   d   s-    
 ;G(, 
..Z Zr   r;   )r.   zt.Type[argparse.Action]r   r   )r   zt.Optional[CompType])r   
__future__r   argparseenumr2   typingtr   r)   argcomplete.findersr   r   ImportErrorwarnEnumr   r/   r9   r;   r   r   r   <module>rY      s    M "   	  
	
 D#Ztyy #ZL	7*Z- *ZS  
	
 	

  K!"Ds3   A9 A& A9 &A63A9 5A66A9 9B	B	