o
    û›hû¦  ã                   @   s  U d Z ddgZddlmZ ddlmZ ddlmZ ddlZddl	Z	ddlZddl
ZddlZddlZddlZddlZddlmZmZmZmZmZmZmZmZmZ ddlZdd	lmZ dd
lmZ ddlm Z  ddl!m"Z"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 dZ9ee:eee:e:f  f Z;ee<d< ee:e:f Z=ee<d< eG dd„ dƒƒZ>dd„ Z?ej@jAj ZBeCjDj ZEdd„ ejFejGej@eHfD ƒZIeJeKƒZLeJe:jMƒZNe.ZOe"jPZQG d d!„ d!eƒZReSeRj< T¡ ƒZUd"d#„ ZVeG d$d%„ d%ƒƒZWe2d&d&d&d'œd(e:d)eXd*eXd+eXd,eXd-eRfd.d/„ƒZYd0d1„ ZZd-ee:df fd2d3„Z[dId-ee:df fd5d6„Z\d7d8„ Z]e2d9d:„ ƒZ^e2d;d<„ ƒZ_e2dJd>d?„ƒZ`d@dA„ Zad-ee: fdBdC„ZbdDdE„ ZcG dFd„ de0ƒZdd-e:fdGdH„ZedS )KzøTools for inspecting Python objects.

Uses syntax highlighting for presenting the various information elements.

Similar in spirit to the inspect module, but all calls take a name argument to
reference the name under which an object is being read.
Ú	InspectorÚInspectColorsé    )Ú	dataclass)Ú	signature)ÚdedentN)	ÚcastÚAnyÚOptionalÚDictÚUnionÚListÚ	TypedDictÚ	TypeAliasÚTuple)Úpage)Úpretty)Úskip_doctest)Ú
PyColorizeÚopenpy)Úsafe_hasattr)Úcompress_user)Úindent)Úlist_namespaceÚtypestr2type)Ú
TermColors)Ú	Colorable)Úundoc)Ú	highlight)ÚPythonLexer)ÚHtmlFormatterZ__custom_documentations__ÚUnformattedBundleÚBundlec                   @   sJ   e Zd ZU eed< eed< eed< ee ed< eed< eed< dd„ Zd	S )
ÚOInfoÚismagicÚisaliasÚfoundÚ	namespaceÚparentÚobjc                 C   s
   t | |ƒS )z†Get a field from the object for backward compatibility with before 8.12

        see https://github.com/h5py/h5py/issues/2253
        )Úgetattr)ÚselfÚfield© r,   úKc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/oinspect.pyÚgetK   s   
z	OInfo.getN)	Ú__name__Ú
__module__Ú__qualname__ÚboolÚ__annotations__r	   Ústrr   r.   r,   r,   r,   r-   r"   B   s   
 r"   c                 C   s   t | tƒ tdd�ƒS )NT)Z	noclasses)r   r   r   )Úcoder,   r,   r-   Úpylight\   s   r6   c                 C   s   h | ]}t  |¡’qS r,   )ÚinspectÚgetdoc)Ú.0Útr,   r,   r-   Ú	<setcomp>b   s    
ÿr;   c                   @   sê   e Zd ZU ee ed< ee ed< ee ed< ee ed< ee ed< ee ed< ee ed< ee ed< ee ed	< ee ed
< ee ed< ee ed< ee ed< ee ed< ee ed< eed< eed< eed< eed< eed< dS )ÚInfoDictÚ	type_nameÚ
base_classÚstring_formr&   ÚlengthÚfileÚ
definitionÚ	docstringÚsourceÚinit_definitionÚclass_docstringÚinit_docstringÚcall_defÚcall_docstringÚ
subclassesr#   r$   Úisclassr%   ÚnameN)r/   r0   r1   r	   r4   r3   r2   r,   r,   r,   r-   r<   t   s*   
 r<   c                 C   s0   | dkrt jdtdd� tS tdt›d| ›�ƒ‚)NZinfo_fieldszfIPython.core.oinspect's `info_fields` is considered for deprecation and may be removed in the Future. é   ©Ú
