
    f,                         d dl Z d dlZd dlmZ 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mZ d dlmZ d	Zd
Z	 dZ	 ddZd Zd Zd Zd Zd ZddZd Zd Zd ZddZddZd Z d Z!	 ddZ"	 ddZ#y)     N)python_bytes_to_unicode)dbg)KnownContentFileIOFolderIO)SubModuleName)load_module_from_path)ParserTreeFilter)convert_names)z.toxz.venvz.mypy_cachevenv__pycache__i     c              #      K   | D ]M  }||v rt        |t              s| |j                  dk(  s,t        |j	                         |       E d {    O y 7 w)Nmodule)
isinstancer   api_type_resolve_namesgoto)definition_namesavoid_namesnames      T/var/www/cvtools/html/venv/lib/python3.12/site-packages/jedi/inference/references.pyr   r      s^       E; $. J==H$%diik3CDDDE Es   .AAAAc                 &    t        d | D              S )Nc              3   T   K   | ]   }|j                   |n|j                   |f " y wN)	tree_name.0ns     r   	<genexpr>z _dictionarize.<locals>.<genexpr>.   s,       kk!q{{A6s   &()dict)namess    r   _dictionarizer"   -   s           c           	         t        | |      }t        |      D ]:  }|t        t        |g|j	                         j                          d            z  }< |t        t        ||j                              z  }t        |      D ]m  }|j                  dk(  s/|j                  #|j                  j                  j                  dk(  rB|t        t        |j                  |j                              z  }o t        t        |            S )NF)
only_stubsprefer_stub_to_compiledparamtrailer)_find_nameslistsetr
   get_root_contextis_stub_find_global_variablesvaluer   r   parenttype_add_names_in_same_contextparent_contextstring_namer   )module_contextr   found_namesr   s       r   _find_defining_namesr7   4   s    ni8K[! s=F002::<<$)
  	 3-k9??KLLK[! ^==G#t~~'=>>((--:s5d6I6I4K[K[\]]	^
 ~k*++r#   c                     | j                  |      }t        |j                               }|j                  |       t        t	        |            S r   )create_namer+   r   addr   )r5   r   r   r6   s       r   r)   r)   H   s>    %%i0Ddiik"KOOD~k*++r#   c              #      K   | j                   y d }	 t        | |      }t        |j                  |            }|sy |E d {    t	        |d       }|d   j
                  }R7 "w)N)r3   until_positionc                     | j                   S r   )	start_pos)xs    r   <lambda>z,_add_names_in_same_context.<locals>.<lambda>^   s
    akk r#   )keyr   )	tree_noder	   r+   getsortedr>   )contextr4   r<   filter_r!   ordereds         r   r2   r2   P   sw      N
"")
 GKK,-$9: --  	s   A A'A%#A'c              #   @  K   | D ]  }|j                   |j                         }	 |j                  } |       j                  |      D ]?  }| |j	                  |j                         }t        ||j                        E d {    A  y 7 	# t        $ r Y w xY wwr   )r   r,   get_global_filterrC   create_contextr2   r4   AttributeError)r!   search_namer   r5   methodglobal_namecs          r   r.   r.   b   s      R>>!..0	R#55F  &x||K8 R!!"11+2G2GH5a9P9PQQQRR R  		s4   #BBABB
B	BBBBc                    | j                   }|j                  }	 d|_        t        | |      }d|_        t	        |      | g}|slt        d |D              D ]W  }|| k7  s	|j                  |j                  j                  |j                         j                  v sG|j                  |       Y |st        d |D              r|}nt        |||      }i }	|D ]  } | j                  j                         j                  |g       D ]  }
t	        t!        | |
            }t        fd|D              rEj#                  |       |D ].  }|	j                  |g       D ]  }j#                  |        	 |	|= 0 q|D ]#  }|	j'                  |g       j                  |       %   j)                         }|r$|D cg c]  }|j+                         | k(  s| c}S |S # d|_        w xY w# t$        $ r Y w xY wc c}w )NFTc              3   <   K   | ]  }|j                           y wr   )r,   )r   ds     r   r   z"find_references.<locals>.<genexpr>   s     ?aQ'')?s   c              3   :   K   | ]  }|j                   d k(    yw)r'   N)r   r   s     r   r   z"find_references.<locals>.<genexpr>   s     HqQZZ72Hs   c              3   &   K   | ]  }|v  
 y wr    )r   r   found_names_dcts     r   r   z"find_references.<locals>.<genexpr>   s     EI9/Es   )inference_stater/   flow_analysis_enabledr7   r"   r+   rB   projectpath
py__file__parentsappendany#get_module_contexts_containing_nameget_used_namesrC   r)   updateKeyError
setdefaultvaluesr,   )r5   r   only_in_moduleinfrL   r6   module_contextsmpotential_modulesnon_matching_reference_maps	name_leafnewdctr   resultr   rV   s                   @r   find_referencesro   r   s   

(
(C//K)$)!*>9E$(!#K0O%&O?;?? 	*AN"q{{'>((ALLN,B,BB&&q)	*
 HKHH+?
 #%+ Q'11@@BFF{TVW 	QINI FGCEEE&&s+!$ I:>>y"M 4 (..s347	B   QD/::4DKKCPQ	QQ" ##%F!LaQ%7%7%9^%KLLMS %)!B $  Ms)   G 1G'9G6G6	G$'	G3	2G3	c                    	 |j                         }t        |d      }|j                  |      sy t	        |j
                  |      }t        | |      }|j                         ry |j                         S # t        $ r Y y w xY w)Nreplace)errors)	readFileNotFoundErrorr   searchr   rZ   r   is_compiled
