Format: application/x-python-code
⬇ Download File (5.1 KB)
   1  o
   2  
   3  �h7�@s�ddlZddlZddlZddlZddlmZddlmZddlm	Z	dd�Z
   4  dd�Zd$d
   5  d�Zdd
   6  �Z
   7  dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�de�Zedd��Zd%dd�Zd d!�Zd"d#�ZdS)&�N)�chain)�contextmanager)�treecCsJ|j}d|vsd|vr
   8  dStj�tjdd�}tt�t�	|�dt
   9  |���S)Nz
  10  dist-packagesz
  11  site-packagesF�lib�pythonz\d.\d)�parts�os�path�join�sys�prefix�bool�re�match�escape�str)r	r�	base_path�r�Lc:\Users\shubh\Videos\agent\nova\Lib\site-packages\jedi/inference/helpers.py�is_stdlib_paths
  12  rcCsZt�|�}g}|jD]}t|tj�rt�|�}||_nt|�}||_|�|�q
  13  ||_|S)zO
  14      Much, much faster than copy.deepcopy, but just for parser tree nodes.
  15      )�copy�children�
  16  isinstancerZLeaf�parent�
  17  deep_ast_copy�append)�objZnew_objZnew_children�child�	new_childrrrrs
  18  
  19  
  20  rFcCsL|j}|jdkrddlm}|�|j�S|jdks%||jd|jdfvr@|dkr1ddlm}|S|jdkr;|�	|�S|�	|�S|j}|j�
  21  |�}|rN|}n|d	}|jd
  22  krt|}		|	d	8}	|j|	}
  23  |
  24  jdkrinqZ|j|	d	|�}n|jd}
  25  |jd	|�}|
  26  dkr�|d}
  27  |d	d
  28  �}|�	|
  29  �}ddlm}
  30  |D]}|
  31  |||�}q�|S)a�
  32      Creates a "call" node that consist of all ``trailer`` and ``power``
  33      objects.  E.g. if you call it with ``append``::
  34  
  35          list([]).append(3) or None
  36  
  37      You would get a node with the content ``list([]).append`` back.
  38  
  39      This generates a copy of the original ast node.
  40  
  41      If you're using the leaf, e.g. the bracket `)` it will return ``list([])``.
  42  
  43      We use this function for two purposes. Given an expression ``bar.foo``,
  44      we may want to
  45        - infer the type of ``foo`` to offer completions after foo
  46        - infer the type of ``bar`` to be able to jump to the definition of foo
  47      The option ``cut_own_trailer`` must be set to true for the second purpose.
  48      Zfstringr)�compiled�trailer������:)�	NO_VALUESZatom�Z
  49  error_nodeT�awaitN)�
  50  infer_trailer)
  51  r�typeZjedi.inferencerZget_string_value_set�inference_staterZjedi.inference.base_valuer#Z
  52  infer_node�indexZjedi.inference.syntax_treer&)�context�leafZcut_own_trailerr rr#�powerr)�cut�start�baseZtrailers�valuesr&rrr�infer_call_of_leaf-sF
  53  "
  54  
  55  
  56  
  57  
  58  
  59  �
  60  
  61  r1cCsNz|j}Wnty|jdkr|gYSgYSwtt�dd�|D���S)N�namecss�|]}t|�VqdS�N)�get_names_of_node)�.0�crrr�	<genexpr>xs�z$get_names_of_node.<locals>.<genexpr>)r�AttributeErrorr'�listr�
  62  from_iterable)�noderrrrr4os
  63  
  64  
  65  �r4cCs|��ot|jdd�t�S�N)�default)Zis_compiledr�get_safe_valuer��valuerrr�	is_string{srAcCst|�pt|�Sr3)�	is_numberrAr?rrr�
  66  is_literalsrCcCs|jdd�}t||�r
  67  |SdSr<)r>r)r@�acceptrrr�_get_safe_value_or_none�s
  68  �rEcC�
  69  t|t�Sr3)rE�intr?rrr�get_int_or_none��
  70  rHcCrFr3)rErr?rrr�get_str_or_none�rIrJcCst|ttf�duSr3)rErG�floatr?rrrrB�srBc@seZdZdS)�SimpleGetItemNotFoundN)�__name__�
  71  __module__�__qualname__rrrrrL�srLc
  72  gs0�zdVWdS|y}zt|��d}~wwr3)rL)Zexception_classes�errr�reraise_getitem_errors�s���rQcCs�d}g}|dd�D]R}|dvr|s|t|j�7}q
  73  |jdkr;|jddd�D]
  74  }|�|�||ur4nq'q
  75  ||fS|jdkrO|�|�||urN||fSq
  76  |dkrX|sWg}q
  77  ||fS||fS)Nrr$)�.z...Zdotted_name�r2�,)�lenr@r'rr)�nodesZis_import_fromZ
  78  until_node�level�namesr;�nrrr�parse_dotted_names�s8�
  79  
  80  �
  81  �
  82  ��rZcGs|�|dd���|d�S)Nr!)�
  83  import_moduleZpy__getattribute__)r(rXrrr�values_from_qualified_names�sr\cCs"|��j}|durdS|ddvS)NFr)Zpandas�numpyZ
  84  tensorflowZ
  85  matplotlib)Zget_root_context�string_names)r*r^rrr�is_big_annoying_library�s
  86  r_)Fr3)rrrr�	itertoolsr�
  87  contextlibrZparso.pythonrrrr1r4rArCrErHrJrB�	ExceptionrLrQrZr\r_rrrr�<module>s.
  88  B
  89  
  90