+
    e'                         ^ RI t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
HtHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^
tR R ltR tR t]! . R7      R 4       tR tR tR R ltR R ltR tR tR# )    NPath)all_suffixes)inference_state_method_cache)ContextualizedNode)	is_stringget_str_or_none)get_cached_code_lines)FileIO)settings)debugc                $    V ^8  d   QhR\         /# )   str_path)str)formats   "9/usr/lib/python3/dist-packages/jedi/inference/sys_path.py__annotate__r      s     . . .    c                     \        V4      pVP                  4       '       d   V# V P                  4       pVf   R # VP                  pVP	                  V4      P                  4       # N)r   is_absolute
py__file__parentjoinpathabsolute)module_contextr   pathmodule_pathbase_dirs   &&   r   	_abs_pathr!      s]    >D ++-K !!HT"++--r   c              #  8  "   \        VP                  R,          VP                  R,          4       EFO  w  r# VR9   g   Q hVP                  R	9   d   \        VP                  4      ^8  g   Q hVP                  pV^ ,          P                  R8X  d   V^ ,          P                  R8X  g   Q hV^,          pVP                  ^ ,          R8X  d#   VP                  ^,          P                  R8X  g   Q h \        T P                  T4      T4      pTP                  4       P                  T4       FP  pTP                  4        F9  p\        T4      '       g   K  \        YP                  4       4      p	T	f   K5  T	x  K;  	  KR  	  EKR  	  R#   \
         d     EKe  i ; i5i)
a  
Extracts the assigned strings from an assignment that looks as follows::

    sys.path[0:0] = ['module/path', 'another/module/path']

This function is in general pretty tolerant (and therefore 'buggy').
However, it's not a big issue usually to add more paths to Jedi's sys_path,
because it will only affect Jedi in very random situations and by adding
more paths than necessary, it usually benefits the general user.
:NNr   :   Nr   namesys.r   N)=z+=power	atom_expr)zipchildrentypelenvalueAssertionErrorr   create_contextinferiterater   r!   get_safe_value)
r   	expr_stmtassigneeoperatorctrailercn
lazy_valuer/   abs_paths
   &&        r   _paths_from_assignmentr=       sa     ")"4"4S"99;M;Md;ST	{***==$::H%%&*+ +!!AQ499&1Q4::+>>>dG##A&#-'2B2B12E2K2Kv2UUU
   = =i H)T((*,,R0J#))+U##(9M9M9OPH+&	 , 11 U(  		s6   5FB9F1AFF4FFFFFc              #  ^  "   VP                   R8X  d\   VP                  ^ ,          R8X  dD   VP                   R8X  d3   VP                  ^ ,          R8X  d   \        VP                  4      ^8X  g   R# VP                  ^,          P                  pVR9  d   R# VP                  ^,          pVR8X  d.   \        VP                  4      R9   d   VP                  ^,          pV P	                  V4      P                  V4       F)  p\        V4      pVf   K  \        W4      pVf   K%  Vx  K+  	  R# 5i)zDextract the path from either "sys.path.append" or "sys.path.insert" r9   r&   (Ninsert)r@   append)      )r-   r,   r.   r/   r1   
infer_noder	   r!   )r   trailer1trailer2r$   argr/   pr<   s   &&&     r   _paths_from_list_modificationsrI   K   s      MMY&8+<+<Q+?3+F*x/@/@/Cs/JH%%&!+Q%%D''


A
CxC-7ll1o..s3>>sCE"9^/N Ds   DD-#
D-)defaultc                   R pV P                   f   . # . p V P                   P                  4       R,          pV! V4       F  w  rEVP                  p\        VP                  4      ^8  d0   VP                  \        V .VP                  R,          O5!  4       KZ  Vf   K`  VP                  R8X  g   Ks  VP                  \        W4      4       K  	  V#   \         d     T# i ; i)z.
Detect sys.path modifications within module.
c              3     "   V  F  pVP                   P                   pVf   K  VP                  R9   g   K2  VP                  pV^ ,          P                  R8X  g   KX  V^ ,          P                  R8X  g   Kr  V^,          P                  R8X  g   K  V^,          P                  ^,          pVP                  R8X  g   K  VP                  R8X  g   K  W3x  K  	  R # 5i)Nr$   r%   r9   r   r(   )r   r-   r,   r/   )namesr$   r)   r8   ns   &    r   get_sys_path_powers9check_sys_path_modifications.<locals>.get_sys_path_powersi   s     DKK&&E UZZ3I%INNQ499&1Q4::+>aDII2!a(Avv'AGGv,="k) s-   CC!CC7C(C>CCr   :r   rC   Nr5   )
	tree_nodeget_used_namesr   r.   r,   extendrI   r-   r=   KeyError)r   rO   addedpossible_namesr$   r)   r5   s   &      r   check_sys_path_modificationsrW   d   s    
	* '	EP'11@@B6J /~>KDI5>>"a'2&).)<
 &9>>[+H3NNO ? L   Ls   !C C"!C"c                     \        4       p\        V4       F=  p\        W4       F+  pVP                  V4       \	        V4      \
        8  g   K*   K;  	  K?  	  V# r   )set_get_buildout_script_paths_get_paths_from_buildout_scriptaddr.   _BUILDOUT_PATH_INSERTION_LIMIT)inference_statescript_pathbuildout_script_pathsbuildout_script_pathr   s   &&   r   discover_buildout_pathsrb      sS    E :; G3OZD!%%d+()-KK [ !H ! r   c           
   #   `  "   \        \        V4      4      p V P                  VR \        P                  R7      p^ RIH	p T! YTR\        T P                  T4      R7      P                  4       p\        T4       Rj  xL
  R#   \
         d    \        P                  ! RT4        R# i ; i L/5i)T)file_iocache
cache_pathz(Error trying to read buildout_script: %sN)ModuleValue)rd   string_names
code_lines)r   r   parser   cache_directoryIOErrorr   warningjedi.inference.valuerg   r
   grammar
