
    XhX                     $   U d Z 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 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$ 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/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             Z>d Z?ej                  j                  j                   ZBeCj                  j                   ZEej                  ej                  ej                  eHfD  ch c]  }  ej                  |        c} ZJ eKeL      ZM eKe:j                        ZO G d de      ZP eQePjx                  j                               ZSd ZTe G d d              ZUe2d!d!d!d"d#e:d$eVd%eVd&eVd'eVd(ePfd)       ZWd* ZXd(ee:df   fd+ZId3d(ee:df   fd,ZYd- ZZd. Z[d(ee:   fd/Z\d0 Z] eC       Z^ G d1 de      Z_d(e:fd2Z`yc c} w )4zTools 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    )	dataclass)	signature)dedentN)Token)	castAnyOptionalDictUnionList	TypedDict	TypeAliasTuple)Configurable)page)pretty)skip_doctest)
PyColorizeopenpy)safe_hasattr)compress_user)indent)list_namespacetypestr2type)undoc)	highlight)PythonLexer)HtmlFormatter__custom_documentations__UnformattedBundleBundlec                   V    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 Zy)	OInfoismagicisaliasfound	namespaceparentobjc                 Z    t        j                  d| dt        d       t        | |      S )zGet a field from the object for backward compatibility with before 8.12

        see https://github.com/h5py/h5py/issues/2253
        zGOInfo dataclass with fields access since IPython 8.12 please use OInfo.z instead.OInfo used to be a dict but a dataclass provide static fields verification with mypy.This warning and backward compatibility `get()` method were added in 8.13.   
stacklevel)warningswarnDeprecationWarninggetattr)selffields     I/var/www/html/myenv/lib/python3.12/site-packages/IPython/core/oinspect.pygetz	OInfo.getK   s=     	UV[U\ ]Y Y 	
 tU##    N)	__name__
__module____qualname__bool__annotations__r
   strr	   r6    r7   r5   r$   r$   B   s*    MMK}K	H$r7   r$   c                 @    t        | t               t        d            S )NT)	noclasses)r   r   r   )codes    r5   pylightrB   ]   s    T;=-$*GHHr7   c                   0   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<   y)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)r8   r9   r:   r
   r=   r<   r;   r>   r7   r5   rD   rD   r   s    }#}SM
3-}SMc]"c]"SM!smSM! MMMK
Ir7   rD   c                 z    | dk(  r"t        j                  dt        d       t        S t	        dt
        d|       )Ninfo_fieldszfIPython.core.oinspect's `info_fields` is considered for deprecation and may be removed in the Future. r,   r-   zmodule z has no attribute )r/   r0   r1   _info_fieldsAttributeErrorr8   )rT   s    r5   __getattr__rY      s@    }t	

 
78,.@I
JJr7   c                   P    e Zd ZU dZeed<   ee   ed<   eed<   e	ed<   e
e   ed<   y)InspectorHookDatazData passed to the mime hookr*   info	info_dictdetail_levelomit_sectionsN)r8   r9   r:   __doc__r	   r<   r
   r$   rD   intlistr=   r>   r7   r5   r[   r[      s*    &	H
5/9r7   r[   F)rS   r&   r%   rT   r'   rS   r&   r%   returnc                     t        |      }|j                  t        D ci c]
  }||vs|d c}       | |d<   ||d<   ||d<   ||d<   ||d<   t        di |S c c}w )z1Make an object info dict with all fields present.NrT   r'   rS   r&   r%   r>   )dictupdaterW   rD   )rT   r'   rS   r&   r%   kwinfodictks           r5   object_inforj      su     BxHOOlHax6GQWHIHVHW!HY!HY!HYh Is
   	AAc                 "   t        |       }|y|j                  d      ryt        j                  j	                  |      syt        j                  |d      5 }t        j                  |j                        \  }}ddd       |S # 1 sw Y   S xY w)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_liness        r5   get_encodingr{      s    
 cNE }	/	0WW^^E"
 ^^E4( 	GF%55fooFHf	G	Gs   #BBc                     	 | j                         }t        |t              rt        j                  |      S t        j                   |       }|S # t
        $ r Y "w xY w)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.
    )getdoc
