
    f                        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ZddlmZmZmZmZmZmZ ej0                  d	k  rdd
lmZ n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" 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+ ddl*m,Z, ddl-m.Z.m/Z/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z: ddl;m<Z< dZ=ee>eee>e>f      f   Z?ee@d<   ee>e>f   ZAee@d<   e G d d              ZBd! ZCej                  j                  j                   ZFeGj                  j                   ZIej                  ej                  ej                  eLfD  ch c]  }  ej                  |        c} ZN eOeP      ZQ eOe>j                        ZSe.ZTe"j                  ZVg d"ZWd# ZXd$ ZYd%ee>df   fd&ZMd1d%ee>df   fd'ZZd( Z[e6d)        Z\e6d*        Z]e6d2d+       Z^d, Z_d%e>fd-Z`d. Za G d/ de4      Zbd%e>fd0Zcyc c} w )3zTools 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)AnyOptionalDictUnionListTuple)   
   )	TypeAlias)page)pretty)skip_doctest)
PyColorize)openpy)safe_hasattr)compress_user)indent)list_namespace)typestr2type)
TermColorsColorSchemeColorSchemeTable)cast_unicode)	Colorable)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                     t        | |      S )zGet a field from the object for backward compatibility with before 8.12

        see https://github.com/h5py/h5py/issues/2253
        )getattr)selffields     P/var/www/cvtools/html/venv/lib/python3.12/site-packages/IPython/core/oinspect.pygetz	OInfo.getH   s     tU##    N)	__name__
__module____qualname__bool__annotations__r	   strr   r4    r5   r3   r(   r(   ?   s*    MMK}K	H$r5   r(   c                 @    t        | t               t        d            S )NT)	noclasses)r!   r"   r#   )codes    r3   pylightr@   Y   s    T;=-$*GHHr5   )	type_name
base_classstring_formr,   lengthfile
definition	docstringsourceinit_definitionclass_docstringinit_docstringcall_defcall_docstringr)   r*   isclassr+   namec                  Z    t         D ci c]  }|d }}|j                  |        |S c c}w )z1Make an object info dict with all fields present.N)info_fieldsupdate)kwkinfodicts      r3   object_inforV   |   s/     +,1$,H,OOBO -s   
(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        r3   get_encodingrg      s    
 cNE }	/	0WW^^E"
 ^^E4( 	FF$44V__EOHe	F	Fs   #BBreturnc                     	 | 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      r3   rj   rj      sV    (ZZ\ b###B''^^C FM  s   A 	AAc           	         t        | t              rg }dD ]  }t        | |      }|t        |      }|rd|z  nd}|j	                  dj                  d||f             t        j                  |      r)t        |      }|sl|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 = 
)rk   propertyr0   rg   appendjoinrl   
isfunction	getsourcer   r   _get_wrapped	TypeError	__class__OSError)	r.   onamesourcesattrnamefnre   oname_prefix_srcsrcs	            r3   r{   r{      s@   & #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    C7 7	ED##D62E5D66EEc                     t        j                  |       xs9 t        j                  |       xs" t        | t              xs t        | t
              S )zTrue if obj is a function ())rl   rz   ismethodrk   _builtin_func_type_builtin_meth_typer.   s    r3   is_simple_callabler      sK    s# Ww'7'7'< Ws./W3=cCU3VXr5   c                     t        j                  dt        d       t        | d      rt	        |       s| j
                  } t        j                  |       S )zWrapper 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.   
stacklevel__call__)warningswarnDeprecationWarningr   r   r   rl   getfullargspecr   s    r3   
getargspecr      sJ     MM <=O\]_ C$-?-Dll!!#&&r5   c                     t        j                  dt        d       t        j                  | 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.r   r   argsvarargsvarkwdefaults)r   r   r   rl   formatargspec)argspecs    r3   format_argspecr     sO     MM <=O\]_   ')2D!(!17:3FH Hr5   c                 ^   t        j                  dt        d       | j                  d      }|d}n+	 |d   d   dk(  }|r|d   d	d |d<   	 | d
   t        |      z   }| j                  d      }|| j                  d      }|| j                  dd      }||fS # t        t
        f$ r Y ^w xY w)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.r   r   r   Nr   r   r1      rO   rM   rK   rG   ru   )r   r   r   r4   KeyError
IndexErrorr   )oinfoformat_callr   	call_linehas_selfdocs         r3   call_tipr     s     MM	2	 ii	"G	
	6vq)V3H ")&/!""5&M."99	 ))$
