
     h"                        d dl mZ d dlmZmZ d dlm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Zd dlZddlmZmZ 	 d dlZ	dZn# e$ r	 d dlZ	d	ZY nw xY w	 d d
lmZ n# e$ r  G d de          ZY nw xY wej        d          dk    ZereZneZdZ e             Z!d dZ"d dZ#d Z$d Z% e"g de$d            e"g de%d            G d de          Z&d Z'	 	 	 d!dZ(d"dZ)d Z*d Z+d Z,dS )#    )defaultdict)	Completer
Completion)InMemoryHistorypromptN   )InternalCommandExceptionExitReplExceptionTF)Exitc                       e Zd ZdS )	ClickExitN)__name__
__module____qualname__     O/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/click_repl/__init__.pyr   r      s        r   r      z0.2.0c                     t          |d          st          d          t          | t          j                  r| g} n+t          | t
          t          f          st          d          | D ]}||ft          |<   d S )N__call__z#Internal command must be a callablez*"names" must be a string or a list / tuple)hasattr
ValueError
isinstancesixstring_typeslisttuple_internal_commands)namestargetdescriptionnames       r   _register_internal_commandr$   )   s    6:&& @>???%)** Ge}-- GEFFF 9 9$*K#84  9 9r   c                 N    t                               |           }|r|d         S |S )Nr   )r   get)r#   defaulttarget_infos      r   _get_registered_targetr)   6   s,    $((..K 1~Nr   c                      t                      N)r   r   r   r   _exit_internalr,   =   s    


r   c                     t          j                    } |                     d           |                                  |                     d          5  |                     d           d d d            n# 1 swxY w Y   |                     d          5  |                     d           t          t                    }t          j	        t                    D ]&\  }}||d                                      |           '|                     d t          j	        |          D                        d d d            n# 1 swxY w Y   |                                 S )Nz	REPL helpzExternal Commandsz!prefix external commands with "!"zInternal Commandsz!prefix internal commands with ":"r	   c              3   x   K   | ]5\  }}d                      d t          |          D                       |fV  6dS )z, c              3   @   K   | ]}d                      |          V  dS )z:{0}N)format).0mnemonics     r   	<genexpr>z+_help_internal.<locals>.<genexpr>.<genexpr>N   s.      UUx6==22UUUUUUr   N)joinsorted)r1   r"   	mnemonicss      r   r3   z!_help_internal.<locals>.<genexpr>L   sg       
 

 'Y 		UU6)CTCTUUUVV
 
 
 
 
 
r   )clickHelpFormatterwrite_headingindentsection
write_textr   r   r   	iteritemsr   appendwrite_dlgetvalue)	formatter
info_tabler2   r(   s       r   _help_internalrC   A   s   #%%IK(((			.	/	/ B B@AAAB B B B B B B B B B B B B B B			.	/	/ 
 
@AAA &&
%(]3E%F%F 	8 	8!Hk{1~&--h7777 
 

 +.-
*C*C
 
 
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 s%   A44A8;A8BD;;D?D?)qquitexitzexits the repl)?hhelpz!displays general help informationc                       e Zd Zd ZddZdS )ClickCompleterc                     || _         d S r+   )cli)selfrM   s     r   __init__zClickCompleter.__init__]   s    r   Nc              #   8  K   	 t          j        |j                  }n# t          $ r Y d S w xY w|j                                        |j        k    }|r|r|                                }nd}t          r(t          j        	                    | j
        i d|          }n&t          j                            | j
        d|          }|d S g }|j        j        D ]}t          |t          j                  r\|j        |j        fD ]L}	|	D ]G}
|                    t)          t+          |
          t-          |           |j                             HMxt          |t          j                  rlt          |j        t          j                  rM|j        j        D ]@}|                    t)          t+          |          t-          |                                At          |j        t          j                  r|j                            |          D ]k}|j                            ||          }|                    t)          t+          |          t-          |           t?          |d                               l|D ] }|j         !                    |          r|V  !d S )N )display_meta
short_help)"shlexsplittext_before_cursorr   rstrippopHAS_C8r7   shell_completion_resolve_contextrM   _bashcompleteresolve_ctxcommandparamsr   Optionoptssecondary_optsr>   r   	text_typelenrI   ArgumenttypeChoicechoicesMultiCommandlist_commandsget_commandgetattrtext
startswith)rN   documentcomplete_eventargscursor_within_command
incompletectxrh   paramoptionsochoicer#   r^   items                  r   get_completionszClickCompleter.get_completions`   s     	;x:;;DD 	 	 	FF	
 '..00H4OO 	  	) 	 JJ J 	F(99$(BDQQCC%11$(BEEC;F[' 	X 	XE%.. X %
E,@A  G$  & )!s:.>UZ      E5>22 Xej%,77 X"'*"4 X Xz)F2C2Cc*ooEU'V'VWWWWck5#566 		11#66  +11#t<<!$Z(%,Wl%C%C       	 	Dy##J// 


	 	s    