stacklevelzmodule z has no attribute )ÚwarningsÚwarnÚDeprecationWarningÚ_info_fieldsÚAttributeErrorr/   )rL   r,   r,   r-   Ú__getattr__�   s   ýrU   c                   @   sB   e Zd ZU dZeed< ee ed< eed< e	ed< e
e ed< dS )ÚInspectorHookDatazData passed to the mime hookr(   ÚinfoÚ	info_dictÚdetail_levelÚomit_sectionsN)r/   r0   r1   Ú__doc__r   r3   r	   r"   r<   ÚintÚlistr4   r,   r,   r,   r-   rV   œ   s   
 rV   F)rK   r$   r#   rL   r%   rK   r$   r#   Úreturnc                    sL   |‰ ‡ fdd„t D ƒ‰ | ˆ d< |ˆ d< |ˆ d< |ˆ d< |ˆ d< td	i ˆ ¤ŽS )
z1Make an object info dict with all fields present.c                    s   i | ]	}|ˆ vr|d “qS ©Nr,   )r9   Úk©Zinfodictr,   r-   Ú
<dictcomp>³   s    zobject_info.<locals>.<dictcomp>rL   r%   rK   r$   r#   Nr,   )rS   r<   )rL   r%   rK   r$   r#   Úkwr,   ra   r-   Úobject_info§   s   rd   c                 C   st   t | ƒ}|du r
dS | d¡rdS tj |¡sdS t |d¡�}t |j	¡\}}W d  ƒ |S 1 s3w   Y  |S )znGet encoding for python source file defining obj

    Returns None if obj is not defined in a sourcefile.
    N©z.soz.dllz.pydÚrb)
Ú	find_fileÚendswithÚosÚpathÚisfileÚ	stdlib_ioÚopenr   Údetect_encodingÚreadline)r(   ÚofileÚbufferÚencodingÚ_linesr,   r,   r-   Úget_encoding½   s   

ÿþrt   c                 C   sB   z|   ¡ }W n	 ty   Y nw t|tƒrt |¡S t  | ¡}|S )a=  Stable wrapper around inspect.getdoc.

    This can't crash because of attribute problems.

    It also attempts to call a getdoc() method on the given object.  This
    allows objects which provide their docstrings via non-standard mechanisms
    (like Pyro proxies) to still be inspected by ipython's ? system.
    )r8   Ú	ExceptionÚ
isinstancer4   r7   Úcleandoc)r(   ÚdsZdocstrr,   r,   r-   r8   Õ   s   
ÿ


r8   Ú c           	      C   s  t | tƒrTg }dD ]A}t| |ƒ}|durJt|ƒ}|rd| nd}| d d||f¡¡ t |¡r>t|ƒ}|r=| t	|ƒ¡ q	| d||t
|ƒf ¡ q	|rRd |¡S dS t| ƒ} zt | ¡}W |S  ty   z
t | j¡}W Y |S  ttfy~   Y Y dS w  tyˆ   Y dS w )al  Wrapper around inspect.getsource.

    This can be modified by other projects to provide customized source
    extraction.

    Parameters
    ----------
    obj : object
        an object whose source code we will attempt to extract
    oname : str
        (optional) a name under which the object is known

    Returns
    -------
    src : unicode or None

    )ÚfgetÚfsetÚfdelNz%s.ry   z# z
%s%s = %s
Ú
)rv   Úpropertyr)   rt   ÚappendÚjoinr7   Ú
isfunctionÚ	getsourcer   r   Ú_get_wrappedÚ	TypeErrorÚ	__class__ÚOSError)	r(   ÚonameÚsourcesÚattrnameÚfnrr   Zoname_prefixZ_srcÚsrcr,   r,   r-   r‚   ê   sD   


€ÿ€
öûÿÿr‚   c                 C   s(   t  | ¡pt  | ¡pt| tƒpt| tƒS )zTrue if obj is a function ())r7   r�   Úismethodrv   Ú_builtin_func_typeÚ_builtin_meth_type©r(   r,   r,   r-   Úis_simple_callable)  s
   ÿÿr�   c                 C   s2   t jdtdd� t| dƒrt| ƒs| j} t | ¡S )zâWrapper around :func:`inspect.getfullargspec`

    In addition to functions and methods, this can also handle objects with a
    ``__call__`` attribute.

    DEPRECATED: Deprecated since 7.10. Do not use, will be removed.
    z]`getargspec` function is deprecated as of IPython 7.10and will be removed in future versions.rM   rN   Ú__call__)rP   rQ   rR   r   r�   r‘   r7   Úgetfullargspecr�   r,   r,   r-   Ú
