
    Mh!                        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&dS )!    N)Path)ZipFile)zipimporterZipImportError)all_suffixes)access)debug)parser_utils)KnownContentFileIO	ZipFileIOc                      t           j        S N)syspath     l/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jedi/inference/compiled/subprocess/functions.pyget_sys_pathr      s	    8Or   c                 &    t          j        | fi |S r   )r   load_module)inference_statekwargss     r   r   r      s    o88888r   c                 l    | j                             |          } t          |j        |          |i |S r   )compiled_subprocessget_access_handlegetattrr   )r   id	attributeargsr   handles         r   get_compiled_method_returnr!      s9    0BB2F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           _        dS dS w xY w# ||t           _        w xY w)zK
    Returns Tuple[Union[NamespaceInfo, FileIO, None], Optional[bool]]
    N	full_nameNNr   )r   r   _find_moduleImportError)r   sys_pathr'   r   temps        r   get_module_infor-   !   s     !38$::i:6:: CHH      CHHH   CHOOOOs!   : 
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                                         |/t          |           t          j                                         dS dS )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:   ;   sf     f3:&&&&
f
 r   c                     t                      D ]H}t          j                            | d|z             }t          j                            |          r|c S IdS )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   sZ    
 ..  w||NJ,?@@7>>$ 	KKK	4r   c                 *    t          j        |          S r   )r
   safe_literal_eval)r   values     r   rD   rD   S   s    )%000r   c                  4    t          t          | i |          S r   )list_iter_module_names)r   r   s     r   iter_module_namesrI   W   s    "D3F33444r   c              #     K   |D ]}	 d t          j        |          D             }na# t          $ rT 	 t          |          }t	          |j        |j                  }n&# t          $ r t          j	        d|           Y Y yw xY wY nw xY w|D ]j\  }}|r|dk    r|
                                r|V  &|                    d          r|d d         }nt          j        |          }|rd|vr
|dk    r|V  kd S )Nc              3   L   K   | ]}|j         |                                fV   d S r   )nameis_dir).0entrys     r   	<genexpr>z%_iter_module_names.<locals>.<genexpr>_   s1      VVEEJ7VVVVVVr   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   [   sq      & &	VVRZPTEUEUVVVKK 	 	 	
"-d"3"3 5#+_-CE E!   BDIII 	 ( 	& 	&LD& & =((T->->-@-@(JJJ==(( :"3B3iGG%3D99G &s'11*,,%	&& &s2   '
B)ABA?;B>A??BBTc                 X   d}d}t           j        D ]}|r|t          j        j        k    rd}n|}	 |j        }n# t          $ r Y 3w xY w || |          }|D|j        dk    rQ|j        }|-|j	        s&|s| n|}t          ||j        j                  }	|	dfc S  nt          | ||          S )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AAA	(II 	 	 	 H	
 y##{h&&[F~d&7~*.=FFI	#1)T=\=b#c#c '----E  VT6222s   8
AAc                    |s.t           j        j                            | |          }||j        }|]|[	 t           j                            |           }||j        }n1# t          $ r$}t          dt          |          z             d }~ww xY w|"t          d	                    |                     t          ||           S )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E[F~$,	8>++F33D 	8 	8 	8 ntAww6777	8
 ~9@@HHIII'''s   (A 
B)BBc                 $   	 | j         } ||          }n# t          $ r d}Y nw xY w	 | j        } ||          }n# t          $ r d |fcY S w xY w	 t          |           j        }n# t          $ r t          d          w xY w|t          j        j        j        ur|                     |          }nt          | |          }|d |fS t          | t                    r%t          ||t          | j                            |fS t          ||          |fS )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|      sq   /"- '&v..

    


+* #l6**       Z BLL# B B B@AAAB 		#4???   ((66**|Z&+&& NdD,@,@AA:MMk400*<<s'    $$; AAA% %A?c                     |                      |          }	 |                     |          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      sf    
 x((D)t$$$ ) ) )C') ) ) 	))s	   , Ac              #     K   t          |           }t          |          }|                                }|D ]O}t          |          }|j        |k    r3|                    |          }|j        |                    d          fV  Pd S )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      s      x  H?++O%..00/ > >''	..!--o>>I.-"8"8"="=====	> >r   c                       e Zd ZdZd ZdS )rm   z;Stores information returned from an implicit namespace specc                 "    || _         || _        d S 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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 1 1 1 1 1 1 1 , , , , , , * * * * * *             6 6 6 6 6 6 6 6  9 9 9> > >
; ; ;   $ $ $  	 	 	 		 	 	1 1 15 5 5 &  &  &F'3 '3 '3 '3T( ( ( (,$= $= $=N
) 
) 
)> > >         r   