
    Mh*                     >   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            Z%dS )#    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whileFc                 F   g }| j         }|dk    rD|                                 }|du r+| j        j         dk    r|dk    r|                    |            n|dk    r4|                    |            | j        D ]}|t          |d          z  }n|dk    r7| j        d	         d
k    r%| j        d         } | dk    r|t          |           z  }nV	 | j        }| j         t          v r|s|                    |            |D ]}|t          ||          z  }n# t          $ r Y nw xY w|S )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          Q/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jedi/parser_utils.pyr6   r6      s    F
)C
f}}&&((	4;#3w#>#>9PSCSCSMM$			 	d] 	C 	CE*5TBBBBFF	C			=##=$Ds{{.t444		B}H yN**:*d###! B B.ujAAAB  	 	 	D	 Ms   D 
DDc              #      K   | V  | j         d         }	 |j        dk    r|j         d         V  n|j        dk    r|V  n|j        dk    sd S |j         d         }F)NTcomp_for   sync_comp_forcomp_ifr5   r1   )rA   lasts     r>   get_sync_comp_forsrG   :   s      
NNNR D!9
""-"""""Y/))JJJJi''E}R !    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_namerK   G   s     Q$..rH   c                     |j         }| j         |cxk     r| j        k    sn t          d          d }t          | j                  D ]3\  }}||j         k     r|c S |                                }|t          v r|}4d S )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/@@@@@<===Gi011 ! !5u&&NNN))++
'' G4rH   c                 t    |                                  }|!t          t          |j                            S dS )z3 Returns a cleaned version of the docstring token. N )get_doc_noder   safe_literal_evalvalue)
scope_noder9   s     r>   clean_scope_docstringr^   `   s9    ""$$D
 )$*556662rH   c                     | j         dk    ra| j        } |                                 }|D|j         dk    r9|j        d         }|j         dk    r!t	          t          |j                            S dS )Nr*   simple_stmtr   stringrY   )r1   r3   get_next_siblingr5   r   r[   r\   )	tree_nodemaybe_strings     r>   find_statement_documentationre   l   sv    ~$$$	 1133# M11+4Q7$00#$5l6H$I$IJJJ2rH   c                 |    | d d                                          }|d         dk    s|dv rdS t          |           S )N   r   f)frrfrY   )lowerr   )r\   	first_twos     r>   r[   r[   x   sG    bqb	!!I|si<77 rrH   H   c                    || j         dk    rd}n| j        j        }|                                 }|r
|dd         }dd                    d |D                                                       z   dz   }t          j        d	d
|          }| j        r|sd| j        	                                z   }nd}||z   |z   }d                    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   | ]}|                                 V  d S N)get_code).0r(   s     r>   	<genexpr>z get_signature.<locals>.<genexpr>   s,      ;;5enn&&;;;;;;rH   r.   z\s+ z ->
)r1   r'   r\   
get_paramsjoinstripresub
annotationrr   textwrapwrap)	r   widthcall_stringomit_first_paramomit_return_annotationparamsprtypecodes	            r>   get_signaturer      s     <9$$$KK!,,K!!F bgg;;F;;;;;AACCCcIA
vsAA "8 *33555?U"D99X]4//000rH   c                     	 | j         }|D ]}t          ||           dS # t          $ r | xj        |z  c_        Y dS w xY w)z$
    Move the `Node` start_pos.
    N)r5   mover8   line)r9   line_offsetr5   cs       r>   r   r      so    !=  	! 	!AK    	! 	!  ! ! !		[ 					!s     >>c                    	 | j         dk    r%| j        d                                         j        }n| j         dk    r%| j        d                                         j        }nm| j         dk    r7| j        d                                                                         j        }n+|                                                                 j        }n# t          $ r Y dS t          $ r Y dS w xY wd|vrdS ||                    d          d         }d	|v r|d|                    d	                   }d
|v r|d|                    d
                   }|S )zl
    returns (as string) any comment that appears on the same line,
    after the node, including the #
    rJ      	with_stmt   r      N#rv   )	r1   r5   rQ   prefixr2   get_last_leafr8   rO   index)r9   
whitespacecomments      r>   get_following_comment_same_liner      sn   
9
""q)88::AJJY+%%q)88::AJJY)##q)88::HHJJQJJ++--;;==DJ   tt    tt *t))#..//0Gw.7==.../w.7==.../Ns   CC 
C*	C*)C*c                 P    | j         }|dk    r| j        d         j         dk    S |dv S )NrA   rB   rC   )
file_inputr   r   ro   rC   )r1   r5   )r9   ts     r>   is_scoper      s3    	AJ}Q$77QQQrH   c                 4     t                      d fd	}|S )NFc                     |  ||          S 	 |          }n# t           $ r
 i x}| <   Y nw xY w	 ||         S # t           $ r  ||          x}||<   |cY S w xY wrq   )KeyError)parso_cache_noder9   include_flows
for_moduler:   cachefuncs        r>   wrapperz(_get_parent_scope_cache.<locals>.wrapper   s    #4m,,,	6/0JJ 	6 	6 	6355J/000	6	d## 	 	 	(,T=(A(AAFZ%MMM	s    ..: AAFr   )r   r   r   s   ` @r>   _get_parent_scope_cacher      s9    E       NrH   c                      j         }|dS 	 t          |          r|j        dv r|j                            d          }|j        |         j         j        k    rP j         j        dk    r j         j         k    rn/ j         j        dk    r j         j        d          k    rn|j         }|S |rTt          |t          j	                  r:|j        dk    r-t           fd	|                                D                       s|S |j         })
z'
    Returns the underlying scope.
    NT)r   r   ro   :r(   tfpdefr   if_stmtc              3   V   K   | ]#}|j         j         cxk    o
|j        k     nc V  $d S rq   )rM   rN   )rs   nr9   s     r>   rt   z#get_parent_scope.<locals>.<genexpr>  sY       = = ! K4>EEEEAIEEEE = = = = = =rH   )r3   r   r1   r5   r   rM   r'   
isinstancer   Flowanyget_test_nodes)r9   r   scoper   s   `   r>   get_parent_scoper      s=    KE}tE?? 	z???,,S11>%(2dnDD{'722t{7G47O7O)X55$+:Nq:QUY:Y:Y % L 	z%;; 	 J)++ = = = =%*%9%9%;%;= = = = = , +rH   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4rH   c                 2    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     (..rH   c                     t          | j        d          d|d         | j        z
  dz            }|d         }| j        |d         k    r
|| j        z  }|sdS |d         d|         |d<   d                    |          S )z3
    Cuts of the value of the leaf at position
    T)keependsNr   rB   rY   r@   )r	   r\   r   columnrx   )leafpositionr   r   s       r>   cut_value_at_positionr   "  s     
T2223OHQK$)4Ka4O3OPEa[FyHQK$+ rb	'6'"E"I775>>rH   c                 h   | j         dk    rEt          | j                  dk    r+| j        d         dk    rt          | j        d                   S dS | j         dk    rM| j        }|d         dk    rdS t          |d                   sdS 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   8   K   | ]}|j         d          dk    V  dS )r   .N)r5   )rs   r   s     r>   rt   z!expr_is_dotted.<locals>.<genexpr>?  s-      >>A1:a=C'>>>>>>rH   Nr'   )r1   lenr5   expr_is_dottedall)r9   r5   s     r>   r   r   0  s     yFt}""t}Q'73'>'>!$-"2333uyK=A;'!!5hqk** 	5>>!"">>>>>>9rH   c                       fd}|S )Nc                     |                                  D ]/}|j        d         } |                                          r dS 0dS )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   rr   )function_noder,   dotted_namedecorator_checkers      r>   r   z&_function_is_x_method.<locals>.wrapperD  s]     '5577 	 	I#,Q/K  !5!5!7!788 tturH    )r   r   s   ` r>   _function_is_x_methodr   C  s#         NrH   c                     | dk    S )Nstaticmethodr   ms    r>   <lambda>r   S  s    1;N rH   c                     | dk    S )Nclassmethodr   r   s    r>   r   r   T  s    !}:L rH   c                 D    | dk    p| dk    p|                      d          S )Npropertycached_propertyz.setter)endswithr   s    r>   r   r   V  s/    a:o 	

9 rH   r   )rm   NFF)&rz   r}   astr   inspectr   weakrefr   parso.pythonr   parso.cacher   parsor	   r7   rR   r6   rG   rK   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   rH   r>   <module>r      s,   				              % % % % % %       $ $ $ $ $ $      B B B

" " " "J
! 
! 
!/ / /  	 	 		 	 	   26AF1 1 1 1B
! 
! 
!  >R R R  (   @ 212BCC 5 5 5/ / /    &    101N1NOO //0L0LMM ,,     rH   