Format: application/x-python-code
⬇ Download File (2.0 KB)
   1  o
   2  
   3  ��h��@s0dZddlZddlZdd�Zdd�Zdd�ZdS)	z:A fancy version of Python's builtin :func:`dir` function.
   4  �NcCszt||�WdSYdS)zfIn recent versions of Python, hasattr() only catches AttributeError.
   5      This catches all errors.
   6      TF)�getattr)�obj�attr�r�Hc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/utils/dir2.py�safe_hasattrs
   7  
   8  rcCs\ztt|��}Wntyt�}Ynwt|d�r#|tt|j��O}dd�|D�}t|�S)avdir2(obj) -> list of strings
   9  
  10      Extended version of the Python builtin dir(), which does a few extra
  11      checks.
  12  
  13      This version is guaranteed to return only a list of true strings, whereas
  14      dir() returns anything that objects inject into themselves, even if they
  15      are later not really valid for attribute access (many extension libraries
  16      have such bugs).
  17      �	__class__cSsg|]	}t|t�r|�qSr)�
  18  isinstance�str)�.0�wrrr�
  19  <listcomp>2szdir2.<locals>.<listcomp>)�set�dir�	Exceptionrr�sorted)r�wordsrrr�dir2s
  20  �
  21  rcCs�zt|dd�}Wn
  22  tyYdSw|durdSzt||d�}Wn
  23  ty+YdSwt�|�r9t|tj�s9dSt|�r?|SdS)aELike getattr, but with a few extra sanity checks:
  24  
  25      - If obj is a class, ignore everything except class methods
  26      - Check if obj is a proxy that claims to have all attributes
  27      - Catch attribute access failing with any exception
  28      - Check that the attribute is a callable object
  29  
  30      Returns the method or None.
  31      Z(_ipython_canary_method_should_not_exist_N)rr�inspect�isclassr	�types�
  32  MethodType�callable)r�nameZcanary�mrrr�get_real_method6s"
  33  ��r)�__doc__rrrrrrrrr�<module>s