isinstancer=   inspectcleandoc	Exception)r*   dsdocstrs      r5   r}   r}      sV    (ZZ\ b###B''^^C FM  s   A 	AAc           	      x   t        | t              rg }dD ]  }t        | |      }||rd|z  nd}|j                  dj	                  d||f             t        j                  |      r)t        |      }|sa|j                  t        |             ||j                  ||dt        |      d        |rdj	                  |      S yt        |       } 	 t        j                  |       }|S # t        $ r: 	 t        j                  | j                        }Y |S # t        t        f$ r Y Y yw xY wt        $ r Y yw xY 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. z# z = 
)r~   propertyr2   appendjoinr   
isfunction	getsourcer   r   _get_wrapped	TypeError	__class__OSError)r*   onamesourcesattrnamefnoname_prefix_srcsrcs           r5   r   r      s6   & #x 0 	Hh'B~27RrwwlH'EFG%%b)$R=Dvd|4 NN)5xL	  99W%%
 3
	##C(C 
  	''6 
 Y'  		s0   C, ,	D96DD+'D9*D++D98D9c                     t        j                  |       xs9 t        j                  |       xs" t        | t              xs t        | t
              S )zTrue if obj is a function ())r   r   ismethodr~   _builtin_func_type_builtin_meth_type)r*   s    r5   is_simple_callabler   &  sK    s# Ww'7'7'< Ws./W3=cCU3VXr7   c                 p    | }d}t        | d      r%| j                  } |dz  }|dkD  r|S t        | d      r%| 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__   d   )r   r   )r*   orig_objis      r5   r   r   +  sI     H	A
sM
*oo	Qs7O sM
* Jr7   c                     t        |       } d}	 t        j                  |       }|S # t        $ r; 	 t        j                  | j                        }Y |S # t
        t        f$ r Y Y |S w xY wt
        $ r Y |S w xY 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   r   
