
    Mh                        d dl Z d dlmZ d dlmZ d dlmZ d dlmZm	Z	 d dl
mZmZ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 d dlmZ d dlmZ  G d de          Z G d d          Z G d de          Z G d dee          ZdS )    N)Path)Optional)inference_state_method_cache)AbstractNameDefinition
ModuleName)GlobalNameFilterParserTreeFilter
DictFilterMergedFilter)compiled)	TreeValue)SubModuleName)values_from_qualified_names)create_simple_object)ValueSetModuleContextc                   $    e Zd ZdZdZddZd ZdS )_ModuleAttributeNamezA
    For module attributes like __file__, __str__ and so on.
    instanceNc                 0    || _         || _        || _        d S N)parent_contextstring_name_string_value)selfparent_moduler   string_values       [/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jedi/inference/value/module.py__init__z_ModuleAttributeName.__init__   s     +&)    c                     | j         /| j         }t          t          | j        j        |          g          S t          j        | j        j                  S r   )r   r   r   r   inference_stater   get_string_value_set)r   ss     r   inferz_ModuleAttributeName.infer   sV    )"A$T%8%H!LL    ,T-@-PQQQr!   r   )__name__
__module____qualname____doc__api_typer    r&    r!   r   r   r      sM          H* * * *
R R R R Rr!   r   c                   4    e Zd Z e            d             ZdS )SubModuleDictMixinc                     i }|                                  r[| j        j                            |                                           }|D ]'}t          |                                 |          ||<   (|S )zf
        Lists modules in the directory of this module (if this module is a
        package).
        )
is_packager#   compiled_subprocessiter_module_names
py__path__r   
as_context)r   namesmodsnames       r   sub_modules_dictz#SubModuleDictMixin.sub_modules_dict&   s}     ?? 	E';MM!! D  E E+DOO,=,=tDDd r!   N)r'   r(   r)   r   r8   r,   r!   r   r.   r.   %   s7        !!##  $#  r!   r.   c                       e Zd ZeZddZd Zd Zd Ze	 e
            d                         Z e
            d             Zd Z e
g           d	             Zd
 ZdS )ModuleMixinNc              #   n  K   t          t          |                                 |          t          |                                                     V  t	          |                                           V  t	          |                                           V  |                                 E d {V  d S )N)r   origin_scope)r   r	   r4   r   r
   r8   _module_attributes_dictiter_star_filters)r   r<   s     r   get_filterszModuleMixin.get_filters=   s      #00)   T__..//
 
 	
 	
 	
 ..0011111557788888))+++++++++++r!   c                 6    t          | j        dd          \  }|S )Ntypes
