a
    ‹©lc¸  ã                   @   s0   d Z ddlZddlZdd„ Zdd„ Zdd„ ZdS )	z:A fancy version of Python's builtin :func:`dir` function.
é    Nc                 C   s$   zt | |ƒ W dS    Y dS 0 dS )zfIn recent versions of Python, hasattr() only catches AttributeError.
    This catches all errors.
    TFN)Úgetattr)ÚobjÚattr© r   úN/var/www/html/django/DPS/env/lib/python3.9/site-packages/IPython/utils/dir2.pyÚsafe_hasattr   s
    
r   c                 C   s\   zt t| ƒƒ}W n ty(   t ƒ }Y n0 t| dƒrF|t t| jƒƒO }dd„ |D ƒ}t|ƒS )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__c                 S   s   g | ]}t |tƒr|‘qS r   )Ú
isinstanceÚstr)Ú.0Úwr   r   r   Ú
<listcomp>2   ó    zdir2.<locals>.<listcomp>)ÚsetÚdirÚ	Exceptionr   r   Úsorted)r   Úwordsr   r   r   Údir2   s    
r   c                 C   s‚   zt | ddƒ}W n ty$   Y dS 0 |dur2dS zt | |dƒ}W n tyV   Y dS 0 t | ¡rrt|tjƒsrdS t|ƒr~|S dS )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.
    Z(_ipython_canary_method_should_not_exist_N)r   r   ÚinspectÚisclassr	   ÚtypesÚ
MethodTypeÚcallable)r   ÚnameZcanaryÚmr   r   r   Úget_real_method6   s    
r   )Ú__doc__r   r   r   r   r   r   r   r   r   Ú<module>   s
   