,,r+   )r   r   r   rO   rz   r   r   r   rK   rK   \   s7          : : : : : :r   rK   c                 x    | pi } t                      t          |          dd}|D ]}||         }|| vr|| |<   | S )z
    Bootstrap prompt_toolkit kwargs or use user defined values.

    :param prompt_kwargs: The user specified prompt kwargs.
    z> )history	completermessage)r   rK   )prompt_kwargsgroupdefaultskeydefault_values        r   bootstrap_promptr      si     "'RM #$$#E** H  / / m##!.M#r   c                    | j         p| }|j        }t          j                                        }| j        j        }t          |j        t          j                  rd |j        j	        D             }n|j        j
        }|                    |d           t          |          |rfd}	nt          j        j        }		 	  |	            }
n# t          $ r Y t          $ r Y dS w xY w|
s|r.dS |rt!          |
          rB|rQ	 t#          |
          }t          |t$          j                  rt          j        |           n# t*          $ r Y dS w xY w	 t-          j        |
          }nQ# t0          $ rD}t          j        d                    t5          |          j        |                     Y d}~d}~ww xY w	 |                    d||          5 }|                    |           |                                 ddd           n# 1 swxY w Y   nR# t          j        $ r}|                                  Y d}~n*d}~wtB          $ r Y ntD          $ r Y nt*          $ r Y dS w xY w)a<  
    Start an interactive shell. All subcommands are available in it.

    :param old_ctx: The current Click context.
    :param prompt_kwargs: Parameters passed to
        :py:func:`prompt_toolkit.shortcuts.prompt`.

    If stdin is not a TTY, no prompt will be printed, but only commands read
    from stdin.

    c                 R    i | ]$}|j                                         D ]\  }}||	%S r   )commandsitems)r1   sourcecmd_namecmd_objs       r   
<dictcomp>zrepl.<locals>.<dictcomp>   sS     
 
 
%+_%:%:%<%<
 
 "' g
 
 
 
r   Nc                      t          di  S )Nr   r   )r   s   r   rk   zrepl.<locals>.get_command   s    **M***r   Tz{}: {})parent)#r   r^   sysstdinisattyr#   r   r7   CommandCollectionsourcesr   rX   r   readlineKeyboardInterruptEOFErrordispatch_repl_commandshandle_internal_commandsr   r   echor   rT   rU   r   r0   rf   r   make_contextinvokerF   ClickExceptionshowr   
SystemExit)old_ctxr   allow_system_commandsallow_internal_commands	group_ctxr   r   repl_command_nameavailable_commandsrk   r^   resultrq   ert   s    `             r   replr      sP   $ )'IEYF
  ,)#U%<== 8
 
#+3
 
 
 '.7,d333$]E::M )	+ 	+ 	+ 	+ 	+ 	+ i(+	!kmmGG  	 	 	H 	 	 	EE	  	   	%;G%D%D 	" 	1'::fc&677 Jv&&& %   	;w''DD 	 	 	JxtAww'7;;<<<HHHH		##D$y#AA SS!!!


               # 	 	 	FFHHHHHHHH 	 	 	D 	 	 	D  	 	 	EE	U+s   ?
C
 

C#	C#"C#=E 
EEE( (
F62:F11F6:H *H<H HH HH I##H<<I#	I#	I#"I#r   c                 r     |                      |          t          j        t                               dS )z9Register :func:`repl()` as sub-command *name* of *group*.)r#   N)r^   r7   pass_contextr   )r   r#   s     r   register_replr     s1    EMMtMU/5566666r   c                  "    t                       dS )zExit the replN)r,   r   r   r   rF   rF     s    r   c                 l    |                      d          rt          j        | dd                    dS dS )zkExecute system commands entered in the repl.

    System commands are all commands starting with "!".

    !r	   NTF)rn   ossystem)r^   s    r   r   r     s<     # 
	'!""+t5r   c                 ~    |                      d          r%t          | dd         d          }|r |            S dS dS )zaRun repl-internal commands.

    Repl-internal commands are all commands starting with ":".

    :r	   N)r'   )rn   r)   )r^   r!   s     r   r   r   &  s[     # 'TBBB 	688O 	 	r   r+   )NTT)r   )-collectionsr   prompt_toolkit.completionr   r   prompt_toolkit.historyr   prompt_toolkit.shortcutsr   r7   click.parserr   rT   r   r   
exceptionsr
   r   click.shell_completionrY   ImportErrorclick._bashcompleteclick.exceptionsr   r   RuntimeErrorversion_infoPY2unicoderc   str__version__dictr   r$   r)   r,   rC   rK   r   r   r   rF   r   r   r   r   r   <module>r      s   # # # # # # ; ; ; ; ; ; ; ; 2 2 2 2 2 2 + + + + + +      				  



 



 C C C C C C C C!!!!FF   FFF
2222222       L      
qQ III TVV 
9 
9 
9 
9          *  000.BR S S S  (K  
> > > > >Y > > >B  0  	Y Y Y Yx7 7 7 7
  

 
 
	 	 	 	 	s#   A AAA A21A2