getargspec.  s   
ÿ
r“   c                 C   s0   t jdtdd� t | d | d | d | d ¡S )a  Format argspect, convenience wrapper around inspect's.

    This takes a dict instead of ordered arguments and calls
    inspect.format_argspec with the arguments in the necessary order.

    DEPRECATED (since 7.10): Do not use; will be removed in future versions.
    za`format_argspec` function is deprecated as of IPython 7.10and will be removed in future versions.rM   rN   ÚargsÚvarargsÚvarkwÚdefaults)rP   rQ   rR   r7   Úformatargspec)Úargspecr,   r,   r-   Úformat_argspec@  s   
ÿÿrš   Tc              	   C   s´   t jdtdd� |  d¡}|du rd}n*z
|d d dk}W n ttfy)   Y nw |r6|d d	d… |d< | d
 t|ƒ }|  d¡}|du rL|  d¡}|du rV|  dd¡}||fS )z?DEPRECATED since 6.0. Extract call tip data from an oinfo dict.zZ`call_tip` function is deprecated as of IPython 6.0and will be removed in future versions.rM   rN   r™   Nr”   r   r*   é   rL   rI   rG   rC   ry   )rP   rQ   rR   r.   ÚKeyErrorÚ
IndexErrorrš   )ZoinfoZformat_callr™   Z	call_lineZhas_selfÚdocr,   r,   r-   Úcall_tipQ  s,   ü
ÿ

rŸ   c                 C   s:   | }d}t | dƒr| j} |d7 }|dkr|S t | dƒs	| S )aN  Get the original object if wrapped in one or more @decorators

    Some objects automatically construct similar objects on any unrecognised
    attribute access (e.g. unittest.mock.call). To protect against infinite loops,
    this will arbitrarily cut off after 100 levels of obj.__wrapped__
    attribute access. --TK, Jan 2016
    r   Ú__wrapped__r›   éd   )r   r    )r(   Zorig_objÚir,   r,   r-   rƒ   w  s   

ûrƒ   c                 C   sn   t | ƒ} d}zt | ¡}W |S  ty-   z
t | j¡}W Y |S  ttfy,   Y Y |S w  ty6   Y |S w )a^  Find the absolute path to the file where an object was defined.

    This is essentially a robust wrapper around `inspect.getabsfile`.

    Returns None if no file can be found.

    Parameters
    ----------
    obj : any Python object

    Returns
    -------
    fname : str
        The absolute path to the file where the object was defined.
    N)rƒ   r7   Ú
getabsfiler„   r…   r†   )r(   Úfnamer,   r,   r-   rg   ‰  s"   õúúýrg   c                 C   sr   t | ƒ} z
t | ¡d }W |S  ty/   zt | j¡d }W Y |S  ttfy.   Y Y dS w  ty8   Y dS w )aW  Find the line number in a file where an object was defined.

    This is essentially a robust wrapper around `inspect.getsourcelines`.

    Returns None if no file can be found.

    Parameters
    ----------
    obj : any Python object

    Returns
    -------
    lineno : int
        The line number where the object definition starts.
    r›   N)rƒ   r7   Úgetsourcelinesr„   r…   r†   )r(   Úlinenor,   r,   r-   Úfind_source_lines¬  s   
÷ûÿÿr§   c                       s”  e Zd Zejddd�jdd�Zeej	ddddf‡ fdd„	Z
d;d
eedf fdd„Zd
efdd„Zdd„ Zdd„ Zd;dd„Zed<dd„ƒZd;dd„Zd;dd„Zd=ded
efdd„Zded
efdd „Zded!ed"ed#ee fd$d%„Zd
efd&d'„Z						(d>d)ed*ed+ee  d,e!d#eee e"d( f d
efd-d.„Z#							(d?d+ee  fd/d0„Z$d@d1d2„Z%d@d
e&fd3d4„Z'e(d5d6„ ƒZ)g d7d7fd7d8œd9d:„Z*‡  Z+S )Ar   TzKdictionary of mime to callable to add information into help mimebundle dict)ÚconfigÚhelp)r¨   Nr   c                    sJ   t t| ƒj||d� || _tjd| |d�| _| jj| _|| _|  	|¡ d S )N)r'   r¨   r4   )Úoutr'   Ústyle)
Úsuperr   Ú__init__Úcolor_tabler   ÚParserÚparserÚformatÚstr_detail_levelÚset_active_scheme)r*   r®   Zcode_color_tableÚschemer²   r'   r¨   ©r…   r,   r-   r­   Ò  s   	
zInspector.__init__ry   r^   c                 C   s*   t |ƒsdS ztt|ƒ|ƒW S    Y dS )zœReturn the call signature for any callable object.

        If any exception is generated, None is returned instead and the
        exception is suppressed.N)ÚcallableÚ_render_signaturer   )r*   r(   r‡   r,   r,   r-   Ú_getdefâ  s   zInspector._getdefc                 C   s   d| j jj|| j jjf S )z*Return a header string with proper colors.z%s%s%s)r®   Zactive_colorsÚheaderÚnormal)r*   Úhr,   r,   r-   Z__headî  s   ÿzInspector.__headc                 C   s*   |d ur| j  |¡ | jj  |¡ d S d S r_   )r®   r³   r°   )r*   r´   r,   r,   r-   r³   ó  s   þzInspector.set_active_schemec                 C   s.   t d| dd� |rt d| ƒ dS t ƒ  dS )z-Generic message when no information is found.zNo %s foundú ©Úendzfor %sN)Úprint)r*   Úmsgr‡   r,   r,   r-   Únoinfoø  s   
