
    f                     *    d Z ddlZddlZd Zd Zd Zy)z:A fancy version of Python's builtin :func:`dir` function.
    Nc                 ,    	 t        | |       y#  Y yxY w)zfIn recent versions of Python, hasattr() only catches AttributeError.
    This catches all errors.
    TF)getattr)objattrs     M/var/www/cvtools/html/venv/lib/python3.12/site-packages/IPython/utils/dir2.pysafe_hasattrr      s    Ts    c                    	 t        t        |             }t        | d      r!|t        t        | j                              z  }|D cg c]  }t        |t              s| }}t        |      S # t        $ r t               }Y mw xY wc c}w )av  dir2(obj) -> list of strings

    Extended version of the Python builtin dir(), which does a few extra
    checks.

    This version is guaranteed to return only a list of true strings, whereas
    dir() returns anything that objects inject into themselves, even if they
    are later not really valid for attribute access (many extension libraries
    have such bugs).
    	__class__)setdir	Exceptionr   r
   
isinstancestrsorted)r   wordsws      r   dir2r      s|    CH
 C%S'((
 41As!3Q4E4%=   5s   A. BB.BBc                     	 t        | dd      }|y	 t        | |d      }t        j                  |       rt	        |t
        j                        syt        |      r|S y# t        $ r Y yw xY w# t        $ r Y yw xY w)aE  Like getattr, but with a few extra sanity checks:

    - If obj is a class, ignore everything except class methods
    - Check if obj is a proxy that claims to have all attributes
    - Catch attribute access failing with any exception
    - Check that the attribute is a callable object

    Returns the method or None.
    (_ipython_canary_method_should_not_exist_N)r   r   inspectisclassr   types
MethodTypecallable)r   namecanaryms       r   get_real_methodr   6   s    H$O Ct$ sJq%2B2B$C{%    s"   A A- 	A*)A*-	A98A9)__doc__r   r   r   r   r        r   <module>r"      s!     >r!   