getabsfiler   r   r   )r*   fnames     r5   rn   rn   =  s      s
CE""3' L  	&&s}}5E L # 	 L	  Ls,   & 	A5AA&!A5%A&&A54A5c                     t        |       } 	 t        j                  |       d   }|S # t        $ r= 	 t        j                  | j                        d   }Y |S # t
        t        f$ r Y Y yw xY wt
        $ r Y yw xY 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   r   getsourcelinesr   r   r   )r*   linenos     r5   find_source_linesr   `  s      s
C	'',Q/ M  	++CMM:1=F M # 		 s,   ' 	A7"AA)%A7(A))A76A7c                       e Zd ZU  ej                  dd      j                  d      Zeed<   ddddd	ef fd
Z	d Z
d.deedf   fdZdedefdZdefdZdefdZd Zd.dZed/d       Zd.dZd.dZd0dedefdZdedefdZdedededee   fd Zdefd!Z	 	 	 	 	 d1d#ed$ed%ee    d&e!deee   e"d"   f   defd'Z#	 	 	 	 	 	 d2d%ee    fd(Z$d3de%fd)Z&e'd*        Z(g d+d+fd+d,d-Z) xZ*S )4r   TzKdictionary of mime to callable to add information into help mimebundle dict)confighelp)r   _theme_namer   N)str_detail_levelr)   r   
theme_namec                *   |dv r>t        j                  d|j                          dt        d       |j                         }|| _        t
        t        |   ||       t        j                  d|      | _
        || _        | j                  |       y )	N)LinuxLightBGNeutralNoColorz?Theme names and color schemes are lowercase in IPython 9.0 use z insteadr,   r-   )r)   r   r=   )outr   )r/   r0   lowerr1   r   superr   __init__r   Parserparserr   set_theme_name)r3   r   r   r)   r   r   s        r5   r   zInspector.__init__  s     CCMMQR\RbRbRdQeemn"
 $))+J%i'vf'E ''EjI 0J'r7   c                 :     | j                   j                  |i |S N)r   format)r3   argskwargss      r5   r   zInspector.format  s    !t{{!!42622r7   rc   c                 T    t        |      sy	 t        t        |      |      S #  Y yxY w)zReturn 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   )r3   r*   r   s      r5   _getdefzInspector._getdef  s.    
 }	$Ys^U;;	s   # 'hc                 |    t         j                  | j                     j                  t        j
                  |fg      S )z*Return a header string with proper colors.)r   theme_tabler   r   r   Header)r3   r   s     r5   __headzInspector.__head  s0    %%d&6&67>>q@Q?RSSr7   rT   c                     ||j                         k(  sJ |t        j                  j                         v sJ || _        || j
                  _        y r   )r   r   r   keysr   r   r   )r3   rT   s     r5   r   zInspector.set_theme_name  sG    tzz|###z--224444!%r7   schemec                     t        j                  dt        d       ||j                         k(  sJ |)| j                  |k7  r|| _        || j
                  _        y y y )NzPset_active_scheme is deprecated and replaced by set_theme_name as of IPython 9.0r,   r-   )r/   r0   r1   r   r   r   r   )r3   r   s     r5   set_active_schemezInspector.set_active_scheme  s\    ^	

 '''$"2"2f"<%D%+DKK" #=r7   c                 Z    t        d|z  d       |rt        d|z         yt                y)z-Generic message when no information is found.zNo %s found endzfor %sN)print)r3   msgr   s      r5   noinfozInspector.noinfo  s&    mc!s+(U"#Gr7   c                 
   t        |      st        d       yd}t        j                  |      r| j	                  d      }| j                  ||      }|| j                  d|       yt        || j                  |      d       y)zwPrint the call signature for any callable object.

        If the object is a class, print the constructor information.zObject is not callable.Nr   zClass constructor information:
zdefinition headerr   r   )r   r   r   rS   _Inspector__headr   r   r   )r3   r*   r   headeroutputs        r5   pdefzInspector.pdef  sr    
 }+,??3[[!CDF c%(>KK+E2&V,#6r7   c                    g }t        |      }|r ||      j                  d|      }|r:|j                  | j                  d             |j                  t	        |             t        j                  |      r^t        |d      rRt        |j                        }||j                  | j                  d             |j                  t	        |             n]t        |d      rQt        |j                        }|r:|j                  | j                  d             |j                  t	        |             |s| j                  d|       yt        j                  d	j                  |             y)
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:__call__zCall docstring:documentationr   )r}   r6   r   r   r   r   rS   hasattrr   r   r   r   r   )r3   r*   r   	formatterlinesr   init_dscall_dss           r5   pdoczInspector.pdoc  s   D C[2""<4BLL%789LL$??3GC$<S\\*G"T[[):;<VG_-S$S\\*GT[[):;<VG_-KK.IIdii&'r7   c                     t        j                          	 t        ||      }|| j	                  d|       yt        j
                  | j                  |             y# t        $ r d}Y Gw xY w)z$Print the source code for an object.)r   NrL   )	linecache
checkcacher   r   r   r   r   )r3   r*   r   r   s       r5   psourcezInspector.psource  sa     		Cu-C ;KK%(IIdkk#&'  	C	s   A A+*A+c                    t        |      }|| j                  d|       yt        |      }|t        d       y|j	                  d      rt        d|z         yt
        j                  j                  |      st        d|z         yt        j                  | j                  t        j                  |d            |d	z
         y)
z0Show the whole file where an object was defined.NrI   zCould not find file for objectrl   z File %r is binary, not printing.z%File %r does not exist, not printing.F)skip_encoding_cookier   )r   r   rn   r   ro   rp   rq   rr   r   r   r   read_py_file)r3   r*   r   r   rw   s        r5   pfilezInspector.pfile+  s     #3'>KK&# =23^^344u<=&9EAB
 IIdkk&"5"5eRW"XY[ade[efr7   textc                     |dt        j                  |       dd}||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/html)htmlescaper~   re   )r3   r   r   defaults	formatteds        r5   _mime_formatzInspector._mime_formatD  sm    "  T!2 36:

 O!$Ii. '0i[PV>WXX H2	22r7   bundlec                    t        |d   t              sJ |d   D ]  }t        |t              rJ  i }g }t        d |d   D              }|d   D ]X  \  }}|j	                  d      }d|v rdnd}|j                  | j                  |dz          |t        |      z
  dz   | |        Z dj                  |      |d<   d|v rht        |d   t              sJ |d   D ]  }t        |t              rJ  t        |d   t        t        f      rdj                  d |d   D              |d<   |j                         D ]  }	|	dv r||	   ||	<    |S )	zRFormat a mimebundle being created by _make_info_unformatted into a real mimebundler   c              3   8   K   | ]  \  }}t        |        y wr   len).0r   _s      r5   	<genexpr>z(Inspector.format_mime.<locals>.<genexpr>o  s     ;da3q6;   r   r   :r   c              3   2   K   | ]  \  }}d | d|   yw)z<h1>z</h1>
Nr>   )r   headbodys      r5   r   z(Inspector.format_mime.<locals>.<genexpr>  s&      /3?D$d4&v./s   )r   r   )
r~   rb   tuplemaxstripr   r   r   r   r   )
r3   r   itemnew_br   _lenr  r  delimri   s
             r5   format_mimezInspector.format_mimef  s    &.555<( 	+DdE***	+ ;f\&:;; . 	JD$::d#D DLDcELL;;tCx()4#d)+;S*@)A%O	 #ii.l& f[14888{+ /!$.../ &-e}=%)YY /CI+CV/ &k"  	%A//!!9a		%
 r7   titlekeyr_   c                     ||v s||v ry||   }|E| j                  ||      }|d   j                  ||d   f       |d   j                  ||d   f       yy)z^Append an info value to the unformatted mimebundle being constructed by _make_info_unformattedNr   r   )r   r   )	r3   r   r  r  r\   r_   r   r4   formatted_fields	            r5   _append_info_fieldzInspector._append_info_field  sv     M!SM%9S	"//yAO< ''0M(NO;&&{/K'LM r7   c                     g g d}	 d*dt         dt        dt        f fd}dt        f fd}d   r ||d	d
       |S d   r(|dkD  r ||dd|       n ||dd|        ||dd       |S d   st        |      rb ||dd|        ||dd|        ||dd|       |dkD  rd   r ||dd|       n ||dd|        ||dd        ||dd        ||dd       |S  ||dd|        ||dd|        ||dd        ||d d
       d!   d"k7  r
 ||d#d!        ||d$d%        ||dd       |dkD  rd   r ||dd|       n ||dd|        ||d&d'|        ||dd|        ||d(d)|       |S )+z;Assemble the mimebundle as unformatted lists of informationr   r   r  r  c                 4    j                  | |||       y )N)r  r  r\   r_   r   )r  )r   r  r  r   r\   r_   r3   s       r5   append_fieldz6Inspector._make_info_unformatted.<locals>.append_field  s*     ##+# $ r7   rc   c                 >    j                  |       t        |       dS )Nr   )r   rB   )r   r3   s    r5   code_formatterz8Inspector._make_info_unformatted.<locals>.code_formatter  s     "kk$/$T] r7   r&   ReprrG   r%   r   SourcerL   	DocstringrK   FilerI   rS   	SignaturerJ   zInit signaturerM   zInit docstringrO   TyperE   
SubclassesrR   zCall signaturerP   zString formr(   Interactive	NamespaceLengthrH   zClass docstringrN   zCall docstringrQ   r   )r!   r=   r"   r   )	r3   r*   r\   r   r^   r_   r   r  r  s	   ` `  `   r5   _make_info_unformattedz Inspector._make_info_unformatted  s   
 %
 HL
	%
	.1
	8;
		F 	 	?7^ [ )_aVXxHV[+yI0P M )_ 23 7lNK!13DnUk9EaDNVXxHV%57GS05|<4 - lNK!1:~N5> K M1V[+>840 aDNVXxHV[+yI!24EyQ!13CYO!13CYOr7   r>   r*   r   r\   r^   c                 `   | j                  ||||      }t        |      }| j                  |||||      }| j                  rt	        |||||      }	| j                  j                         D ]  \  }
}t        j                  |      j                  j                         D cg c]+  }|j                  t        j                  j                  k7  r|- }}t        |      dk(  r	 ||	      }n%t        j                  dt        d        |||      }||||
<    | j!                  |      S c c}w )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   r\   r^   )r^   r_   )r*   r\   r]   r^   r_   r   zMIME 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 versionr,   r-   )r\   rb   r!  
mime_hooksr[   itemsr   r   
parametersvaluesdefault	Parameterr   r/   r0   r1   r  )r3   r*   r   r   r\   r^   r_   r]   r   	hook_datar  hook	parameterrequired_parametersress                  r5   	_get_infozInspector._get_info  sF   4 IIcTIU	]+,,%' - 
 ??)#)+I "__224 &	T &-%6%6t%<%G%G%N%N%P'! ((G,=,=,E,EE '# '
 *+q0y/CMM] +#$ sD/C?"%F3K%&& ''%'s   "0D+c                 n    |J | j                  ||||||      }|s|d= t        j                  |       y)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)r_   r   )r.  r   )	r3   r*   r   r   r\   r^   enable_html_pagerr_   info_bs	            r5   pinfozInspector.pinfo.  sJ    B 	4] ( 
 !{#		&r7   c           
      
   |d}d}d}n$|j                   }|j                  }|j                  }|j                  d      d   }d}	d}
|rR|j                  Ft        |j                  t              r,t        |j                  t              }|j                  |d      }	t        t        i t        D ci c]  }|d c}|d||dd      }|	r|	}nV|rBt        |      s
	 d|d	   z  }n?dt        |      z   }|j                  r%|d|j                  z   z  }nt        |      }|d}n|}|
|z   }d}t!        |dz
  dz        }|rd|d<   n |rd|d<   nt#        |      j$                  |d<   	 |j&                  }t        |      |d<   || j(                  k\  rt	 t        |      }|sat+        |      |kD  rS|d| dz   || d z   }ddt+        dj-                               z  z   j/                  d |j                  d      D              }||d<   |r||d<   	 t        t+        |            |d<   d}t3        |      }|d}n5|j5                  d      rd}n|j5                  d      rd}t7        |      |d<   |rJt9        j:                          	 t=        |t>              s|s#tA        ||      }||jC                         }||d <   |r&| jE                  |j                  d       |      s||d!<   tG        jH                  |      rd|d"<   	 | jK                  ||      }	 |jN                  }|	 | jK                  ||      }t        |      }|tP        k(  rd}	 |r||d#<   |r||d$<   t"        jS                  |      D cg c]  }|j$                   }}t+        |      d%k  rd&j/                  |      }nd&j/                  |dd% d'gz         }||d(<   |S | jK                  ||      }|r||d)<   |r.	 t        |d*      }t        |      }|tT        v rd}|r
||k7  r||d+<   	 t        |jN                        }|tP        k(  rd}|r||d$<   tW        |d,      ritY        |      s^| jK                  |jZ                  |      } | r| |j                  d)      k7  r| |d-<   t        |jZ                        }!|!t\        k(  rd}!|!r|!|d.<   |S c c}w #  d
t        |      z   }Y xY w#  Y DxY w#  Y xY w# t0        $ r Y w xY w# t0        $ r Y 6w xY w# tL        $ r d}Y w xY w# tL        $ r Y w xY w# tL        $ r d}Y w xY wc c}w #  d}Y @xY w# tL        $ r d}Y w xY w)/as  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`).
        NFr   .T)rT   r'   r&   r%   rR   z!Alias to the system command:
  %sr   zAlias: z	Alias to z