zInspector.noinfoc                 C   sh   t |ƒs
tdƒ dS d}t |¡r|  d¡}|  ||¡}|du r(|  d|¡ dS t||  |¡dd� dS )zwPrint the call signature for any callable object.

        If the object is a class, print the constructor information.zObject is not callable.Nry   zClass constructor information:
zdefinition headerr¼   r½   )r¶   r¿   r7   rK   Ú_Inspector__headr¸   rÁ   r±   )r*   r(   r‡   r¹   Úoutputr,   r,   r-   Úpdef   s   

zInspector.pdefc           	      C   sæ   | j }g }t|ƒ}|r||ƒ d|¡}|r#| |dƒ¡ | t|ƒ¡ t |¡rEt|dƒrEt|jƒ}|durD| |dƒ¡ | t|ƒ¡ nt|dƒr_t|j	ƒ}|r_| |dƒ¡ | t|ƒ¡ |si|  
d|¡ dS t d	 |¡¡ dS )
a¸  Print the docstring for any object.

        Optional:
        -formatter: a function to run the docstring through for specially
        formatted docstrings.

        Examples
        --------
        In [1]: class NoInit:
           ...:     pass

        In [2]: class NoDoc:
           ...:     def __init__(self):
           ...:         pass

        In [3]: %pdoc NoDoc
        No documentation found for NoDoc

        In [4]: %pdoc NoInit
        No documentation found for NoInit

        In [5]: obj = NoInit()

        In [6]: %pdoc obj
        No documentation found for obj

        In [5]: obj2 = NoDoc()

        In [6]: %pdoc obj2
        No documentation found for obj2
        z
plain/textzClass docstring:r­   NzInit docstring:r‘   zCall docstring:Zdocumentationr}   )rÂ   r8   r.   r   r   r7   rK   Úhasattrr­   r‘   rÁ   r   r€   )	r*   r(   r‡   Ú	formatterÚheadÚlinesrx   Úinit_dsÚcall_dsr,   r,   r-   Úpdoc  s,   "
€

zInspector.pdocc                 C   s\   t  ¡  zt||d�}W n ty   d}Y nw |du r$|  d|¡ dS t |  |¡¡ dS )z$Print the source code for an object.)r‡   NrD   )Ú	linecacheÚ
checkcacher‚   ru   rÁ   r   r±   )r*   r(   r‡   r‹   r,   r,   r-   ÚpsourceP  s   ÿzInspector.psourcec                 C   s–   t |ƒ}|du r|  d|¡ dS t|ƒ}|du rtdƒ dS | d¡r+td| ƒ dS tj |¡s9td| ƒ dS t |  	t
j|dd�¡|d	 ¡ dS )
z0Show the whole file where an object was defined.NrA   zCould not find file for objectre   z File %r is binary, not printing.z%File %r does not exist, not printing.F)Zskip_encoding_cookier›   )r§   rÁ   rg   r¿   rh   ri   rj   rk   r   r±   r   Zread_py_file)r*   r(   r‡   r¦   rp   r,   r,   r-   Úpfile_  s   
$zInspector.pfileÚtextc                 C   sX   |dt  |¡› d�dœ}|du r|S ||ƒ}t|tƒs$|d|› d�dœS t|fi |¤ŽS )aR  Return a mime bundle representation of the input text.

        - if `formatter` is None, the returned mime bundle has
           a ``text/plain`` field, with the input text.
           a ``text/html`` field with a ``<pre>`` tag containing the input text.

        - if ``formatter`` is not None, it must be a callable transforming the
          input text into a mime bundle. Default values for ``text/plain`` and
          ``text/html`` representations are the ones described above.

        Note:

        Formatters returning strings are supported but this behavior is deprecated.

        z<pre>z</pre>©ú
