
    vKg
-                        S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	J
r
  SSK	Jr  SSKJr  S\R                  S\R                  \R                      S\S	S4S
 jrS\S	\4S jrS\R                   S	\R                   4S jr " S S\R.                  5      r " S S5      r " S S\R.                  5      r " S S5      rS\S\S\S	\R                   4S jrSS\R:                  \   4S jjrS rg)z1
This module manages and invokes typed commands.
    N)
exceptions)command_lexer)unquotefargskwargsreturnc                     [         R                  " U 5      n UR                  " U0 UD6  g ! [         a+  n[        R
                  " SUR                  S   -  5      eS nAff = f)Nzcommand argument mismatch: %sr   )inspect	signaturebind	TypeErrorr   CommandErrorr   )r   r   r   sigvs        i/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/seleniumwire/thirdparty/mitmproxy/command.pyverify_arg_signaturer      sZ    


A
CS$!&! S%%&Eq	&QRRSs   + 
A &AA tc                 @   U [         R                  :X  a  [        R                  " S5      e[        R
                  R                  R                  R                  R                  U S5      nU(       d$  [        R                  " S[        U SU 5      -  5      eUR                  $ )z-
Translates a type to an explanatory string.
zmissing type annotationNzunsupported type: %s__name__)r   _emptyr   r   seleniumwire
thirdparty	mitmproxytypesCommandTypesgetgetattrdisplay)r   tos     r   typenamer!      sz     	GNN%%&?@@		 	 	*	*	0	0	=	=	A	A!T	JB%%&<wq*VW?X&XYY::    xc                 D    U [         R                  R                  :X  a  g U $ N)r   	Signatureemptyr#   s    r   _empty_as_noner)   %   s    G###Hr"   c                       \ rS rSr% \\S'   \R                  \S'   \R                  R                  r\R                  \S'   S rSrg)CommandParameter+   nametypekindc                     U R                   [        R                  R                  L a  SU R                   3$ U R                  $ )N*)r/   r   	ParameterVAR_POSITIONALr-   selfs    r   __str__CommandParameter.__str__0   s4    99))888tyyk?"99r"    N)r   
__module____qualname____firstlineno__str__annotations__typingTyper   r2   POSITIONAL_OR_KEYWORDr/   _ParameterKindr6   __static_attributes__r8   r"   r   r+   r+   +   s2    
I
++#*#4#4#J#JD'
 
 Jr"   r+   c                      \ rS rSr% \\S'   S\S'   \R                  \S'   \R                  \   \S'   SSS\S\R                  SS	4S
 jr\S\R                  \R                     4S j5       r\S\R                  \   4S j5       rS\4S jrS\R&                  \   S\R(                  4S jrS\R&                  \   S\R,                  4S jrSrg	)Command7   r-   CommandManagermanagerr   helpfuncr	   Nc           
         X l         Xl        X0l        [        R                  " U R                  5      U l        UR
                  (       aE  UR
                  R                  5       nSR                  [        R                  " U5      5      U l
        OS U l
        U R                  R                  R                  5        H  u  p%UR                  n[        R                  R                   R"                  R$                  R'                  UR                  S 5      (       a  M`  [(        R*                  " SU S[-        U5       SU S35      e   U R.                  (       au  [        R                  R                   R"                  R$                  R'                  U R.                  S 5      (       d'  [(        R*                  " SU R.                   SU S35      eg g )N
z	Argument z has an unknown type (z) in .z!Return type has an unknown type ()r-   rG   rI   r   r   __doc__stripjointextwrapwraprH   
parametersitems
annotationr   r   r   r   r   r   r   r   r)   return_type)r5   rG   r-   rI   txt	parameterr   s          r   __init__Command.__init__=   sd   		 **4995<<,,$$&C		(--"45DIDI  $~~88>>@OD$$A**44::GGKKIL`L`bfgg --	$?UVdefVgUhhmnrmsst.uvv  A L$;$;$E$E$K$K$X$X$\$\]a]m]mos$t$t)),MdN^N^M__deidjjk*lmm %ur"   c                 @    [        U R                  R                  5      $ r%   )r)   r   return_annotationr4   s    r   rU   Command.return_typeQ   s    dnn>>??r"   c                     / nU R                   R                  R                  5        H4  u  p#UR                  [	        X#R
                  UR                  5      5        M6     U$ )z$Returns a list of CommandParameters.)r   rR   rS   appendr+   rT   r/   )r5   retr-   params       r   rR   Command.parametersU   sK     >>44::<KDJJ'.>.>

KL =
r"   c                     SR                  S U R                   5       5      nU R                  (       a  S[        U R                  5       3nOSnU R                   SU U 3$ )N c              3   6   #    U H  n[        U5      v   M     g 7fr%   )r<   ).0r`   s     r   	<genexpr>)Command.signature_help.<locals>.<genexpr>^   s     B/#e**/s   z ->  )rO   rR   rU   r!   r-   )r5   paramsr_   s      r   signature_helpCommand.signature_help]   sY    B$//BB$"2"2345CC))AfXcU++r"   r   c                     U R                   R                  " U6 nUR                  R                  5        HK  u  pVU R                   R                  U   R                  n[        U R                  Xg5      UR                  U'   MM     UR                  5         U$ ! [         aM    S[        U R                   R                  5       3nS[        U5       3n[
        R                  " SU SU 35      ef = f)Nz
Expected: z
Received: z Command argument mismatch: 
    z
    )r   r   r   r<   rR   r   r   	argumentsrS   rT   parseargrG   apply_defaults)r5   r   bound_argumentsexpectedreceivedr-   value
convert_tos           r   prepare_argsCommand.prepare_argse   s    	j"nn1148O +44::<KD2248CCJ.6t||U.WO%%d+ = 	&&(  	j#C(A(A$B#CDH#CI;/H)),MhZW]^f]g*hii	js   B AC-c                    U R                  U5      nU R                  " UR                  0 UR                  D6nUc  U R                  c  g[
        R                  R                  R                  R                  R                  U R                  5      nU(       d   eUR                  U R                  XC5      (       d/  [        R                  " U R                   SUR                    35      eU$ )zV
Call the command with a list of arguments. At this point, all
arguments are strings.
Nz% returned unexpected data - expected )ru   rI   r   r   rU   r   r   r   r   r   r   is_validrG   r   r   r-   r   )r5   r   
bound_argsr_   typs        r   callCommand.callu   s    
 &&t,
ii>J,=,=>;4++3%%//55BBFFtGWGWX
s||DLL#33))99+B3;;-P  
r"   )rI   rH   rG   r-   r   )r   r9   r:   r;   r<   r=   r   r&   r>   OptionalCallablerX   propertyr?   rU   Listr+   rR   rj   SequenceBoundArgumentsru   Anyr{   rB   r8   r"   r   rD   rD   7   s    
I   
//#
n 0 n n6?? nW[ n( @V__V[[9 @ @ FKK(89  , ,!5 ':P:P  - &** r"   rD   c                   H    \ rS rSr% \\S'   \R                  \S'   \\S'   Sr	g)ParseResult   rs   r.   validr8   N)
r   r9   r:   r;   r<   r=   r>   r?   boolrB   r8   r"   r   r   r      s    J
++Kr"   r   c                      \ rS rSr% \R
                  \\4   \S'   S r	S r
S\S\R                  4S jr\R                  " SS	9S
\S\R                  \R                   \   \R                   \   4   4S j5       rS\S\R                   \R(                     S\R(                  4S jrS\S\R                   \   S\R(                  4S jrS
\S\R(                  4S jr\R2                  4SS jjrSrg)rF      commandsc                     Xl         0 U l        g r%   )masterr   )r5   r   s     r   rX   CommandManager.__init__   s    r"   c                    [        U5       Hh  nUR                  S5      (       a  M  [        X5      n [        [        USS 5      [        5      nU(       a   U R                  UR                  U5        Mh  Mj     g ! [        R                   aB  nU R                  R                  R                  SUR                  < SU< 35         S nAM  S nAff = f! [         a     M  f = f)N__command_namezCould not load command z: )dir
startswithr   
isinstancer<   addr   r   r   r   logwarn	Exception)r5   addonio
is_commandes         r   collect_commandsCommandManager.collect_commands   s    UA<<%%E%!+GA~t,Lc!RJ " HHQ^^Q7 "   *66  KKOO00CD>>ST U  ! s)   CA99C7C

C
C C pathrI   c                 6    [        XU5      U R                  U'   g r%   )rD   r   )r5   r   rI   s      r   r   CommandManager.add   s    %d$7dr"      )maxsizecmdstrr	   c           	         [         R                  R                  USS9n/ n[        S[        R
                  R                  R                  R                  5      [        S[        R
                  R                  R                  R                  5      /nSnU GH  nUR                  5       (       aH  UR                  [        U[        R
                  R                  R                  R                  SS95        Ma  U(       a1  UR                  [        R                   R"                  L a
  U(       a   eOQU(       a  UR%                  S5      nO8[        S[        R
                  R                  R                  R&                  5      nUR(                  [        R
                  R                  R                  R                  :H  =(       a    X`R*                  ;   nUR(                  [        R
                  R                  R                  R                  :H  =(       a    X`R*                  ;  nU=(       a>    US   R(                  [        R
                  R                  R                  R                  :H  n	U(       a&  U	(       a  U R*                  U   R,                  USS -   nU(       a  U	(       a  UR%                  S5        [        R
                  R                  R                  R.                  R1                  UR(                  S5      n
SnU
(       a   U
R3                  XR(                  U5        SnUR                  [        UUR(                  US95        GM     X44$ ! [4        R6                   a    Sn NDf = f)	zr
Parse a possibly partial command. Return a sequence of ParseResults and a sequence of remainder type help items.
T)parseAllrh   N)rs   r.   r   r      F)r   exprparseStringr+   r   r   r   r   CmdCmdArgsisspacer^   r   Spacer/   r   r2   r3   popUnknownr.   r   rR   r   r   parser   r   )r5   r   partsparsednext_paramsrq   partarg_is_known_commandarg_is_unknown_commandcommand_args_followingr    r   s               r   parse_partialCommandManager.parse_partial   s    #0"4"4"@"@RV"@"W+-R!8!8!B!B!H!H!L!LMR!8!8!B!B!H!H!P!PQ6
 7;D||~~")44>>DDJJ" HMMW->->-M-MM&&;&??1-+B0G0G0Q0Q0W0W0_0_` !8!8!B!B!H!H!L!LLfQUYfYfQf ! !8!8!B!B!H!H!L!LLjQU]j]jQj # fA 3 3|7N7N7X7X7^7^7f7f f # $(>"mmD1<<{12N%*@"((2288EEII(--Y]^BE!HHT==$7 !EMM!U d "" "++ "!E"s   MM'&M'r   r   c                     XR                   ;  a  [        R                  " SU-  5      eU R                   U   R                  " U6 $ )z?
Call a command with native arguments. May raise CommandError.
Unknown command: %s)r   r   r   rI   r5   r   r   s      r   r{   CommandManager.call   s?     }},))*?,*NOO}}\*//66r"   c                     XR                   ;  a  [        R                  " SU-  5      eU R                   U   R                  U5      $ )zJ
Call a command using a list of string arguments. May raise CommandError.
r   )r   r   r   r{   r   s      r   call_stringsCommandManager.call_strings   s?     }},))*?,*NOO}}\*//55r"   c                 ^   U R                  U5      u  p#U(       d  [        R                  " SU< 35      eU Vs/ sHV  nUR                  [        R
                  R                  R                  R                  :w  d  MA  [        UR                  5      PMX     sntpVU R                  XV5      $ s  snf )z3
Execute a command string. May raise CommandError.
zInvalid command: )r   r   r   r.   r   r   r   r   r   r   rs   r   )r5   r   r   _r   r   r   s          r   executeCommandManager.execute   s     %%f-)),=fZ*HII 
yyL33==CCIII  GDJJ

   44
s   ?B*<B*Nc                 ,   [        U R                  R                  5       5      nUR                  S S9  U H[  nUR                  =(       d    SR                  5        H  n[        SU-   US9  M     [        UR                  5       US9  [        US9  M]     g )Nc                 "    U R                  5       $ r%   )rj   r(   s    r   <lambda>%CommandManager.dump.<locals>.<lambda>  s     0 0 2r"   )keyrh   z# )file)listr   valuessortrH   
splitlinesprintrj   )r5   outcmdschls        r   dumpCommandManager.dump  su    DMM((*+		2	3Avv|//1dRic* 2!""$3/sO	 r"   )r   r   )r	   N)r   r9   r:   r;   r>   Dictr<   rD   r=   rX   r   r~   r   	functools	lru_cacheTupler   r   r+   r   r   r{   r   r   sysstdoutr   rB   r8   r"   r   rF   rF      s	   kk#w,''$8 86?? 8 %B#B# 
fook2FOODT4UU	VB# &B#H7 7V__VZZ-H 7VZZ 76 6FOOC4H 6VZZ 65c 5fjj 5 zz  r"   rF   rG   specargtypec                 \   [         R                  R                  R                  R                  R                  US5      nU(       d  [        R                  " SU 35      e UR                  XU5      $ ! [        R                   a%  n[        R                  " [        U5      5      UeSnAff = f)z9
Convert a string to a argument to the appropriate type.
NzUnsupported argument type: )r   r   r   r   r   r   r   r   r   r   r<   )rG   r   r   r   r   s        r   rn   rn     s     	))//<<@@$OA%%(CG9&MNN5www.. 5%%c!f-145s    A2 2B+ B&&B+r-   c                    ^  U 4S jnU$ )Nc                    >^  [         R                  " T 5      U 4S j5       nT=(       d    T R                  R                  SS5      UR                  S'   U$ )Nc                  ,   > [        TX5        T" U 0 UD6$ r%   )r   )r   r   functions     r   wrapper+command.<locals>.decorator.<locals>.wrapper&  s     48T,V,,r"   r   rL   r   )r   wrapsr   replace__dict__)r   r   r-   s   ` r   	decoratorcommand.<locals>.decorator%  sN    		"	- 
#	- ,0+V83D3D3L3LSRU3V(r"   r8   )r-   r   s   ` r   commandr   $  s     r"   c                 \   ^ ^ S[         R                  S[         R                  4U U4S jjnU$ )z
Set the type of a command argument at runtime. This is useful for more
specific types such as seleniumwire.thirdparty.mitmproxy.types.Choice, which we cannot annotate
directly as mypy does not like that.
r   r	   c                 J   > TU R                   ;   d   eTU R                   T'   U $ r%   )r=   )r   r-   r.   s    r   r   argument.<locals>.decorator8  s,    q((((("&$r"   )r   FunctionType)r-   r.   r   s   `` r   argumentr   1  s/    U'' E,>,>  
 r"   r%   ) rM   r   r   r   rP   r   r>   'seleniumwire.thirdparty.mitmproxy.typesr   !seleniumwire.thirdparty.mitmproxyr   r   /seleniumwire.thirdparty.mitmproxy.command_lexerr   r~   Iterabler   dictr   r.   r<   r!   r)   
NamedTupler+   rD   r   rF   rn   r}   r   r   r8   r"   r   <module>r      s     
    . 8 ; CSFOO S6??6::3N SX\ Sae S	 	 	fjj VZZ 	v(( 	M M`&## G GT
5n 
5C 
5$ 
56:: 
5
&//#& 
r"   