as_context)rW   file_ioregexcodenew_file_iorh   s         r   	_check_fsr|      sw    ||~ #4	:D<<$W\\48Ko{;A}}<<>  s   A4 4	B ?B c                    t               }t               }|j                         j                         D ]  }|r&|j                  d      s|j                  d      sd|v r,|j	                  dd      j                  d      }d|v rK|j                  d      }|j                  t        j                  j                  | j                  |             |}|j                  | j                  |f        ||fS )N   #   !   *zutf-8ignore/)r+   rs   
splitlines
startswithdecoderstriplstripr:   osrZ   join)	folder_iorx   ignored_paths_absignored_paths_rellpr   s          r   gitignored_pathsr      s    \\^&&( 
:ALL&!,,t*<	HHWh'..s3!888C=D!!"'',,y~~t"DED!!9>>4"89
: ///r#   c                     | j                   }|D ch c]:  }|j                  |d         st        j                   j                  ||d         < c}S c c}w )Nr      )rZ   r   r   r   )r   relative_paths	curr_pathr   s       r   expand_relative_ignore_pathsr      sF    I3A`aYEYEYZ[\]Z^E_BGGLLAaD)```s
   A%Ac              #     K   t        |      }t               }| j                         D ]  \  }}}|D ]O  }|j                  }|j                  dv r
||vrd |f |j                  dk(  s7t        ||      \  }}	||z  }||	z  }Q t        ||      }
|D  cg c]6  } | j                  |vr&| j                  |
vr| j                         t        vr| 8 c} |d d  |D ]  } | d f 
  y c c} w w)N)z.pyz.pyiz
.gitignore)	r+   walkrZ   suffixr   r   r   get_base_name_IGNORE_FOLDERS)r   except_pathsexcept_paths_relativeroot_folder_io
folder_iosfile_iosrx   rZ   r   r   except_paths_relative_expandeds              r   %recurse_find_python_folders_and_filesr      s"    |$LE090@ ",
H 	;G<<D{{o-|+-'yyL(7G"G84!#4  11%)::%	; *F1*
& (
~~\1&DD'')@	 

1 $ 	"IT/!	"5"&
s   A%C)(+C);C$C)c              #   B   K   t        | |      D ]  \  } }|	|  y wr   )r   )r   r   rx   s      r   recurse_find_python_filesr      s,     CI|\ 	7Ms   c              #     	K   | j                         }t               }|D cg c]  }|j                          }}|D ]  }|j                         j                  }| |j                         }	 |j                  	t        	fd|D              r	|v rVt        ||      D ]  }|j                  |vs|  |j                  	       |j                         }k y c c}w w)Nc              3   @   K   | ]  }j                  |        y wr   )r   )r   r   rZ   s     r   r   z1_find_python_files_in_sys_path.<locals>.<genexpr>  s     <atq)<s   )
get_sys_pathr+   r[   	get_valuerx   get_parent_folderrZ   r^   r   r:   )
rW   rg   sys_pathr   rh   yielded_pathsr5   rx   r   rZ   s
            @r   _find_python_files_in_sys_pathr      s     ++-H5L-<=Q\\^=M=) 6 **,44?--/	>>D<8<<@T4YM "<<}4!M" T"!335I 6 >s   C CA7C 1/C c              #      K   |D cg c]  }|j                          }}t        t        | j                  j                        |      E d {    y c c}w 7 
wr   )r[   r   r   rY   rZ   )rW   rg   rh   except_s       r   _find_project_modulesr     sI     '67!q||~7G7(/2I2I2N2N)OQXYYY 8Ys   AA.AAAc              #      K   |D ]  }|j                         r|  t        |      dk  ryt        | |      }t        | |||      E d{    y7 w)z
    Search a name in the directories of modules.

    :param limit_reduction: Divides the limits on opening/parsing files by this
        factor.
       N)limit_reduction)rv   lenr   search_in_file_ios)rW   rg   r   r   r5   file_io_iterators         r   r_   r_     sj      * %%' 4yA~
 -_oN!/3CT2AC C Cs   A
AAAc              #   0  K   t         |z  }t        |z  }d}d}t        j                  dt        j                  |      z   |rdndz         }	|D ]E  }
|dz  }t        | |
|	      }||dz  }| ||k\  rt        d|        y ||k\  s9t        d|        y  y w)Nr   z\b r   zHit limit of parsed files: %szHit limit of opened files: %s)_PARSED_FILE_LIMIT_OPENED_FILE_LIMITrecompileescaper|   r   )rW   r   r   r   completeparse_limit
open_limitfile_io_countparsed_file_country   rx   rh   s               r   r   r   ,  s     $6K#o5JMJJuryy.#uMNE# ow6="G K/3[AJ&/<s   BBB)rU   )F)r   )r   F)$r   r   parsor   
jedi.debugr   jedi.file_ior   r   jedi.inference.namesr   jedi.inference.importsr   jedi.inference.filtersr	   !jedi.inference.gradual.conversionr
   r   r   r   r   r"   r7   r)   r2   r.   ro   r|   r   r   r   r   r   r   r_   r   rU   r#   r   <module>r      s    	 	 )  5 . 8 3 ;I   E ,(,.$R 3l0&a
"D6*Z 9:C8 49r#   