U
    nuf[
  ã                   @   s\   d dl mZmZmZmZmZ d dlmZ dd„ ZG dd„ deƒZ	dd„ Z
d	d
„ Zdd„ ZdS )é    )ÚCompiledValueÚCompiledNameÚCompiledValueFilterÚCompiledValueNameÚcreate_from_access_path)ÚLazyValueWrapperc                 C   sJ   | j }|dkr$|j\}t| ¡ ƒ}nt| ¡ ƒ}| |¡\}| ¡ \}|S )N)ÚNoneÚTrueÚFalse)Zbuiltins_moduleZnon_stub_value_setÚnextZget_filtersÚgetZinfer)Úinference_stateÚstringZtyping_builtins_moduleÚbuiltinsZfilter_ÚnameÚvalue© r   úD/tmp/pip-unpacked-wheel-ol4ehs9f/jedi/inference/compiled/__init__.pyÚbuiltin_from_name	   s    
r   c                       s8   e Zd ZdZdd„ Z‡ fdd„Zdd„ Zdd	„ Z‡  ZS )
Ú
ExactValuezœ
    This class represents exact values, that makes operations like additions
    and exact boolean values possible, while still being a "normal" stub.
    c                 C   s   |j | _ || _d S ©N)r   Ú_compiled_value)ÚselfÚcompiled_valuer   r   r   Ú__init__   s    zExactValue.__init__c                    s    |dkrt | j|ƒS tƒ  |¡S )N)Zget_safe_valueZexecute_operationZaccess_handleÚnegateZ
py__bool__Zis_compiled)Úgetattrr   ÚsuperÚ__getattribute__)r   r   ©Ú	__class__r   r   r      s    zExactValue.__getattribute__c                 C   s   t | j| jjjƒ ¡ \}|S r   )r   r   r   r   Zstring_nameÚexecute_with_values)r   Úinstancer   r   r   Ú_get_wrapped_value$   s
     ÿ
zExactValue._get_wrapped_valuec                 C   s   d| j j| jf S )Nz<%s: %s>)r    Ú__name__r   )r   r   r   r   Ú__repr__)   s    zExactValue.__repr__)	r$   Ú
__module__Ú__qualname__Ú__doc__r   r   r#   r%   Ú__classcell__r   r   r   r   r      s
   r   c                 C   s@   t |ƒtttttttfks&tt	|ƒƒ‚t
| | j |¡ƒ}t|ƒS )z`
    Only allows creations of objects that are easily picklable across Python
    versions.
    )ÚtypeÚintÚfloatÚstrÚbytesÚsliceÚcomplexÚboolÚAssertionErrorÚreprr   Úcompiled_subprocessÚcreate_simple_objectr   )r   Úobjr   r   r   r   r5   -   s    &
þr5   c                 C   s   t | dƒ ¡ S )Nr-   )r   r!   )r   r   r   r   Úget_string_value_set:   s    r7   c                 K   s:   |  d¡rd S | jjf d|i|—Ž}|d kr0d S t| |ƒS )Nztensorflow.Údotted_name)Ú
startswithr4   Úload_moduler   )r   r8   ÚkwargsZaccess_pathr   r   r   r:   >   s    
r:   N)Zjedi.inference.compiled.valuer   r   r   r   r   Zjedi.inference.base_valuer   r   r   r5   r7   r:   r   r   r   r   Ú<module>   s   