%C
{ii()
{iiB'c>! *% 		s   B B,+B,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__r   d   )r   r   )r.   orig_objis      r3   r|   r|   <  sI     H	A
sM
*oo	Qs7O sM
* Jr5   c                 $   t        |       } d}	 t        j                  |       }t        |      S # t        $ rC 	 t        j                  | j                        }n# t
        t        f$ r Y nw xY wY t        |      S t
        $ r Y t        |      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|   rl   
getabsfiler}   r~   r   r   )r.   fnames     r3   rZ   rZ   N  s      s
CE""3'   	&&s}}5E# 		   s8   / 	BABA+(B*A++B:BB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|   rl   getsourcelinesr}   r~   r   )r.   linenos     r3   find_source_linesr   q  s      s
C	'',Q/ M  	++CMM:1=F M # 		 s,   ' 	A7"AA)%A7(A))A76A7c            	       j    e Zd Zeej
                  ddddf fd	Zd deedf   fdZ	defdZ
d Zd Zd d	Zed!d
       Zd dZd dZd"dedefdZdedefdZdededefdZdefdZ	 	 	 	 	 d#dededee   defdZ	 	 	 	 	 	 d$dee   fdZd%dZd%deeef   fdZ e!d        Z"g ddfdddZ# xZ$S )&r   Nr   c                     t         t        |   ||       || _        t	        j
                  d| |      | _        | j                  j                  | _        || _        | j                  |       y )N)r-   configr;   )outr-   style)
superr   __init__color_tabler   Parserparserformatstr_detail_levelset_active_scheme)r1   r   code_color_tableschemer   r-   r   r~   s          r3   r   zInspector.__init__  s^    
 	i'vf'E& ''E$fMkk(( 0v&r5   rh   c                 <    	 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)_render_signaturer   )r1   r.   r   s      r3   _getdefzInspector._getdef  s"    
	$Ys^U;;	s    c                     | j                   j                  j                  || j                   j                  j                  S )z*Return a header string with proper colors.)r   active_colorsheadernormal)r1   hs     r3   __headzInspector.__head  s:    ++99@@++99@@B 	Br5   c                     |A| j                   j                  |       | j                  j                   j                  |       y y N)r   r   r   )r1   r   s     r3   r   zInspector.set_active_scheme  s9    ..v6KK##55f= r5   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)r1   msgr   s      r3   noinfozInspector.noinfo  s&    mc!s+(U"#Gr5   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.Nru   zClass constructor information:
zdefinition headerr   r   )callabler   rl   rN   _Inspector__headr   r   r   )r1   r.   r   r   outputs        r3   pdefzInspector.pdef  sr    
 }+,??3[[!CDF c%(>KK+E2&V,#6r5   c                    | j                   }g }t        |      }|r ||      j                  d|      }|r1|j                   |d             |j                  t	        |             t        j                  |      rUt        |d      rIt        |j                        }||j                   |d             |j                  t	        |             nTt        |d      rHt        |j                        }|r1|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:r   zCall docstring:documentationrv   )r   rj   r4   rx   r   rl   rN   hasattrr   r   r   r   ry   )	r1   r.   r   	formatterheadrf   ro   init_dscall_dss	            r3   pdoczInspector.pdoc  s   D {{C[2""<4BLL012LL$??3GC$<S\\*G"T"345VG_-S$S\\*GT"345VG_-KK.IIdii&'r5   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   NrH   )	linecache
checkcacher{   rn   r   r   r   )r1   r.   r   r   s       r3   psourcezInspector.psource
  sa     		Cu-C ;KK%(IIdkk#&'  	C	s   A A+*A+c                 p   t        |      }|| j                  d|       yt        |      }|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.NrE   rX   z File %r is binary, not printing.z%File %r does not exist, not printing.F)skip_encoding_cookier   )r   r   rZ   r[   r   r\   r]   r^   r   r   r   read_py_file)r1   r.   r   r   rc   s        r3   pfilezInspector.pfile  s     #3'>KK&# >>124u<=&9EAB
 IIdkk&"5"5eRW"XY[ade[efr5   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escaperk   dict)r1   r   r   r   	formatteds        r3   _mime_formatzInspector._mime_format0  sm    "  T!2 36:

 O!$Ii. '0i[PV>WXX H2	22r5   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      r3   	<genexpr>z(Inspector.format_mime.<locals>.<genexpr>[  s     ;da3q6;   rv   r   :r   c              3   2   K   | ]  \  }}d | d|   yw)z<h1>z</h1>
Nr<   )r   r   bodys      r3   r   z(Inspector.format_mime.<locals>.<genexpr>n  s!     XLT4tD6/Xs   )r   r   )
rk   listtuplemaxstriprx   r   r   ry   keys)
r1   r   itemnew_brf   _lenr   r   delimrT   s
             r3   format_mimezInspector.format_mimeR  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XF;DWX&k"  	"A//q			"
 r5   titlekeyc                     ||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   rx   )	r1   r   r  r  infoomit_sectionsr   r2   formatted_fields	            r3   _append_info_fieldzInspector._append_info_fieldx  sv     M!SM%9S	"//yAO< ''0M(NO;&&{/K'LM r5   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  r1   s       r3   append_fieldz6Inspector._make_info_unformatted.<locals>.append_field  s*     ##+# $ r5   rh   c                 >    j                  |       t        |       dS )Nr   )r   r@   )r   r1   s    r3   code_formatterz8Inspector._make_info_unformatted.<locals>.code_formatter  s     "kk$/$T] r5   r*   ReprrC   r)   r   SourcerH   	DocstringrG   FilerE   rN   	SignaturerF   zInit signaturerI   zInit docstringrK   TyperA   