text/plainú	text/htmlN)ÚhtmlÚescaperv   Údict)r*   rÐ   rÆ   r—   Ú	formattedr,   r,   r-   Ú_mime_formatx  s   þ
zInspector._mime_formatÚbundlec           
      C   sB  t |d tƒs	J ‚|d D ]	}t |tƒsJ ‚qi }g }tdd„ |d D ƒƒ}|d D ])\}}| d¡}d|v r9dnd}| |  |d ¡› |t|ƒ d › |› |› �¡ q*d |¡|d< d|v r�t |d tƒshJ ‚|d D ]	}t |tƒsuJ ‚qlt |d ttfƒr�d dd„ |d D ƒ¡|d< | 	¡ D ]}	|	d	v r˜q‘||	 ||	< q‘|S )
zRFormat a mimebundle being created by _make_info_unformatted into a real mimebundlerÒ   c                 s   s   � | ]	\}}t |ƒV  qd S r_   ©Úlen)r9   r»   Ú_r,   r,   r-   Ú	<genexpr>£  ó   € z(Inspector.format_mime.<locals>.<genexpr>r}   r¼   ú:rÓ   c                 s   s$   � | ]\}}d |› d|› �V  qdS )z<h1>z</h1>
Nr,   )r9   rÇ   Úbodyr,   r,   r-   rÝ   ¶  s   €" )rÓ   rÒ   )
rv   r]   ÚtupleÚmaxÚstripr   rÂ   rÛ   r€   Úkeys)
r*   rÙ   ÚitemZnew_brÈ   Ú_lenrÇ   rà   Údelimr`   r,   r,   r-   Úformat_mimeš  s4   
(ÿÿzInspector.format_mimeÚtitleÚkeyrZ   c           	      C   sd   ||v s||v r
dS || }|dur0|   ||¡}|d  ||d f¡ |d  ||d f¡ dS dS )z^Append an info value to the unformatted mimebundle being constructed by _make_info_unformattedNrÒ   rÓ   )rØ   r   )	r*   rÙ   ré   rê   rW   rZ   rÆ   r+   Zformatted_fieldr,   r,   r-   Ú_append_info_fieldÀ  s   
ýzInspector._append_info_fieldc           	         sä  g g dœ}	d-dt dtdtf‡ ‡‡fdd„}dtf‡fd	d
„}ˆ d r+||ddƒ |S ˆ d rJ|dkr;||dd|ƒ n||dd|ƒ ||ddƒ |S ˆ d sRt|ƒr’||dd|ƒ ||dd|ƒ ||dd|ƒ |dkrwˆ d rw||dd|ƒ n||dd|ƒ ||ddƒ ||ddƒ ||dd ƒ |S ||dd|ƒ ||d!d"|ƒ ||ddƒ ||d#dƒ ˆ d$ d%kr¸||d&d$ƒ ||d'd(ƒ ||ddƒ |dkrÔˆ d rÔ||dd|ƒ n||dd|ƒ ||d)d*|ƒ ||dd|ƒ ||d+d,|ƒ |S ).z;Assemble the mimebundle as unformatted lists of informationrÑ   NrÙ   ré   rê   c                    s   ˆj | ||ˆ ˆ|d� d S )N)ré   rê   rW   rZ   rÆ   )rë   )rÙ   ré   rê   rÆ   ©rW   rZ   r*   r,   r-   Úappend_fieldÜ  s   
úz6Inspector._make_info_unformatted.<locals>.append_fieldr^   c                    s   ˆ   | ¡t| ƒdœS )NrÑ   )r±   r6   )rÐ   )r*   r,   r-   Úcode_formatterè  s   þz8Inspector._make_info_unformatted.<locals>.code_formatterr$   ÚReprr?   r#   r   ZSourcerD   Z	DocstringrC   ÚFilerA   rK   Ú	SignaturerB   zInit signaturerE   zInit docstringrG   ÚTyper=   Z
SubclassesrJ   zCall signaturerH   zString formr&   ÚInteractiveÚ	NamespaceZLengthr@   zClass docstringrF   zCall docstringrI   r_   )r    r4   r!   r�   )	r*   r(   rW   rÆ   rY   rZ   rÙ   rí   rî   r,   rì   r-   Ú_make_info_unformattedÒ  s^   þÿÿÿÿ/Ó(Úêz Inspector._make_info_unformattedr,   r(   r‡   rW   rY   c                 C   s¾   | j ||||d�}t|ƒ}| j|||||d�}| jrZt|||||d�}	| j ¡ D ]1\}
}dd„ t |¡j 	¡ D ƒ}t
|ƒdkrD||	ƒ}ntjdtdd	� |||ƒ}|d
urY|||
< q(|  |¡S )a4  Retrieve an info dict and format it.

        Parameters
        ----------
        obj : any
            Object to inspect and return info from
        oname : str (default: ''):
            Name of the variable pointing to `obj`.
        formatter : callable
        info
            already computed information
        detail_level : integer
            Granularity of detail level, if set to 1, give more information.
        omit_sections : list[str]
            Titles or keys to omit from output (can be set, tuple, etc., anything supporting `in`)
        ©r‡   rW   rY   )rY   rZ   )r(   rW   rX   rY   rZ   c                 S   s   g | ]}|j tjj kr|‘qS r,   )Údefaultr7   Ú	Parameter)r9   Z	parameterr,   r,   r-   Ú
<listcomp>N  s
    þz'Inspector._get_info.<locals>.<listcomp>r›   zÇMIME hook format changed in IPython 8.22; hooks should now accept a single parameter (InspectorHookData); support for hooks requiring two-parameters (obj and info) will be removed in a future versionrM   rN   N)rW   r]   rõ   Ú
mime_hooksrV   Úitemsr7   r   Ú
parametersÚvaluesrÛ   rP   rQ   rR   rè   )r*   r(   r‡   rÆ   rW   rY   rZ   rX   rÙ   Ú	hook_datarê   ÚhookZrequired_parametersÚresr,   r,   r-   Ú	_get_info!  sB   ûûþ
û
€
zInspector._get_infoc           	      C   s:   |dusJ ‚| j ||||||d�}|s|d= t |¡ dS )a   Show detailed information about an object.

        Optional arguments:

        - oname: name of the variable pointing to the object.

        - formatter: callable (optional)
              A special formatter for docstrings.

              The formatter is a callable that takes a string as an input
              and returns either a formatted string or a mime type bundle
              in the form of a dictionary.

              Although the support of custom formatter returning a string
              instead of a mime type bundle is deprecated.

        - info: a structure with some information fields which may have been
          precomputed already.

        - detail_level: if set to 1, more information is given.

        - omit_sections: set of section keys and titles to omit
        N)rZ   rÓ   )r  r   )	r*   r(   r‡   rÆ   rW   rY   Zenable_html_pagerrZ   Zinfo_br,   r,   r-   Úpinfob  s   !ÿzInspector.pinfoc                 C   s"   t jdtdd� | j||||d�S )z’
        Inspector.info() was likely improperly marked as deprecated
        while only a parameter was deprecated. We "un-deprecate" it.
        z±The `Inspector.info()` method has been un-deprecated as of 8.0 and the `formatter=` keyword removed. `Inspector._info` is now an alias, and you can just call `.info()` directly.rM   rN   rö   )rP   rQ   rR   rW   )r*   r(   r‡   rW   rY   r,   r,   r-   Ú_info‹  s   ûzInspector._infoc               	   C   s,  |du rd}d}d}n	|j }|j}|j}| d¡d }d}	d}
|r8|jdur8t|jtƒr8t|jtƒ}| |d¡}	t	t
i dd„ tD ƒ¥|d||dd	œ¥ƒ}|	rQ|	}n8|r|t|ƒskzd
|d  }W n)   dt|ƒ }Y ndt|ƒ }|jr{|d|j 7 }nt|ƒ}|du r‡d}n|}|
| }d}t|d d ƒ}|ržd|d< n|r¥d|d< nt|ƒj|d< z|j}t|ƒ|d< W n   Y || jkrüz6t|ƒ}|sòt|ƒ|krò|d|… d || d…  }ddtd ¡ ƒ   dd„ | d¡D ƒ¡}||d< W n   Y |�r||d< z
tt|ƒƒ|d< W n
 t�y   Y nw d}t|ƒ}|du �r&d}n| d¡�r/d}n| d ¡�r7d!}t|ƒ|d"< |�rlt ¡  zt|tƒ�sN|�s`t ||ƒ}|du�r\| !¡ }||d#< W n
 t�yk   Y nw |�r}|  "| d#¡|¡�s}||d$< t# $|¡�rd|d%< z|  %||¡}W n t&�y›   d}Y nw z|j'}W n t&�y­   d}Y n$w |du �rÆz|  %||¡}W n
 t&�yÅ   Y nw t|ƒ}|t(k�rÑd}|�rØ||d&< |�rß||d'< d(d)„ t )|¡D ƒ}t|ƒd*k �röd+ |¡}nd+ |dd*… d,g ¡}||d-< |S |  %||¡}|�r||d.< |�r>zt|d/ƒ}W n   d}Y nt|ƒ}|t*v �r2d}|�r>||k�r>||d0< zt|j'ƒ}|t(k�rKd}W n t&�yX   d}Y nw |�r`||d'< t+|d1ƒ�r”t,|ƒ�s”|  %|j-|¡}|�r�|| d.¡k�r�||d2< t|j-ƒ}|t.k�r�d}|�r”||d3< |S )4as  Compute a dict with detailed information about an object.

        Parameters
        ----------
        obj : any
            An object to find information about
        oname : str (default: '')
            Name of the variable pointing to `obj`.
        info : (default: None)
            A struct (dict like with attr access) with some information fields
            which may have been precomputed already.
        detail_level : int (default:0)
            If set to 1, more information is given.

        Returns
        -------
        An object info dict with known fields from `info_fields` (see `InfoDict`).
        NFry   Ú.éÿÿÿÿc                 S   s   i | ]}|d “qS r_   r,   )r9   r+   r,   r,   r-   rb   Á  ó    z"Inspector.info.<locals>.<dictcomp>T)rL   r%   r$   r#   rJ   z!Alias to the system command:
  %sr›   zAlias: z	Alias to z
Docstring:
z<no docstring>éÈ   é   rM   zMagic functionr=   zSystem aliasr>   z <...> r}   r¼   r?   c                 s   s   � | ]}|  ¡ V  qd S r_   )rã   )r9   Úqr,   r,   r-   rÝ   û  s   € 
ÿz!Inspector.info.<locals>.<genexpr>r&   r@   re   z<string>z9Dynamically generated function. No source code available.rA   rD   rC   rK   rE   rG   c                 S   s   g | ]}|j ‘qS r,   )r/   )r9   Úsubr,   r,   r-   rù   N  r  z"Inspector.info.<locals>.<listcomp>é
   ú, z...rJ   rB   r…   rF   r‘   rH   rI   )/r#   r$   r&   Úsplitr'   rÅ   Ú	HOOK_NAMEr)   r.   r   r<   rS   r¶   r4   r[   r8   r\   Útyper/   r…   r²   rÛ   Ú
expandtabsr€   ru   rg   rh   r   rÌ   rÍ   rv   r~   r‚   ÚrstripÚ_source_contains_docstringr7   rK   r¸   rT   r­   Ú_object_init_docstringÚ__subclasses__Ú_builtin_type_docstringsr   r�   r‘   Ú_func_call_docstring) r*   r(   r‡   rW   rY   r#   r$   ZospaceZatt_nameZparents_docsZpreludeZparents_docs_dictrª   rx   Z
ds_or_NoneZ
string_maxZshalfZbclassZostrÚbinary_filer¤   r‹   Zinit_defZobj_initrÉ   ÚnamesZ	all_namesZdeflnÚclsZclass_dsrH   rÊ   r,   r,   r-   rW   š  s@  ÿûþþ€


ÿÿ


€ÿÿ
ÿ
ÿ
2Ò


€ÿ

zInspector.infoc                 C   s8   zt  t| ƒ¡j\}t  |¡|kW S  ty   Y dS w )zâ
        Check whether the source *src* contains the docstring *doc*.

        This is is helper function to skip displaying the docstring if the
        source already contains it, avoiding repetition of information.
        F)ÚastÚparser   rà   Úget_docstringru   )r‹   rž   Zdef_noder,   r,   r-   r  ‡  s   üz$Inspector._source_contains_docstringF)Ú
list_typesc                C   sú   d}d}|rt   d ttƒ¡¡ dS | ¡ }	t|	ƒ}
|
dkr#|	d }n|
dkr,|	\}}ntd| ƒ‚|D ]}||vrDtd	|| ¡ f ƒ‚q4tƒ tƒ }}|D ]"}|| }t	|ƒ|v r[qN| 
t	|ƒ¡ t|||||d
�}| |¡ qNt   d t|ƒ¡¡ dS )a¢  Search namespaces with wildcards for objects.

        Arguments:

        - pattern: string containing shell-like wildcards to use in namespace
          searches and optionally a type specification to narrow the search to
          objects of that type.

        - ns_table: dict of name->namespaces for search.

        Optional arguments:

          - ns_search: list of namespace names to include in search.

          - ignore_case(False): make the search case-insensitive.

          - show_all(False): show all names, including those starting with
            underscores.

          - list_types(False): list all available object types for object matching.
        Úallry   r}   Nr›   r   rM   z)invalid argument string for psearch: <%s>z'invalid namespace <%s>. Valid names: %s)Úignore_caseÚshow_all)r   r€   Úsortedr   r  rÛ   Ú
ValueErrorrä   ÚsetÚidÚaddr   Úupdate)r*   ÚpatternZns_tableZ	ns_searchr  r   r  Ztype_patternÚfilterZcmdsZlen_cmdsrL   Zsearch_resultZnamespaces_seenZns_nameÚnsZtmp_resr,   r,   r-   Úpsearch˜  s>   

ÿ
ÿÿÿzInspector.psearch©ry   )ry   Nr_   )ry   NNr   r,   )ry   NNr   Tr,   )ry   Nr   ),r/   r0   r1   Ú	traitletsr
   Útagrú   r   r   ÚANSICodeColorsr­   r   r4   r¸   rÂ   r³   rÁ   rÄ   r   rË   rÎ   rÏ   rÖ   rØ   r    r!   rè   r   rë   rõ   r   r	   r"   r\   r   r  r  r  r<   rW   Ústaticmethodr  r*  Ú__classcell__r,   r,   rµ   r-   r   Ë  s”    þýù

9
"&þýü
ú
þRùþýûúù
øDø
û
) n
ÿÿc                 C   s
  g }d}d}| j  ¡ D ]6}|jtjjkrd}n	|r | d¡ d}|jtjjkr*d}n|jtjjkr:|r:| d¡ d}| t	|ƒ¡ q|rI| d¡ t
|ƒtdd„ |D ƒƒ dkrgd |d	 d
d„ |D ƒ¡¡}n	d |d |¡¡}| jtjurƒt | j¡}|d |¡7 }|S )z¢
    This was mostly taken from inspect.Signature.__str__.
    Look there for the comments.
    The only change is to add linebreaks when this gets too long.
    FTú/Ú*c                 s   s   � | ]	}t |ƒd  V  qdS )rM   NrÚ   ©r9   Úrr,   r,   r-   rÝ   ÷  rÞ   z$_render_signature.<locals>.<genexpr>éK   z{}(
{})ry   c                 s   s   � | ]}d   |¡V  qdS )z    {},
N)r±   r3  r,   r,   r-   rÝ   ù  s   € 

ÿz{}({})r  z -> {})rü   rý   Úkindr7   rø   ÚPOSITIONAL_ONLYr   ÚVAR_POSITIONALÚKEYWORD_ONLYr4   rÛ   Úsumr±   r€   Úreturn_annotationÚ_emptyÚformatannotation)Zobj_signatureÚobj_nameÚresultZpos_onlyÚkw_onlyÚparamÚrenderedÚannor,   r,   r-   r·   Û  s4   


ÿr·   r+  )T)fr[   Ú__all__Údataclassesr   r7   r   Útextwrapr   r  rÔ   Úiorl   rÌ   ri   ÚtypesrP   Útypingr   r   r	   r
   r   r   r   r   r   r,  ZIPython.corer   ZIPython.lib.prettyr   ZIPython.testing.skipdoctestr   ZIPython.utilsr   r   ZIPython.utils.dir2r   ZIPython.utils.pathr   ZIPython.utils.textr   ZIPython.utils.wildcardr   r   ZIPython.utils.coloransir   ZIPython.utils.colorabler   ZIPython.utils.decoratorsr   Úpygmentsr   Zpygments.lexersr   Zpygments.formattersr   r  r4   r    r3   r!   r"   r6   ÚFunctionTyper‘   r  Úobjectr­   r  Ú
ModuleTypeÚ
MethodTyper~   r  r  r  r�   ÚupperrŽ   ZColorsr.  r   r<   r]   rä   rS   rU   rV   r2   rd   rt   r8   r‚   r�   r“   rš   rŸ   rƒ   rg   r§   r   r·   r,   r,   r,   r-   Ú<module>   s²    , 
ÿÿ

úþýüûúø?

%#      