ModuleType)r   r#   )r   cs     r   py__class__zModuleMixin.py__class__I   s    ()=wUUr!   c                     dS )NTr,   r   s    r   	is_modulezModuleMixin.is_moduleM   s    tr!   c                     dS )NFr,   rF   s    r   is_stubzModuleMixin.is_stubP   s    ur!   c                 D    |                      | | j        d                   S N)_module_name_classstring_namesrF   s    r   r7   zModuleMixin.nameS   s"     &&tT->r-BCCCr!   c                      g d}t           fd|D                       }                                 }|!t           dt          |                    |d<   |S )N)__package__r*   r'   c              3   <   K   | ]}|t          |          fV  d S r   )r   ).0nr   s     r   	<genexpr>z6ModuleMixin._module_attributes_dict.<locals>.<genexpr>\   s3      EE!A+D!445EEEEEEr!   __file__)dict
py__file__r   str)r   r5   dctpaths   `   r   r=   z#ModuleMixin._module_attributes_dictX   se    666EEEEuEEEEE  24SYYOOC
O
r!   c              #      K   |                                  D ],}t          |                                d           }|J |V  -d S r   )star_importsnextr?   )r   star_modulefs      r   r>   zModuleMixin.iter_star_filtersb   sZ      ,,.. 	 	K[,,..55A===GGGG	 	r!   c                    ddl m} g }|                                 }| j                                        D ]}|                                ry || j        |                                d         ||j                  	                                }|D ].}t          |t                    r||                                z  }/||z  }|S )Nr   )ImporterrL   )import_pathmodule_contextlevel)jedi.inference.importsra   r4   	tree_nodeiter_importsis_star_importr#   	get_pathsrd   follow
isinstanceModuleValuer\   )r   ra   modulesrc   inewmodules          r   r\   zModuleMixin.star_importsk   s    333333**,,.. 	 	A!! h( !b 1#1'	  
 &((  " 9 9F!&+66 96#6#6#8#883r!   c                     dS )z
        A module doesn't have a qualified name, but it's important to note that
        it's reachable and not `None`. With this information we can add
        qualified names on top for all value children.
        r,   r,   rF   s    r   get_qualified_nameszModuleMixin.get_qualified_names   s	     rr!   r   )r'   r(   r)   r   rM   r?   rD   rG   rI   propertyr   r7   r=   r>   r\   rr   r,   r!   r   r:   r:   :   s        #
, 
, 
, 
,       !!##D D $# XD "!##  $#   "!"%%  &%(    r!   r:   c                   n     e Zd ZdZ	 	 d fd	Z fdZd Zdee         fdZ	d	 Z
d
 Zd Zd Zd Z xZS )rl   rp   NFc                     t                                          |d |           || _        |d | _        n|j        | _        || _        || _        || _        d S )N)r   rf   )superr    file_io_pathrZ   rN   
code_lines_is_package)r   r#   module_nodery   rw   rN   r0   	__class__s          r   r    zModuleValue.__init__   sj    ! 	 	
 	
 	

 ?)-DJJ DJ($%r!   c                 v    | j         | j         j        dk    rdS t                                                      S )Nz.pyiT)rx   suffixrv   rI   )r   r|   s    r   rI   zModuleValue.is_stub   s5    :!dj&76&A&A 4ww   r!   c                 H    | j         d S d                    | j                   S )N.)rN   joinrF   s    r   
py__name__zModuleValue.py__name__   s%    $4xx)***r!   returnc                 F    | j         dS | j                                         S )z?
        In contrast to Python's __file__ can be None.
        N)rx   absoluterF   s    r   rW   zModuleValue.py__file__   s%     :4z""$$$r!   c                     | j         S r   )rz   rF   s    r   r0   zModuleValue.is_package   s    r!   c                 N    | j         g S | j        r| j         S | j         d d         S rK   )rN   rz   rF   s    r   py__package__zModuleValue.py__package__   s6    $I 	%$$ "%%r!   c                 &   | j         sdS d                    | j        dd                   }d}|d         |v s
|d         |v rt                      }| j                                        D ]`}t          j                            || j        j	                  }t          j        
                    |          r|                    |           a|rt          |          S |                                 }|J t          j                            |          gS )z
        In case of a package, this returns Python's __path__ attribute, which
        is a list of paths (strings).
        Returns None if the module is not a package.
        N 2   )zdeclare_namespace(__name__)zextend_path(__path__r      )rz   r   ry   setr#   get_sys_pathosrZ   r7   r   isdiraddlistrW   dirname)r   first_few_linesoptionspathsr%   otherfiles          r   r3   zModuleValue.py__path__   s     	4 ''$/#2#"677 J1:((GAJ/,I,I EEE)6688 % %Q	(=>>7=='' %IIe$$$ #E{{"   %%&&r!   c                      t          |           S r   r   rF   s    r   _as_contextzModuleValue._as_context   s    T"""r!   c                     d| j         j        d|                                 d| j        j        d         d| j        j        d         d|                                 dS )N<z: @r   -z	 is_stub=>)r|   r'   r   rf   	start_posend_posrI   rF   s    r   __repr__zModuleValue.__repr__   sb     N###T__%6%6%6%6N$Q''')?)B)B)BLLNNNN
 	
r!   )NNF)r'   r(   r)   r+   r    rI   r   r   r   rW   r0   r   r3   r   r   __classcell__)r|   s   @r   rl   rl      s        HIM/4& & & & & & ! ! ! ! !+ + +
%HTN % % % %     & & &' ' 'B# # #
 
 
 
 
 
 
r!   rl   )r   pathlibr   typingr   jedi.inference.cacher   jedi.inference.namesr   r   jedi.inference.filtersr   r	   r
   r   jedi.inferencer   jedi.inference.base_valuer   r   jedi.inference.helpersr   jedi.inference.compiledr   r   jedi.inference.contextr   r   r.   r:   rl   r,   r!   r   <module>r      s   				             = = = = = = C C C C C C C C _ _ _ _ _ _ _ _ _ _ _ _ # # # # # # / / / / / / . . . . . . > > > > > > 8 8 8 8 8 8 . . . . . . 0 0 0 0 0 0R R R R R1 R R R(       *L L L L L$ L L L^]
 ]
 ]
 ]
 ]
+y ]
 ]
 ]
 ]
 ]
r!   