Docstring:
z<no docstring>      r,   zMagic functionrE   zSystem aliasrF   z <...> r   r   rG   c              3   <   K   | ]  }|j                           y wr   )r  )r   qs     r5   r   z!Inspector.info.<locals>.<genexpr>  s      O&'	Os   r(   rH   rl   z<string>z9Dynamically generated function. No source code available.rI   rL   rK   rS   rM   rO   
   , z...rR   rJ   r   rN   r   rP   rQ   )/r%   r&   r(   splitr)   r   	HOOK_NAMEr2   r6   r   rD   rW   r   r=   r`   r}   ra   typer8   r   r   r   
expandtabsr   r   rn   ro   r   r   r   r~   r   r   rstrip_source_contains_docstringr   rS   r   rX   r   _object_init_docstring__subclasses___builtin_type_docstringsr   r   r   _func_call_docstring)"r3   r*   r   r\   r^   r%   r&   ospaceatt_nameparents_docspreludeparents_docs_dictr4   r   r   
ds_or_None
string_maxshalfbclassostrbinary_filer   r   init_defobj_initr   subnames	all_namesdeflnclsclass_dsrP   r   s"                                     r5   r\   zInspector.infoW  s   ( <GGFllGllG^^F ;;s#B'DKK+Y0O 'Y ?,004@L	,8955$;9	 "!&&"&	
 BC=.=AFB !3s8+;;*S[[88BJ!%r\ 
Z!^q()/C-C#Cy11C	]]F #FC
 40003x#D	J(><)3dE67mCD !3]-E-E-G)H#HHNN O+/::d+;O D &*M" %C	CMCM
 #= K~~56"
+S'.CK    "c8,K#C/C!jjl$'CM d55cggh6GL!C ??3!C	N <<U3
#<< ##'<<%#@ !*44"G)1%&(/$%-1-@-@-EFcS\\FEF5zB IIe,	 IIeCRj%&89	 )Cd 
] LLe,E$)L! +!#k2C  &c{H77#Hh-5C)* .44"G (/$% C,5G5L<<e<SWW\-B!B '/C
O .22"G,3C()
I :"."SX-B:	  		:   "    *  " * G($#H " s   -
R!R& #R< A3S S =5S 5S, T S> %T T%  T/ &R9<SS		SS	S)(S),S;:S;>	T
TTT%T,/T>=T>c                     	 t        j                  t        |             j                  \  }t        j                  |      |k(  S # t
        $ r Y yw xY 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_docstringr   )r   docdef_nodes      r5   rA  z$Inspector._source_contains_docstringD  sK    	))F3K055KX$$X.#55 	 		s   AA 	AAF)
list_typesc                r   d}d}|r2t        j                   dj                  t        t                           y|j	                         }	t        |	      }
|
dk(  r|	d   }n|
dk(  r|	\  }}nt        d|z        |D ]%  }||vst        d	|d
|j                                t               t               }}|D ]P  }||   }t        |      |v r|j                  t        |             t        |||||      }|j                  |       R t        j                   dj                  t        |                   y)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.
        allr   r   Nr   r   r,   z)invalid argument string for psearch: <%s>zinvalid namespace <z>. Valid names: )ignore_caseshow_all)r   r   sortedr   r<  r   
ValueErrorr   setidaddr   rf   )r3   patternns_table	ns_searchrb  rc  r_  type_patternfiltercmdslen_cmdsrT   search_resultnamespaces_seenns_namenstmp_ress                    r5   psearchzInspector.psearchU  s<   4  IIdii| 456}}Yq=!WF]"&F<H$% & &  	9D8# "&x}}"8 9 9	9 *-  	*G'"B"v(2'$Rv0;hPG  )	* 			$))F=123r7   r   )r   Nr   )r   NNr   r>   )r   NNr   Tr>   )r   Nr   )+r8   r9   r:   	traitletsr   tagr#  r=   r<   r   r   r   r   r   r   r   r   r   r   r   r   r   re   r   r!   r"   r  r   r  r!  r	   r
   r$   ra   r   r.  r2  rD   r\   staticmethodrA  ru  __classcell__)r   s   @r5   r   r     s   Z 
cc 
  ( (*3
eCHo 
T T T&3 &	, 	,7, 6( 6(p(g2 3  3  3D$"3 $ $LN!N N 	N CyN$L	Ld  $57?(?( ?(
 uo?( ?( T#Yb	12?( 
?(H  $'
 uo'Rk kZ    13!5@4@E@4 @4r7   c                 h   g }d}d}| j                   j                         D ]  }|j                  t        j                  j
                  k(  rd}n|r|j                  d       d}|j                  t        j                  j                  k(  rd}n<|j                  t        j                  j                  k(  r|r|j                  d       d}|j                  t        |              |r|j                  d       t        |      t        d |D              z   dkD  r)dj                  |dj                  d	 |D                    }n!d
j                  |dj                  |            }| j                  t        j                  ur3t        j                   | j                        }|dj                  |      z  }|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              3   8   K   | ]  }t        |      d z     yw)r,   Nr   r   rs     r5   r   z$_render_signature.<locals>.<genexpr>  s     6!3q6A:6r   K   z{}(
{})r   c              3   >   K   | ]  }d j                  |        yw)z    {},
N)r   r  s     r5   r   z$_render_signature.<locals>.<genexpr>  s       73&'Kq!73s   z{}({})r;  z -> {})r%  r&  kindr   r(  POSITIONAL_ONLYr   VAR_POSITIONALKEYWORD_ONLYr=   r   sumr   r   return_annotation_emptyformatannotation)obj_signatureobj_nameresultpos_onlykw_onlyparamrenderedannos           r5   r   r     sn    FHG))002 "::**:::HMM#H::**999GZZ7,,999gMM#Gc%j!" c 8}s6v666;$$Xrww 73+173 03 
 ??8TYYv->?&&gnn<''(G(GHHOOD))Or7   rv  )ar`   __all__dataclassesr   r   r   textwrapr   rZ  r   iors   r   rp   typesr/   pygments.tokenr   typingr   r	   r
   r   r   r   r   r   r   rw  traitlets.configr   IPython.corer   IPython.lib.prettyr   IPython.testing.skipdoctestr   IPython.utilsr   r   IPython.utils.dir2r   IPython.utils.pathr   IPython.utils.textr   IPython.utils.wildcardr   r   IPython.utils.decoratorsr   pygmentsr   pygments.lexersr   pygments.formattersr   r=  r=   r!   r<   r"   r$   rB   FunctionTyper   rE  objectr   rB  
ModuleType
MethodTyper   r}   rD  r>  ra  r   upperr   rD   rb   r   rW   rY   r[   r;   rj   r{   r   r   r   rn   r   	_sentinelr   r   )ts   0r5   <module>r     sm   - "   
     	    
 
 
  )  % 4 , + , % ? *  ' -'	  $CeCHo)>$>? 9 ?cN	 " $ $ $4I ))22:: 00  % 0 0%2B2B % 2 2H >NGNN1 
 #Y #))_ y 2 H,,1134	K    
  
    	 
        *05d# *;c$h ;|X
$ hsm  F@ H	R4 R4j(# (k!s   ;H