as_contextrW   )r^   ra   rd   module_noderg   r   s   &&    r   r[   r[      s     S-./G%++// , 
 1 ()@)@BVW	
 jl  ,N;;;  @BVW <s4   B."B AB.<B,=B."B)%B.(B))B.c                $    V ^8  d   QhR\         /# )r   r   r   )r   s   "r   r   r      s      D r   c                     V P                    F-  p VP                  V4      P                  4       '       d   Vu # K/  	  R #   \         d     KA  i ; ir   )parentsr   is_fileOSError)r   filenamer   s   && r   _get_parent_dir_with_filerx      sP    ,,	x(0022 3    		s   &A  AAc                $    V ^8  d   QhR\         /# )r   search_pathr   )r   s   "r   r   r      s      D r   c              #  ,  "   \        V R4      pV'       g   R# VP                  R4      pVP                  4       '       g   R# \        P                  ! V4       Fd  p VP                  V4      p\        VR4      ;_uu_ 4       pVP                  4       pVP                  R4      '       d   RV9   d   Vx  RRR4       Kf  	  R#   + '       g   i     K{  ; i  \        \        3 d+   p\        P                  ! \        T4      4        Rp?K  Rp?ii ; i5i)z
if there is a 'buildout.cfg' file in one of the parent directories of the
given module it will return a list of all files in the buildout bin
directory that look like python files.

:param search_path: absolute path to the module.
zbuildout.cfgNbinrz#!python)rx   r   existsoslistdiropenreadline
startswithUnicodeDecodeErrorrl   r   rm   r   )rz   project_rootbin_pathrw   filepathf	firstlinees   &       r   rZ   rZ      s      -[.IL$$U+H??JJx(
	((2Hh$$JJL	''--(i2G"N %$ ) %$$ #G, 	 MM#a&!		sY   =D D%C3C4C<DCCDCD'DDDDc                     \        4       R .,            F2  pV P                  V8X  g   K  V P                  V P                  4      p  V # 	  V # )z.pyi)r   suffix	with_namestem)r   r   s   & r   remove_python_path_suffixr      sE    .F8++;;& >>$)),DK	 , Kr   c                  a a \        S4      oSP                  P                  R4      '       d   R# SP                  R8H  pV'       d   SP                  oVV 3R lp\	        V! 4       4      pV'       g   R# \        VR R7      ^ ,          V3# )a3  
Returns the dotted path inside a sys.path as a list of names. e.g.

>>> transform_path_to_dotted([str(Path("/foo").absolute())], Path('/foo/bar/baz.py').absolute())
(('bar', 'baz'), False)

Returns (None, False) if the path doesn't really resolve to anything.
The second return part is if it is a package.
r&   __init__c               3      <"   S EF  p \        S4      P                  V 4      '       g   K&  \        S4      \        V 4      R  pVP                  \        P                  P
                  4      '       g   VP                  R4      '       d
   VR,          pV'       g   K  VP                  \        P                  P
                  4      p\        V4      '       g    R # \        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      x  EK  	  R # 5i)N/:r#   NNc              3   R   "   T F  p\         P                  ! R RV4      x  K  	  R# 5i)z-stubs$ N)resub).0ss   & r   	<genexpr>Mtransform_path_to_dotted.<locals>.iter_potential_solutions.<locals>.<genexpr>  s      I5az2q 9 95s   %')	r   r   r.   r   r   sepsplitalltuple)rH   restr   r   sys_paths      r   iter_potential_solutions:transform_path_to_dotted.<locals>.iter_potential_solutions   s     A;**1--;'A0??277;;//4??33G3G8D4 JJrww{{3Eu::   %I5I%%I5III% s   $DAD	DAD$*Dc                     \        V 4      # r   )r.   )rH   s   &r   <lambda>*transform_path_to_dotted.<locals>.<lambda>  s    SVr   )key)NF)r   r$   r   r   r   sorted)r   r   
is_packager   potential_solutionss   ff   r   transform_path_to_dottedr      s     ,K8K""3'' !!Z/J!((J*   8 :; %+;<Q?KKr   )r   r   pathlibr   importlib.machineryr   jedi.inference.cacher   jedi.inference.base_valuer   jedi.inference.helpersr   r	   jedi.parser_utilsr
   jedi.file_ior   jedir   r   r]   r!   r=   rI   rW   rb   r[   rx   rZ   r   r    r   r   <module>r      su    	 	  , = 8 = 3   !# .('V2 b)" *"J	!<,:5Lr   