
    f*                         d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ h dZd	Zd d
Zd Zd Zd Zd Zd Zd Z	 	 d!dZd Zd Zd Zd Zd dZ ee      Zd Zd Zd Z d Z!d Z" e"d      Z# e"d      Z$ e"dd      Z%y)"    N)literal_eval)cleandocWeakKeyDictionary)tree)parser_cache)split_lines>   atomexprtermtestpowerfactorfuncdefor_testand_exprand_testclassdefnot_testxor_expr	atom_expr
arith_expr
comparison
shift_exprimport_fromimport_name)	tryexceptfinallyelseifelifwithforwhilec                 N   g }| j                   }|dk(  rE| j                         }|du r/| j                  j                   dk7  r|dk7  r|j                  |        |S |dk(  r4|j                  |        | j                  D ]  }|t        |d      z  } |S |dk(  r6| j                  d	   d
k(  r"| j                  d   } | dk7  r|t        |       z  }|S 	 | j                  }| j                   t        v r|s|j                  |        |D ]  }|t        ||      z  } |S # t        $ r Y |S w xY w)z
    For static analysis.
    nameFparam=	expr_stmtT)
last_added	decorator)()typeget_next_leafparentappendchildrenget_executable_nodes_EXECUTE_NODESAttributeError)noder+   resulttyp	next_leafchildr5   s          L/var/www/cvtools/html/venv/lib/python3.12/site-packages/jedi/parser_utils.pyr6   r6      sX    F
))C
f}&&(	4;;#3#3w#>9PSCSMM$2 M1 
	 	d]] 	CE*5TBBF	C( M% 
	==#==$Ds{.t44 M		B}}H yyN*:d#! B.ujAAB M  	 M	s   D 	D$#D$c              #      K   |  | j                   d   }	 |j                  dk(  r|j                   d    n$|j                  dk(  r| n|j                  dk(  sy |j                   d   }Uw)Ncomp_for   sync_comp_forcomp_ifr5   r1   )rA   lasts     r>   get_sync_comp_forsrG   :   sl     
NR D
99
"--""YY/)Ji'}}R  s   A*A,c                 :    | j                   d   j                  dk(  S )z
    Returns True if only one name is returned: ``for x in y``.
    Returns False if the for loop is more complicated: ``for x, z in y``.

    :returns: bool
    rB   r'   rE   )for_stmts    r>   for_stmt_defines_one_namerJ   G   s      Q$$..    c                 "   |j                   }| j                   |cxk  r| j                  k  st        d       t        d      d }t        | j                        D ]3  \  }}||j                   k  r|c S |j                         }|t        v s2|}5 y )Nz!The node is not part of the flow.)	start_posend_pos
ValueError	enumerater5   get_first_leaf_FLOW_KEYWORDS)	flow_noder9   rM   keywordir=   
first_leafs          r>   get_flow_branch_keywordrW   Q   s    I)@y/@/@@<== A<==Gi001 !5u&N))+
' G! rK   c                 d    | j                         }|t        t        |j                              S y)z3 Returns a cleaned version of the docstring token.  )get_doc_noder   safe_literal_evalvalue)
scope_noder9   s     r>   clean_scope_docstringr^   `   s0    ""$D
 )$**566rK   c                     | j                   dk(  ri| j                  } | j                         }|K|j                   dk(  r<|j                  d   }|j                   dk(  rt	        t        |j                              S y)Nr*   simple_stmtr   stringrY   )r1   r3   get_next_siblingr5   r   r[   r\   )	tree_nodemaybe_strings     r>   find_statement_documentationre   l   ss    ~~$$$	 113#  M1+44Q7$$0#$5l6H6H$IJJrK   c                 X    | d d j                         }|d   dk(  s|dv ryt        |       S )N   r   f)frrfrY   )lowerr   )r\   	first_twos     r>   r[   r[   x   s7    bq	!I|si<7 rK   c                    |(| j                   dk(  rd}n| j                  j                  }| j                         }|r|dd }ddj	                  d |D              j                         z   dz   }t        j                  d	d
|      }| j                  r |sd| j                  j                         z   }nd}||z   |z   }dj	                  t        j                  ||            S )z
    Generate a string signature of a function.

    :param width: Fold lines if a line is longer than this value.
    :type width: int
    :arg func_name: Override function name when given.
    :type func_name: str

    :rtype: str
    Nlambdefz<lambda>rB   r0   rY   c              3   <   K   | ]  }|j                           y wN)get_code).0r(   s     r>   	<genexpr>z get_signature.<locals>.<genexpr>   s     ;5enn&;s   r.   z\s+ z ->
)r1   r'   r\   
get_paramsjoinstripresub
annotationrq   textwrapwrap)	r   widthcall_stringomit_first_paramomit_return_annotationparamsprtypecodes	            r>   get_signaturer      s     <<9$$K!,,,,K!Fbgg;F;;AACCcIA
vsAA"8**3355?U"D99X]]4/00rK   c                     	 | j                   }|D ]  }t        ||        y# t        $ r | xj                  |z  c_        Y yw xY w)z$
    Move the `Node` start_pos.
    N)r5   mover8   line)r9   line_offsetr5   cs       r>   r   r      sJ    !==  	!AK 	!  !		[ 	!s   " AAc                    	 | j                   dk(  r(| j                  d   j                         j                  }n| j                   dk(  r(| j                  d   j                         j                  }nm| j                   dk(  r6| j                  d   j                         j	                         j                  }n(| j                         j	                         j                  }d|vry||j                  d      d }d	|v r|d|j                  d	       }d
|v r|d|j                  d
       }|S # t        $ r Y yt        $ r Y yw xY w)zl
    returns (as string) any comment that appears on the same line,
    after the node, including the #
    rI      	with_stmt   r      N#ru   )	r1   r5   rQ   prefixr2   get_last_leafr8   rO   index)r9   
whitespacecomments      r>   get_following_comment_same_liner      s-   
99
"q)88:AAJYY+%q)88:AAJYY)#q)88:HHJQQJ++-;;=DDJ *))#./0Gw.7==./w.7==./N    s   CD( (	D>3D>=D>c                 d    | j                   }|dk(  r| j                  d   j                   dk7  S |dv S )NrA   rB   rC   )
file_inputr   r   rn   rC   )r1   r5   )r9   ts     r>   is_scoper      s8    		AJ}}Q$$77QQQrK   c                 ,     t               d fd	}|S )Nc                     | 	 ||      S 	 |    }	 ||   S # t         $ r
 i x}| <   Y w xY w# t         $ r  ||      x}||<   |cY S w xY wrp   )KeyError)parso_cache_noder9   include_flows
for_moduler:   cachefuncs        r>   wrapperz(_get_parent_scope_cache.<locals>.wrapper   s    #m,,	6/0J	d##	  	6355J/0	6
  	(,T=(AAFZ%M	s    / ,,A
AFr   )r   r   r   s   ` @r>   _get_parent_scope_cacher      s    E NrK   c                      j                   }|y	 t        |      r|j                  dv r|j                  j	                  d      }|j                  |   j
                   j
                  k\  rz j                   j                  dk(  r j                   j                   k(  r	 |S  j                   j                  dk(  r j                   j                  d    k(  r	 |S |j                   }|S |rMt        |t        j                        r3|j                  dk(  r"t         fd|j                         D              s|S |j                   }3)	z'
    Returns the underlying scope.
    N)r   r   rn   :r(   tfpdefr   if_stmtc              3   z   K   | ]2  }|j                   j                   cxk  xr |j                  k  nc  4 y wrp   )rM   rN   )rr   nr9   s     r>   rs   z#get_parent_scope.<locals>.<genexpr>  s2      = ! KK4>>EAIIEE =s   8;)r3   r   r1   r5   r   rM   r'   