Subclasses
subclasseszCall signaturerL   zString formr,   Interactive	NamespaceLengthrD   zClass docstringrJ   zCall docstringrM   r   )r%   r;   r&   r   )	r1   r.   r  r   detail_levelr  r   r  r  s	   ` `  `   r3   _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r5   r.   r   r  c                 z    | j                  ||||      }| j                  |||||      }| j                  |      S )a9  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 : container[str]
            Titles or keys to omit from output (can be set, tuple, etc., anything supporting `in`)
        r   r  r"  )r"  r  )r  r#  r
  )	r1   r.   r   r   r  r"  r  	info_dictr   s	            r3   	_get_infozInspector._get_info  sQ    4 IIcTIU	,,%' - 
 ''r5   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   )	r1   r.   r   r   r  r"  enable_html_pagerr  info_bs	            r3   pinfozInspector.pinfo  sJ    B 	4] ( 
 !{#		&r5   c                 d    t        j                  dt        d       | j                  ||||      S )z
        Inspector.info() was likely improperly marked as deprecated
        while only a parameter was deprecated. We "un-deprecate" it.
        zThe `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.r   r   r%  )r   r   r   r  )r1   r.   r   r  r"  s        r3   _infozInspector._info&  s7     	B 	
 yyE<yPPr5   c                 R
   |d}d}d}n$|j                   }|j                  }|j                  }|j                  d      d   }d}	d}
|rR|j                  Ft        |j                  t              r,t        |j                  t              }|j                  |d      }	t        |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\  rv	 t        |      }d}|sat'        |      |kD  rS|d| dz   || d z   }ddt'        |j)                               z  z   j+                  d |j                  d      D              }|||<   |r||d<   	 t        t'        |            |d<   d}t/        |      }|d}n5|j1                  d      rd}n|j1                  d      rd}t3        |      |d<   |rJt5        j6                          	 t9        |t:              s|s#t=        ||      }||j?                         }||d <   |r&| jA                  |j                  d       |      s||d!<   tC        jD                  |      rd|d"<   	 | jG                  ||      }	 |jJ                  }|	 | jG                  ||      }t        |      }|tL        k(  rd}	 |r||d#<   |r||d$<   t        jO                  |      D cg c]  }|j                    }}t'        |      d%k  rd&j+                  |      }nd&j+                  |dd% d'gz         }||d(<   n| jG                  ||      }|r||d)<   |r.	 t        |d*      }t        |      }|tP        v rd}|r
||k7  r||d+<   	 t        |jJ                        }|tL        k(  rd}|r||d$<   tS        |d,      ritU        |      s^| jG                  |jV                  |      } | r| |j                  d)      k7  r| |d-<   t        |jV                        }!|!tX        k(  rd}!|!r|!|d.<   t[        d/i |S #  d
t        |      z   }Y xY w#  Y IxY w#  Y xY w# t,        $ r Y w xY w# t,        $ r Y 9w xY w# tH        $ r d}Y w xY w# tH        $ r Y w xY w# tH        $ r d}Y w xY wc c}w #  d}Y DxY w# tH        $ r d}Y w xY w)0a  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`. Keys are
        strings, values are string or None.
        NFru   .T)rO   r+   r*   r)   r  z!Alias to the system command:
  %sr   zAlias: z	Alias to z
