
    f                        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y)    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y)_ModuleAttributeNamezA
    For module attributes like __file__, __str__ and so on.
    instanceNc                 .    || _         || _        || _        y N)parent_contextstring_name_string_value)selfparent_moduler   string_values       V/var/www/cvtools/html/venv/lib/python3.12/site-packages/jedi/inference/value/module.py__init__z_ModuleAttributeName.__init__   s    +&)    c                     | j                   6| 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   s`    )""A$T%8%8%H%H!L   ,,T-@-@-P-PQQr!   r   )__name__
__module____qualname____doc__api_typer    r&    r!   r   r   r      s     H*
Rr!   r   c                   &    e Zd Z e       d        Zy)SubModuleDictMixinc                     i }| j                         rW| j                  j                  j                  | j	                               }|D ]  }t        | j                         |      ||<   ! |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&   sj     ??'';;MM!D  E+DOO,=tDdE r!   N)r'   r(   r)   r   r8   r,   r!   r   r.   r.   %   s    !# $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y)ModuleMixinNc              #   (  K   t        t        | j                         |      t        | j                                      t	        | j                                t	        | j                                | j                         E d {    y 7 w)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=   su     #0) T__./
 	
 ..01155788))+++s   BB
BBc                 8    t        | j                  dd      \  }|S )Ntypes
ModuleType)r   r#   )r   cs     r   py__class__zModuleMixin.py__class__I   s    ()=)=wUr!   c                      y)NTr,   r   s    r   	is_modulezModuleMixin.is_moduleM   s    r!   c                      y)NFr,   rF   s    r   is_stubzModuleMixin.is_stubP   s    r!   c                 @    | j                  | | j                  d         S N)_module_name_classstring_namesrF   s    r   r7   zModuleMixin.nameS   s"     &&tT->->r-BCCr!   c                      g d}t         fd|D              } j                         }|t         dt        |            |d<   |S )N)__package__r*   r'   c              3   :   K   | ]  }|t        |      f  y wr   )r   ).0nr   s     r   	<genexpr>z6ModuleMixin._module_attributes_dict.<locals>.<genexpr>\   s     E!A+D!45Es   __file__)dict
py__file__r   str)r   r5   dctpaths   `   r   r=   z#ModuleMixin._module_attributes_dictX   sE    6EuEE 24SYOC
O
r!   c              #   z   K   | j                         D ]$  }t        |j                         d       }|J | & y wr   )star_importsnextr?   )r   star_modulefs      r   r>   zModuleMixin.iter_star_filtersb   sB     ,,. 	K[,,.5A= =G	s   9;c                 t   ddl m} g }| j                         }| j                  j	                         D ]  }|j                         s || j                  |j                         d   ||j                        j                         }|D ]&  }t        |t              s||j                         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*,,. 	A!(( !b 1#1''	
 &(  " 9F!&+66#6#6#889 3	 r!   c                      y)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     r!   r   )r'   r(   r)   r   rM   r?   rD   rG   rI   propertyr   r7   r=   r>   r\   rr   r,   r!   r   r:   r:   :   sw    #
, !#D $ D "# $ ""% &(r!   r:   c                   h     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   c                     t         |   |d |       || _        |d | _        n|j                  | _        || _        || _        || _        y )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__   sU    ! 	 	

 ?)-DJ DJ($%r!   c                 l    | j                   | j                   j                  dk(  ryt        |          S )Nz.pyiT)rx   suffixrv   rI   )r   r|   s    r   rI   zModuleValue.is_stub   s0    ::!djj&7&76&A w  r!   c                 R    | j                   y dj                  | j                         S )N.)rN   joinrF   s    r   
py__name__zModuleValue.py__name__   s&    $xx))**r!   returnc                 P    | j                   y| j                   j                         S )z?
        In contrast to Python's __file__ can be None.
        N)rx   absoluterF   s    r   rW   zModuleValue.py__file__   s$     ::zz""$$r!   c                     | j                   S r   )rz   rF   s    r   r0   zModuleValue.is_package   s    r!   c                 l    | j                   g S | j                  r| j                   S | j                   d d S rK   )rN   rz   rF   s    r   py__package__zModuleValue.py__package__   s;    $I$$$  "%%r!   c                    | j                   sydj                  | j                  dd       }d}|d   |v s|d   |v rt               }| j                  j                         D ]g  }t        j                  j                  || j                  j                        }t        j                  j                  |      sW|j                  |       i |rt        |      S | j                         }|J t        j                  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      ''$//#2"67 J1:(GAJ/,I EE))668 %Q		(=(=>77=='IIe$% E{"  %&&r!   c                     t        |       S r   r   rF   s    r   _as_contextzModuleValue._as_context   s    T""r!   c                     d| j                   j                  d| j                         d| j                  j                  d   d| j                  j
                  d   d| j                         dS )N<z: @r   -z	 is_stub=>)r|   r'   r   rf   	start_posend_posrI   rF   s    r   __repr__zModuleValue.__repr__   sN    NN##T__%6NN$$Q')?)?)BLLN
 	
r!   )NNF)r'   r(   r)   r+   r    rI   r   r   r   rW   r0   r   r3   r   r   __classcell__)r|   s   @r   rl   rl      sG    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      sh    	   = C _ _ # / . > 8 . 0R1 R( *L$ L^]
+y ]
r!   