
    f!                        d dl Z d dlZ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 d	lmZmZ d
 Zd Zd Zd ZddZd Zd ZddZd Zd Zd Zd Z ddZ!ddZ"d Z#d Z$d Z% G d d      Z&y)     N)Path)ZipFile)zipimporterZipImportError)all_suffixes)access)debug)parser_utils)KnownContentFileIO	ZipFileIOc                  "    t         j                  S N)syspath     g/var/www/cvtools/html/venv/lib/python3.12/site-packages/jedi/inference/compiled/subprocess/functions.pyget_sys_pathr      s    88Or   c                 .    t        j                  | fi |S r   )r   load_module)inference_statekwargss     r   r   r      s    o888r   c                 p    | j                   j                  |      } t        |j                  |      |i |S r   )compiled_subprocessget_access_handlegetattrr   )r   id	attributeargsr   handles         r   get_compiled_method_returnr!      s5    00BB2FF,76==),d=f==r   c                 .    t        j                  | |      S r   )r   create_access_path)r   objs     r   create_simple_objectr%      s    $$_c::r   c                     ||t         j                  ct         _        }	 t        dd|i||t         _        S S # t        $ r Y |t         _        yyw xY w# |t         _        w w xY w)zK
    Returns Tuple[Union[NamespaceInfo, FileIO, None], Optional[bool]]
    	full_nameNNr   )r   r   _find_moduleImportError)r   sys_pathr'   r   temps        r   get_module_infor-   !   s     !388$:i:6: CH    CH   CH  s!   ; 	AA AA A(c                 "    t         j                  S r   )r   builtin_module_names)r   s    r   get_builtin_module_namesr0   0   s    ###r   c                     |)zE
    Raise an error to simulate certain problems for unit tests.
    r   )r   exception_types     r   _test_raise_errorr3   4   s
     r   c                     |9t        |t        j                         t        j                  j                          |*t        |       t        j                  j                          yy)zL
    Force some prints in the subprocesses. This exists for unit tests.
    N)file)printr   stderrflushstdout)r   r7   r9   s      r   _test_printr:   ;   sJ     f3::&

f

 r   c                     t               D ]H  }t        j                  j                  | d|z         }t        j                  j	                  |      sF|c S  y)z^
    The __init__ file can be searched in a directory. If found return it, else
    None.
    __init__N)r   osr   joinexists)directory_pathsuffixr   s      r   _get_init_pathrB   G   sH    
 . ww||NJ,?@77>>$K r   c                 ,    t        j                  |      S r   )r
   safe_literal_eval)r   values     r   rD   rD   S   s    ))%00r   c                  *    t        t        | i |      S r   )list_iter_module_names)r   r   s     r   iter_module_namesrI   W   s    "D3F344r   c              #     K   |D ]  }	 d t        j                  |      D        }|D ]a  \  }}|r|dk7  s|j                         s| $|j                  d      r|d d }nt        j                  |      }|sSd|vsX|dk7  s^| c  y # t        $ rV 	 t        |      }t	        |j
                  |j                        }n&# t        $ r t        j                  d|       Y Y w xY wY w xY ww)Nc              3   T   K   | ]   }|j                   |j                         f " y wr   )nameis_dir).0entrys     r   	<genexpr>z%_iter_module_names.<locals>.<genexpr>_   s     VEEJJ7Vs   &(z"Not possible to list directory: %s__pycache__z.pyi.r<   )r=   scandirOSErrorr   _zip_list_subdirectoryarchiveprefixr   r	   warningisidentifierendswithinspectgetmodulename)r   pathsr   dir_entrieszip_import_inforL   rM   modnames           r   rH   rH   [   s     &	VRZZPTEUVK ( 	&LD& =(T->->-@J==("3BiG%33D9Gs'1*,%	&&  	