Docstring:
z<no docstring>      r   zMagic functionrA   zSystem aliasrB   rC   z <...> rv   r   c              3   <   K   | ]  }|j                           y wr   )r  )r   qs     r3   r   z!Inspector.info.<locals>.<genexpr>  s      Eq Es   r,   rD   rX   z<string>z9Dynamically generated function. No source code available.rE   rH   rG   rN   rI   rK   r   , z...r  rF   r~   rJ   r   rL   rM   r<   ).r)   r*   r,   splitr-   r   	HOOK_NAMEr0   r4   r   r   r;   __doc__rj   inttyper6   r~   r   r   
expandtabsry   rn   rZ   r[   r   r   r   rk   rw   r{   rstrip_source_contains_docstringrl   rN   r   AttributeErrorr   _object_init_docstring__subclasses___builtin_type_docstringsr   r   r   _func_call_docstringrV   )"r1   r.   r   r  r"  r)   r*   ospaceatt_nameparents_docspreludeparents_docs_dictr   ro   
ds_or_None
string_maxshalfbclassostrstr_headbinary_filer   r   init_defobj_initr   subnames	all_namesdeflnclsclass_dsrL   r   s"                                     r3   r  zInspector.info5  s   * <GGFllGllG^^F ;;s#B'DKK+Y0O 'Y ?,004@LdGWQU
 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	*(<<)3dE67mCD 3X-@-@-B)C#CC D EDJJt4D EE  $H %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 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()!S!!c."SX-B:	  		:   "    *  " * G($#H " s   =R R$ 0A5R, -R4 "5S S -S6 <S& 
T9T ' T R!$R),R14	S S	SSS#"S#&	S32S36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_docstringrn   )r   r   def_nodes      r3   r=  z$Inspector._source_contains_docstring  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.
        allru   rv   Nr   r   r   z)invalid argument string for psearch: <%s>zinvalid namespace <z>. Valid names: )ignore_caseshow_all)r   ry   sortedr   r6  r   
ValueErrorr  setidaddr   rR   )r1   patternns_table	ns_searchr_  r`  r\  type_patternfiltercmdslen_cmdsrO   search_resultnamespaces_seenns_namenstmp_ress                    r3   psearchzInspector.psearch(  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3r5   ru   )ru   Nr   )ru   NNr   r<   )ru   NNr   Tr<   )ru   Nr   )%r6   r7   r8   r   r   ANSICodeColorsr   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  staticmethodr=  rr  __classcell__)r~   s   @r3   r   r     s   #0",";";"#T	
'eCHo B# B
>
7, 7( 7(r(g. 3  3  3D$"3 $ $LN!N N 	N$L	Ld  $"("( "(
 uo"( 
"(N  $'
 uo'RQ`"S#X `"D    13!5@4@E@4 @4r5   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     r3   r   z$_render_signature.<locals>.<genexpr>  s     6!3q6A:6r   K   z{}(
{})ru   c              3   >   K   | ]  }d j                  |        yw)z    {},
N)r   r{  s     r3   r   z$_render_signature.<locals>.<genexpr>  s       73&'Kq!73s   z{}({})r5  z -> {})
parametersvalueskindrl   	ParameterPOSITIONAL_ONLYrx   VAR_POSITIONALKEYWORD_ONLYr;   r   sumr   ry   return_annotation_emptyformatannotation)obj_signatureobj_nameresultpos_onlykw_onlyparamrenderedannos           r3   r   r   k  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))Or5   rs  )T)dr8  __all__dataclassesr   rl   r   textwrapr   rX  r   ior_   r   r\   systypesr   typingr   r	   r
   r   r   r   version_infotyping_extensionsr   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.coloransir   r   r   IPython.utils.py3compatr   IPython.utils.colorabler   IPython.utils.decoratorsr    pygmentsr!   pygments.lexersr"   pygments.formattersr#   r7  r;   r%   r:   r&   r(   r@   FunctionTyper   rB  objectr   r?  
ModuleType
MethodTyperw   rj   rA  r:  r^  r   upperr   Colorsrt  r   rQ   rV   rg   r{   r   r   r   r   r|   rZ   r   r   r   )ts   0r3   <module>r     s4   
' "   
     	 
   : :w+   % 4 $   + , % 1 / M M 0 - *  ' -'	  $CeCHo)>$>? 9 ?cN	 " $ $ $2I ))22:: 00  % 0 0%2B2B % 2 2H >NGNN1 
 #Y #))_  
)).5T? *<c$h <~X
 ' '" H H  " "J$ c  F>X4	 X4v(# (Y s   $H