isinstancer   Flowanyget_test_nodes)r9   r   scoper   s   `   r>   get_parent_scoper      s     KKE}
E?zz??,,S1>>%(22dnnD{{''72t{{7G7G47O L ))X5$++:N:Nq:QUY:Y L !& Lz%; JJ)+ =%*%9%9%;= =+ rK   c                 .    t        | |      j                  S )z
    Basically access the cached code lines in parso. This is not the nicest way
    to do this, but we avoid splitting all the lines again.
    )get_parso_cache_nodelinesgrammarpaths     r>   get_cached_code_linesr     s    
  .444rK   c                 .    t         | j                     |   S )z
    This is of course not public. But as long as I control parso, this
    shouldn't be a problem. ~ Dave

    The reason for this is mostly caching. This is obviously also a sign of a
    broken caching architecture.
    )r   _hashedr   s     r>   r   r     s     (..rK   c                     t        | j                  d      d|d   | j                  z
  dz    }|d   }| j                  |d   k(  r|| j                  z  }|sy|d   d| |d<   dj	                  |      S )z3
    Cuts of the value of the leaf at position
    T)keependsNr   rB   rY   r@   )r	   r\   r   columnrw   )leafpositionr   r   s       r>   cut_value_at_positionr   "  s}     

T23OHQK$))4Ka4OPEa[FyyHQK$++b	'6"E"I775>rK   c                 T   | j                   dk(  rCt        | j                        dk(  r*| j                  d   dk(  rt        | j                  d         S y| j                   dk(  r9| j                  }|d   dk(  ryt        |d         syt	        d	 |dd
 D              S | j                   dk(  S )zP
    Checks if a path looks like `name` or `name.foo.bar` and not `name()`.
    r
   r   r   r0   rB   Fr   awaitc              3   @   K   | ]  }|j                   d    dk(    yw)r   .N)r5   )rr   r   s     r>   rs   z!expr_is_dotted.<locals>.<genexpr>?  s     >A1::a=C'>s   Nr'   )r1   lenr5   expr_is_dottedall)r9   r5   s     r>   r   r   0  s     yyFt}}"t}}Q'73'>!$--"233yyK==A;'!hqk*>!">>>99rK   c                        fd}|S )Nc                 v    | j                         D ]%  }|j                  d   }|j                         v s% y y)z
        This is a heuristic. It will not hold ALL the times, but it will be
        correct pretty much for anyone that doesn't try to beat it.
        staticmethod/classmethod are builtins and unless overwritten, this will
        be correct.
        rB   TF)get_decoratorsr5   rq   )function_noder,   dotted_namemethod_namess      r>   r   z&_function_is_x_method.<locals>.wrapperD  sF     '557 	I#,,Q/K##%5	 rK    )r   r   s   ` r>   _function_is_x_methodr   C  s     NrK   staticmethodclassmethodpropertycached_propertyr   )H   NFF)&ry   r|   astr   inspectr   weakrefr   parso.pythonr   parso.cacher   parsor	   r7   rR   r6   rG   rJ   rW   r^   re   r[   r   r   r   r   r   r   get_cached_parent_scoper   r   r   r   r   function_is_staticmethodfunction_is_classmethodfunction_is_propertyr   rK   r>   <module>r      s    	    %  $ B

"J
!/		 26AF1B
!>R(@ 22BC 5/&  1@ /> ,Z9JK rK   