Format: application/x-python-code
1 o
2
3 ��h� � @ s0 d Z ddlZddlZdd� Zdd� Zdd� ZdS ) z:A fancy version of Python's builtin :func:`dir` function.
4 � Nc C s zt | |� W dS Y dS )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 r c C s\ zt t| ��}W n ty t � }Y nw t| d�r#|t t| j��O }dd� |D �}t|�S )av dir2(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__c S s g | ] }t |t�r|�qS r )�
18 isinstance�str)�.0�wr r r �
19 <listcomp>2 s zdir2.<locals>.<listcomp>)�set�dir� Exceptionr r �sorted)r �wordsr r r �dir2 s
20 �
21 r c C s� zt | dd�}W n
22 ty Y dS w |durdS zt | |d�}W n
23 ty+ Y dS w t�| �r9t|tj�s9dS t|�r?|S dS )aE Like 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)r r �inspect�isclassr �types�
32 MethodType�callable)r �nameZcanary�mr r r �get_real_method6 s"