"-d"3 5#++_-C-CE! BDI 	sn   C0BC0C03C0:C0?C0	C0	C-+CC-C'#C-$C0&C''C-*C0,C--C0c                    d}d}t         j                  D ]  }|r |t        j                  j                  k7  rd}n|}	 |j
                  } || |      }|@|j                  dk(  rP|j                  }|8|j                  s,|s| n|}t        ||j                  j                        }	|	dfc S  n t        | ||      S # t        $ r Y w xY w)a  
    Provides information about a module.

    This function isolates the differences in importing libraries introduced with
    python 3.3 on; it gets a module name and optionally a path. It will return a
    tuple containin an open file for the module (if not builtin), the filename
    or the name of the module if it is a builtin one and a boolean indicating
    if the module is contained in a package.
    NfrozenT)r   	meta_path	importlib	machinery
PathFinder	find_specAttributeErrororiginloaderhas_locationImplicitNSInfosubmodule_search_locations_path_find_module_py33)
stringr   r'   is_global_searchspecrk   finderprh   implicit_ns_infos
             r   r)   r)   ~   s     DF-- )*=*=*H*H HAA	((I #{{h&[[F~d&7&7*.FI	#1)T=\=\=b=b#c '--14 VT622'  	 	s   B;;	CCc                 z   |s8t         j                  j                  j                  | |      }||j                  }|0|.	 t         j
                  j                  |       }||j                  }|t        dj                  |             t        ||       S # t        $ r}t        dt        |      z         d }~ww xY w)NzOriginally  zCouldn't find a loader for {})re   rf   rg   rh   rk   util
ValueErrorr*   reprformat_from_loader)rq   r   rk   r'   rr   rs   es          r   rp   rp      s    ""--77E[[F~$,	8>>++F3D ~9@@HII''  	8 ntAw677	8s    -B 	B:B55B:c                    	 | j                   } ||      }	 | j                  } ||      }	 t        |       j                  }|t        j                  j                  j                  ur| j	                  |      }nt        | |      }|d |fS t        | t              r"t        ||t        | j                              |fS t        ||      |fS # t        $ r d}Y w xY w# t        $ r d |fcY S w xY w# t        $ r t        d      w xY w)NFz$get_source was not defined on loader)
is_packageri   get_filenametype
get_sourcer*   re   rf   SourceFileLoader_get_source
isinstancer   r   r   rW   r   )rk   rq   is_package_methodr   r   module_pathfcodes           r   r|   r|      s#   /"-- 'v.
+** #6*BL## 		##44???   (66*|Z&+&dD,@A:MMk40*<<C  
   Z   B@AABs-   C C C/ CCC,+C,/Dc                 |    | j                  |      }	 | j                  |      S # t        $ r t        d|      w xY w)z
    This method is here as a replacement for SourceLoader.get_source. That
    method returns unicode, but we prefer bytes.
    z'source not available through get_data())rL   )r   get_datarU   r*   )rk   fullnamer   s      r   r   r      sJ    
 x(D)t$$ )C') 	))s   $ ;c              #      K   t        |       }t        |      }|j                         }|D ]M  }t        |      }|j                  |k(  s|j	                  |      }|j
                  |j                  d      f O y w)N/)r   r   namelistparentrelative_torL   r[   )zip_pathzip_subdir_pathzip_filezip_content_file_pathsraw_file_name	file_paths         r   rV   rV      sz     x H?+O%..0/ >'	.!--o>I..-"8"8"===	>s   AA<	3A<c                       e Zd ZdZd Zy)rm   z;Stores information returned from an implicit namespace specc                      || _         || _        y r   )rL   r^   )selfrL   r^   s      r   r<   zImplicitNSInfo.__init__   s    	
r   N)__name__
__module____qualname____doc__r<   r   r   r   rm   rm      s
    Er   rm   r(   )NNT)NNNT)'r   r=   r\   re   pathlibr   zipfiler   	zipimportr   r   importlib.machineryr   jedi.inference.compiledr   jedir	   r
   jedi.file_ior   r   r   r   r!   r%   r-   r0   r3   r:   rB   rD   rI   rH   r)   rp   r|   r   rV   rm   r   r   r   <module>r      s    
 	     1 , *   69>
;$		15 &F'3T(,$=N
)> r   