Format: application/x-python-code
⬇ Download File (29.1 KB)
   1  o
   2  
   3  ��h���@sUdZddgZddlmZddlmZddlmZddlZddl	Z	ddlZddl
   4  ZddlZddl
   5  Z
   6  ddlZddlZddlmZmZmZmZmZmZmZmZmZddlZdd	lmZdd
   7  lmZddlm Z ddl!m"Z"m#Z#dd
   8  l$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8dZ9ee:eee:e:ffZ;ee<d<ee:e:fZ=ee<d<eGdd�d��Z>dd�Z?ej@jAjZBeCjDjZEdd�ejFejGej@eHfD�ZIeJeK�ZLeJe:jM�ZNe.ZOe"jPZQGd d!�d!e�ZReSeRj<�T��ZUd"d#�ZVeGd$d%�d%��ZWe2d&d&d&d'�d(e:d)eXd*eXd+eXd,eXd-eRfd.d/��ZYd0d1�ZZd-ee:dffd2d3�Z[dId-ee:dffd5d6�Z\d7d8�Z]e2d9d:��Z^e2d;d<��Z_e2dJd>d?��Z`d@dA�Zad-ee:fdBdC�ZbdDdE�ZcGdFd�de0�Zdd-e:fdGdH�ZedS)Kz�Tools for inspecting Python objects.
   9  
  10  Uses syntax highlighting for presenting the various information elements.
  11  
  12  Similar in spirit to the inspect module, but all calls take a name argument to
  13  reference the name under which an object is being read.
  14  �	Inspector�
  15  InspectColors�)�	dataclass)�	signature)�dedentN)	�cast�Any�Optional�Dict�Union�List�	TypedDict�	TypeAlias�Tuple)�page)�pretty)�skip_doctest)�
  16  PyColorize�openpy)�safe_hasattr)�
  17  compress_user)�indent)�list_namespace�typestr2type)�
  18  TermColors)�	Colorable)�undoc)�	highlight)�PythonLexer)�
  19  HtmlFormatterZ__custom_documentations__�UnformattedBundle�Bundlec@sJeZdZUeed<eed<eed<eeed<eed<eed<dd�Zd	S)
  20  �OInfo�ismagic�isalias�found�	namespace�parent�objcCs
  21  t||�S)z�Get a field from the object for backward compatibility with before 8.12
  22  
  23          see https://github.com/h5py/h5py/issues/2253
  24          )�getattr)�self�field�r,�Kc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/oinspect.py�getKs
  25  z	OInfo.getN)	�__name__�
  26  __module__�__qualname__�bool�__annotations__r	�strrr.r,r,r,r-r"Bs
  27  r"cCst|t�tdd��S)NT)Z	noclasses)rrr)�coder,r,r-�pylight\sr6cCsh|]}t�|��qSr,)�inspect�getdoc)�.0�tr,r,r-�	<setcomp>bs
  28  �r;c@s�eZdZUeeed<eeed<eeed<eeed<eeed<eeed<eeed<eeed<eeed	<eeed
  29  <eeed<eeed<eeed
  30  <eeed<eeed<eed<eed<eed<eed<eed<dS)�InfoDict�	type_name�
  31  base_class�string_formr&�length�file�
  32  definition�	docstring�source�init_definition�class_docstring�init_docstring�call_def�call_docstring�
  33  subclassesr#r$�isclassr%�nameN)r/r0r1r	r4r3r2r,r,r,r-r<ts*
  34  r<cCs0|dkrtjdtdd�tStdt�d|����)NZinfo_fieldszfIPython.core.oinspect's `info_fields` is considered for deprecation and may be removed in the Future. ���
  35  stacklevelzmodule z has no attribute )�warnings�warn�DeprecationWarning�_info_fields�AttributeErrorr/)rLr,r,r-�__getattr__�s�rUc@sBeZdZUdZeed<eeed<eed<e	ed<e
  36  eed<dS)�InspectorHookDatazData passed to the mime hookr(�info�	info_dict�detail_level�
  37  omit_sectionsN)r/r0r1�__doc__rr3r	r"r<�int�listr4r,r,r,r-rV�s
  38  rVF)rKr$r#rLr%rKr$r#�returncsL|��fdd�tD��|�d<|�d<|�d<|�d<|�d<td	i���S)
  39  z1Make an object info dict with all fields present.csi|]	}|�vr|d�qS�Nr,)r9�k�Zinfodictr,r-�
  40  <dictcomp>�szobject_info.<locals>.<dictcomp>rLr%rKr$r#Nr,)rSr<)rLr%rKr$r#�kwr,rar-�object_info�srdcCstt|�}|dur
  41  dS|�d�rdStj�|�sdSt�|d��}t�|j	�\}}Wd�|S1s3wY|S)znGet encoding for python source file defining obj
  42  
  43      Returns None if obj is not defined in a sourcefile.
  44      N�z.soz.dllz.pyd�rb)
  45  �	find_file�endswith�os�path�isfile�	stdlib_io�openr�detect_encoding�readline)r(�ofile�buffer�encoding�_linesr,r,r-�get_encoding�s
  46  
  47  ��rtcCsBz|��}Wn	tyYnwt|t�rt�|�St�|�}|S)a=Stable wrapper around inspect.getdoc.
  48  
  49      This can't crash because of attribute problems.
  50  
  51      It also attempts to call a getdoc() method on the given object.  This
  52      allows objects which provide their docstrings via non-standard mechanisms
  53      (like Pyro proxies) to still be inspected by ipython's ? system.
  54      )r8�	Exception�
  55  isinstancer4r7�cleandoc)r(�dsZdocstrr,r,r-r8�s
  56  �
  57  
  58  
  59  r8�c	Cst|t�rTg}dD]A}t||�}|durJt|�}|rd|nd}|�d�d||f��t�|�r>t|�}|r=|�t	|��q	|�d||t
  60  |�f�q	|rRd�|�SdSt|�}zt�|�}W|Styz
  61  t�|j
  62  �}WY|Sttfy~YYdSwty�YdSw)alWrapper around inspect.getsource.
  63  
  64      This can be modified by other projects to provide customized source
  65      extraction.
  66  
  67      Parameters
  68      ----------
  69      obj : object
  70          an object whose source code we will attempt to extract
  71      oname : str
  72          (optional) a name under which the object is known
  73  
  74      Returns
  75      -------
  76      src : unicode or None
  77  
  78      )�fget�fset�fdelNz%s.ryz# z
  79  %s%s = %s
  80  �
  81  )rv�propertyr)rt�append�joinr7�
  82  isfunction�	getsourcerr�_get_wrapped�	TypeError�	__class__�OSError)	r(�oname�sources�attrname�fnrrZoname_prefixZ_src�srcr,r,r-r��sD
  83  
  84  
  85  ���
  86  ����r�cCs(t�|�pt�|�pt|t�pt|t�S)zTrue if obj is a function ())r7r��ismethodrv�_builtin_func_type�_builtin_meth_type�r(r,r,r-�is_simple_callable)s
  87  ��r�cCs2tjdtdd�t|d�rt|�s|j}t�|�S)z�Wrapper around :func:`inspect.getfullargspec`
  88  
  89      In addition to functions and methods, this can also handle objects with a
  90      ``__call__`` attribute.
  91  
  92      DEPRECATED: Deprecated since 7.10. Do not use, will be removed.
  93      z]`getargspec` function is deprecated as of IPython 7.10and will be removed in future versions.rMrN�__call__)rPrQrRrr�r�r7�getfullargspecr�r,r,r-�
  94  getargspec.s
  95  �
  96  r�cCs0tjdtdd�t�|d|d|d|d�S)a
  97  Format argspect, convenience wrapper around inspect's.
  98  
  99      This takes a dict instead of ordered arguments and calls
 100      inspect.format_argspec with the arguments in the necessary order.
 101  
 102      DEPRECATED (since 7.10): Do not use; will be removed in future versions.
 103      za`format_argspec` function is deprecated as of IPython 7.10and will be removed in future versions.rMrN�args�varargs�varkw�defaults)rPrQrRr7�
 104  formatargspec)�argspecr,r,r-�format_argspec@s
 105  ��r�Tc	Cs�tjdtdd�|�d�}|durd}n*z
 106  |dddk}Wnttfy)Yn
 107  w|r6|dd	d�|d<|d
 108  t|�}|�d�}|durL|�d�}|durV|�d
 109  d�}||fS)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.rMrNr�Nr�rr*�rLrIrGrCry)rPrQrRr.�KeyError�
 110  IndexErrorr�)ZoinfoZformat_callr�Z	call_lineZhas_self�docr,r,r-�call_tipQs,�
 111  �
 112  
 113  r�cCs:|}d}t|d�r|j}|d7}|dkr|St|d�s	|S)aNGet the original object if wrapped in one or more @decorators
 114  
 115      Some objects automatically construct similar objects on any unrecognised
 116      attribute access (e.g. unittest.mock.call). To protect against infinite loops,
 117      this will arbitrarily cut off after 100 levels of obj.__wrapped__
 118      attribute access. --TK, Jan 2016
 119      r�__wrapped__r��d)rr�)r(Zorig_obj�ir,r,r-r�ws
 120  
 121  �r�cCsnt|�}d}zt�|�}W|Sty-z
 122  t�|j�}WY|Sttfy,YY|Swty6Y|Sw)a^Find the absolute path to the file where an object was defined.
 123  
 124      This is essentially a robust wrapper around `inspect.getabsfile`.
 125  
 126      Returns None if no file can be found.
 127  
 128      Parameters
 129      ----------
 130      obj : any Python object
 131  
 132      Returns
 133      -------
 134      fname : str
 135          The absolute path to the file where the object was defined.
 136      N)r�r7�
 137  getabsfiler�r�r�)r(�fnamer,r,r-rg�s"����rgcCsrt|�}z
 138  t�|�d}W|Sty/zt�|j�d}WY|Sttfy.YYdSwty8YdSw)aWFind the line number in a file where an object was defined.
 139  
 140      This is essentially a robust wrapper around `inspect.getsourcelines`.
 141  
 142      Returns None if no file can be found.
 143  
 144      Parameters
 145      ----------
 146      obj : any Python object
 147  
 148      Returns
 149      -------
 150      lineno : int
 151          The line number where the object definition starts.
 152      r�N)r�r7�getsourcelinesr�r�r�)r(�linenor,r,r-�find_source_lines�s
 153  ����r�cs�eZdZejddd�jdd�Zeej	ddddf�fdd�	Z
 154  d;d
 155  eedffdd�Z
 156  d
 157  efd
 158  d�Zdd�Zdd�Zd;dd�Zed<dd��Zd;dd�Zd;dd�Zd=ded
 159  efdd�Zded
 160  efdd �Zded!ed"ed#eefd$d%�Zd
 161  efd&d'�Z						(d>d)ed*ed+ee d,e!d#eeee"d(fd
 162  efd-d.�Z#							(d?d+ee fd/d0�Z$d@d1d2�Z%d@d
 163  e&fd3d4�Z'e(d5d6��Z)gd7d7fd7d8�d9d:�Z*�Z+S)ArTzKdictionary of mime to callable to add information into help mimebundle dict)�config�help)r�NrcsJtt|�j||d�||_tjd||d�|_|jj|_||_|�	|�dS)N)r'r�r4)�outr'�style)
 164  �superr�__init__�color_tabler�Parser�parser�format�str_detail_level�set_active_scheme)r*r�Zcode_color_table�schemer�r'r��r�r,r-r��s	
 165  zInspector.__init__ryr^cCs*t|�sdSztt|�|�WSYdS)z�Return the call signature for any callable object.
 166  
 167          If any exception is generated, None is returned instead and the
 168          exception is suppressed.N)�callable�_render_signaturer)r*r(r�r,r,r-�_getdef�szInspector._getdefcCsd|jjj||jjjfS)z*Return a header string with proper colors.z%s%s%s)r�Z
 169  active_colors�header�normal)r*�hr,r,r-Z__head�s�zInspector.__headcCs*|dur|j�|�|jj�|�dSdSr_)r�r�r�)r*r�r,r,r-r��s�zInspector.set_active_schemecCs.td|dd�|rtd|�dSt�dS)z-Generic message when no information is found.zNo %s found� ��endzfor %sN)�print)r*�msgr�r,r,r-�noinfo�s
 170  zInspector.noinfocCsht|�s
 171  td�dSd}t�|�r|�d�}|�||�}|dur(|�d|�dSt||�|�dd�dS)zwPrint the call signature for any callable object.
 172  
 173          If the object is a class, print the constructor information.zObject is not callable.NryzClass constructor information:
 174  zdefinition headerr�r�)r�r�r7rK�_Inspector__headr�r�r�)r*r(r�r��outputr,r,r-�pdefs
 175  
 176  zInspector.pdefc	Cs�|j}g}t|�}|r||��d|�}|r#|�|d��|�t|��t�|�rEt|d�rEt|j�}|durD|�|d��|�t|��nt|d�r_t|j	�}|r_|�|d��|�t|��|si|�
 177  d|�dSt�d	�|��dS)
 178  a�Print the docstring for any object.
 179  
 180          Optional:
 181          -formatter: a function to run the docstring through for specially
 182          formatted docstrings.
 183  
 184          Examples
 185          --------
 186          In [1]: class NoInit:
 187             ...:     pass
 188  
 189          In [2]: class NoDoc:
 190             ...:     def __init__(self):
 191             ...:         pass
 192  
 193          In [3]: %pdoc NoDoc
 194          No documentation found for NoDoc
 195  
 196          In [4]: %pdoc NoInit
 197          No documentation found for NoInit
 198  
 199          In [5]: obj = NoInit()
 200  
 201          In [6]: %pdoc obj
 202          No documentation found for obj
 203  
 204          In [5]: obj2 = NoDoc()
 205  
 206          In [6]: %pdoc obj2
 207          No documentation found for obj2
 208          z
 209  plain/textzClass docstring:r�NzInit docstring:r�zCall docstring:Z
 210  documentationr})
 211  r�r8r.rrr7rK�hasattrr�r�r�rr�)	r*r(r��	formatter�head�linesrx�init_ds�call_dsr,r,r-�pdocs,"
 212  �
 213  
 214  zInspector.pdoccCs\t��zt||d�}Wntyd}Ynw|dur$|�d|�dSt�|�|��dS)z$Print the source code for an object.)r�NrD)�	linecache�
 215  checkcacher�rur�rr�)r*r(r�r�r,r,r-�psourcePs�zInspector.psourcecCs�t|�}|dur|�d|�dSt|�}|durtd�dS|�d�r+td|�dStj�|�s9td|�dSt�|�	t
 216  j|dd��|d	�dS)
 217  z0Show the whole file where an object was defined.NrAzCould not find file for objectrez File %r is binary, not printing.z%File %r does not exist, not printing.F)Zskip_encoding_cookier�)r�r�rgr�rhrirjrkrr�rZread_py_file)r*r(r�r�rpr,r,r-�pfile_s
 218  $zInspector.pfile�textcCsX|dt�|��d�d�}|dur|S||�}t|t�s$|d|�d�d�St|fi|��S)aRReturn a mime bundle representation of the input text.
 219  
 220          - if `formatter` is None, the returned mime bundle has
 221             a ``text/plain`` field, with the input text.
 222             a ``text/html`` field with a ``<pre>`` tag containing the input text.
 223  
 224          - if ``formatter`` is not None, it must be a callable transforming the
 225            input text into a mime bundle. Default values for ``text/plain`` and
 226            ``text/html`` representations are the ones described above.
 227  
 228          Note:
 229  
 230          Formatters returning strings are supported but this behavior is deprecated.
 231  
 232          z<pre>z</pre>��
 233  text/plain�	text/htmlN)�html�escaperv�dict)r*r�r�r��	formattedr,r,r-�_mime_formatxs�
 234  zInspector._mime_format�bundlec
 235  CsBt|dt�s	J�|dD]	}t|t�sJ�q
 236  i}g}tdd�|dD��}|dD])\}}|�d�}d|vr9dnd}|�|�|d��|t|�d�|�|���q*d�|�|d<d|vr�t|dt�shJ�|dD]	}t|t�suJ�qlt|dttf�r�d�dd�|dD��|d<|�	�D]
 237  }	|	d	vr�q�||	||	<q�|S)
 238  zRFormat a mimebundle being created by _make_info_unformatted into a real mimebundler�css�|]	\}}t|�VqdSr_��len)r9r��_r,r,r-�	<genexpr>���z(Inspector.format_mime.<locals>.<genexpr>r}r��:r�css$�|]
 239  \}}d|�d|��VqdS)z<h1>z</h1>
 240  Nr,)r9r��bodyr,r,r-r��s�")r�r�)
 241  rvr]�tuple�max�striprr�r�r��keys)
 242  r*r��itemZnew_br��_lenr�r��delimr`r,r,r-�format_mime�s4
 243  (��zInspector.format_mime�title�keyrZc	Csd||vs||vr
 244  dS||}|dur0|�||�}|d�||df�|d�||df�dSdS)z^Append an info value to the unformatted mimebundle being constructed by _make_info_unformattedNr�r�)r�r)	r*r�r�r�rWrZr�r+Zformatted_fieldr,r,r-�_append_info_field�s
 245  �zInspector._append_info_fieldc	s�ggd�}	d-dtdtdtf���fdd�
 246  }dtf�fd	d
 247  �}�dr+||dd
 248  �|S�drJ|dkr;||dd|�n||dd|�||dd�|S�dsRt|�r�||dd|�||dd|�||dd|�|dkrw�drw||dd|�n||dd|�||dd�||dd�||dd �|S||dd|�||d!d"|�||dd�||d#d
 249  ��d$d%kr�||d&d$�||d'd(�||dd�|dkrԈdr�||dd|�n||dd|�||d)d*|�||dd|�||d+d,|�|S).z;Assemble the mimebundle as unformatted lists of informationr�Nr�r�r�cs�j|||��|d�dS)N)r�r�rWrZr�)r�)r�r�r�r��rWrZr*r,r-�append_field�s
 250  �z6Inspector._make_info_unformatted.<locals>.append_fieldr^cs��|�t|�d�S)Nr�)r�r6)r�)r*r,r-�code_formatter�s�z8Inspector._make_info_unformatted.<locals>.code_formatterr$�Reprr?r#rZSourcerDZ	DocstringrC�FilerArK�	SignaturerBzInit signaturerEzInit docstringrG�Typer=Z
 251  SubclassesrJzCall signaturerHzString formr&�Interactive�	NamespaceZLengthr@zClass docstringrFzCall docstringrIr_)r r4r!r�)	r*r(rWr�rYrZr�r�r�r,r�r-�_make_info_unformatted�s^�����/�(��z Inspector._make_info_unformattedr,r(r�rWrYcCs�|j||||d�}t|�}|j|||||d�}|jrZt|||||d�}	|j��D]1\}
 252  }dd�t�|�j�	�D�}t
 253  |�dkrD||	�}
 254  n
 255  tjdt
 256  dd	�|||�}
 257  |
 258  d
 259  urY|
 260  ||
 261  <q(|�|�S)a4Retrieve an info dict and format it.
 262  
 263          Parameters
 264          ----------
 265          obj : any
 266              Object to inspect and return info from
 267          oname : str (default: ''):
 268              Name of the variable pointing to `obj`.
 269          formatter : callable
 270          info
 271              already computed information
 272          detail_level : integer
 273              Granularity of detail level, if set to 1, give more information.
 274          omit_sections : list[str]
 275              Titles or keys to omit from output (can be set, tuple, etc., anything supporting `in`)
 276          �r�rWrY)rYrZ)r(rWrXrYrZcSsg|]}|jtjjkr|�qSr,)�defaultr7�	Parameter)r9Z	parameterr,r,r-�
 277  <listcomp>Ns
 278  �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 versionrMrNN)rWr]r��
 279  mime_hooksrV�itemsr7r�
 280  parameters�valuesr�rPrQrRr�)r*r(r�r�rWrYrZrXr��	hook_datar��hookZrequired_parameters�resr,r,r-�	_get_info!sB���
 281  �
 282  �
 283  zInspector._get_infoc	Cs:|dusJ�|j||||||d�}|s|d=t�|�dS)a Show detailed information about an object.
 284  
 285          Optional arguments:
 286  
 287          - oname: name of the variable pointing to the object.
 288  
 289          - formatter: callable (optional)
 290                A special formatter for docstrings.
 291  
 292                The formatter is a callable that takes a string as an input
 293                and returns either a formatted string or a mime type bundle
 294                in the form of a dictionary.
 295  
 296                Although the support of custom formatter returning a string
 297                instead of a mime type bundle is deprecated.
 298  
 299          - info: a structure with some information fields which may have been
 300            precomputed already.
 301  
 302          - detail_level: if set to 1, more information is given.
 303  
 304          - omit_sections: set of section keys and titles to omit
 305          N)rZr�)rr)	r*r(r�r�rWrYZenable_html_pagerrZZinfo_br,r,r-�pinfobs!�zInspector.pinfocCs"tjdtdd�|j||||d�S)z�
 306          Inspector.info() was likely improperly marked as deprecated
 307          while only a parameter was deprecated. We "un-deprecate" it.
 308          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.rMrNr�)rPrQrRrW)r*r(r�rWrYr,r,r-�_info�s�zInspector._infoc 	Cs,|durd}d}d}n	|j}|j}|j}|�d�d}d}	d}
 309  |r8|jdur8t|jt�r8t|jt�}|�|d�}	t	t
 310  idd�tD��|d||dd	���}|	rQ|	}
 311  n8|r|t|�skzd
 312  |d}
 313  Wn)dt
 314  |�}
 315  Ynd
 316  t
 317  |�}
 318  |jr{|
 319  d|j7}
 320  n
 321  t|�}|dur�d}
 322  n|}
 323  |
 324  |
 325  }
 326  d}t|dd�}|r�d|d<n|r�d|d<nt|�j|d<z|j}t
 327  |�|d<WnY||jkr�z6t
 328  |�}|s�t|�|kr�|d|�d||d�}ddtd����dd�|�d�D��}||d<WnY|�r||d<z
 329  t
 330  t|��|d<Wn
 331  t�yYnwd}t|�}|du�r&d}n|�d��r/d}n|�d ��r7d!}t|�|d"<|�rlt��zt|t��sN|�s`t ||�}|du�r\|�!�}||d#<Wn
 332  t�ykYnw|
 333  �r}|�"|�d#�|
 334  ��s}|
 335  |d$<t#�$|��rd|d%<z|�%||�}Wnt&�y�d}Ynwz|j'}Wnt&�y�d}Yn$w|du�r�z|�%||�}Wn
 336  t&�y�Ynwt|�}|t(k�r�d}|�r�||d&<|�r�||d'<d(d)�t�)|�D�}t|�d*k�r�d+�|�}nd+�|dd*�d,g�}||d-<|S|�%||�}|�r||d.<|
 337  �r>zt|d/�}Wnd}Ynt|�}|t*v�r2d}|�r>|
 338  |k�r>||d0<zt|j'�}|t(k�rKd}Wnt&�yXd}Ynw|�r`||d'<t+|d1��r�t,|��s�|�%|j-|�}|�r�||�d.�k�r�||d2<t|j-�}|t.k�r�d}|�r�||d3<|S)4asCompute a dict with detailed information about an object.
 339  
 340          Parameters
 341          ----------
 342          obj : any
 343              An object to find information about
 344          oname : str (default: '')
 345              Name of the variable pointing to `obj`.
 346          info : (default: None)
 347              A struct (dict like with attr access) with some information fields
 348              which may have been precomputed already.
 349          detail_level : int (default:0)
 350              If set to 1, more information is given.
 351  
 352          Returns
 353          -------
 354          An object info dict with known fields from `info_fields` (see `InfoDict`).
 355          NFry�.�����cSsi|]}|d�qSr_r,)r9r+r,r,r-rb��z"Inspector.info.<locals>.<dictcomp>T)rLr%r$r#rJz!Alias to the system command:
 356    %sr�zAlias: z	Alias to z
 357  Docstring:
 358  z<no docstring>���rMzMagic functionr=zSystem aliasr>z <...> r}r�r?css�|]}|��VqdSr_)r�)r9�qr,r,r-r��s�
 359  �z!Inspector.info.<locals>.<genexpr>r&r@rez<string>z9Dynamically generated function. No source code available.rArDrCrKrErGcSsg|]}|j�qSr,)r/)r9�subr,r,r-r�Nrz"Inspector.info.<locals>.<listcomp>�
 360  �, z...rJrBr�rFr�rHrI)/r#r$r&�splitr'r��	HOOK_NAMEr)r.rr<rSr�r4r[r8r\�typer/r�r�r��
 361  expandtabsr�rurgrhrr�r�rvr~r��rstrip�_source_contains_docstringr7rKr�rTr��_object_init_docstring�__subclasses__�_builtin_type_docstringsrr�r��_func_call_docstring) r*r(r�rWrYr#r$ZospaceZatt_nameZparents_docsZpreludeZparents_docs_dictr�rxZ
 362  ds_or_NoneZ
 363  string_maxZshalfZbclassZostr�binary_filer�r�Zinit_defZobj_initr��namesZ	all_namesZdefln�clsZclass_dsrHr�r,r,r-rW�s@�����
 364  
 365  
 366  ��
 367  
 368  
 369  ���
 370  �
 371  �
 372  2�
 373  
 374  
 375  ��
 376  
 377  zInspector.infocCs8zt�t|��j\}t�|�|kWStyYdSw)z�
 378          Check whether the source *src* contains the docstring *doc*.
 379  
 380          This is is helper function to skip displaying the docstring if the
 381          source already contains it, avoiding repetition of information.
 382          F)�ast�parserr��
 383  get_docstringru)r�r�Zdef_noder,r,r-r�s�z$Inspector._source_contains_docstringF)�
 384  list_typescCs�d}d}|rt�d�tt���dS|��}	t|	�}
 385  |
 386  dkr#|	d}n|
 387  dkr,|	\}}ntd|��|D]}||vrDtd	||��f��q4t�t�}}
 388  |D]"}||}t	|�|
 389  vr[qN|
 390  �
 391  t	|��t|||||d
 392  �}|�|�qNt�d�t|���dS)a�Search namespaces with wildcards for objects.
 393  
 394          Arguments:
 395  
 396          - pattern: string containing shell-like wildcards to use in namespace
 397            searches and optionally a type specification to narrow the search to
 398            objects of that type.
 399  
 400          - ns_table: dict of name->namespaces for search.
 401  
 402          Optional arguments:
 403  
 404            - ns_search: list of namespace names to include in search.
 405  
 406            - ignore_case(False): make the search case-insensitive.
 407  
 408            - show_all(False): show all names, including those starting with
 409              underscores.
 410  
 411            - list_types(False): list all available object types for object matching.
 412          �allryr}Nr�rrMz)invalid argument string for psearch: <%s>z'invalid namespace <%s>. Valid names: %s)�ignore_case�show_all)
 413  rr��sortedrr
 414  r��
 415  ValueErrorr��set�id�addr�update)r*�patternZns_tableZ	ns_searchrr rZtype_pattern�filterZcmdsZlen_cmdsrLZ
 416  search_resultZnamespaces_seenZns_name�nsZtmp_resr,r,r-�psearch�s>
 417  
 418  �
 419  ���zInspector.psearch�ry)ryNr_)ryNNrr,)ryNNrTr,)ryNr),r/r0r1�	traitletsr
 420  �tagr�rr�ANSICodeColorsr�rr4r�r�r�r�r�rr�r�r�r�r�r r!r�rr�r�rr	r"r\rrrrr<rW�staticmethodrr*�
 421  __classcell__r,r,r�r-r�s����
 422  
 423  9
 424  "&���
 425  �
 426  �R������
 427  �D�
 428  �
 429  )n
 430  ��cCs
 431  g}d}d}|j��D]6}|jtjjkrd}n	|r |�d�d}|jtjjkr*d}n|jtjjkr:|r:|�d�d}|�t	|��q|rI|�d�t
 432  |�tdd�|D��dkrgd�|d	�
 433  d
 434  d�|D���}n	d�|d�
 435  |��}|jtjur�t�|j�}|d
 436  �|�7}|S)z�
 437      This was mostly taken from inspect.Signature.__str__.
 438      Look there for the comments.
 439      The only change is to add linebreaks when this gets too long.
 440      FT�/�*css�|]	}t|�dVqdS)rMNr��r9�rr,r,r-r��r�z$_render_signature.<locals>.<genexpr>�Kz{}(
 441  {})rycss�|]}d�|�VqdS)z    {},
 442  N)r�r3r,r,r-r��s�
 443  
 444  �z{}({})rz -> {})r�r��kindr7r��POSITIONAL_ONLYr�VAR_POSITIONAL�KEYWORD_ONLYr4r��sumr�r��return_annotation�_empty�formatannotation)Z
 445  obj_signature�obj_name�resultZpos_only�kw_only�param�rendered�annor,r,r-r��s4
 446  
 447  
 448  �r�r+)T)fr[�__all__�dataclassesrr7r�textwraprrr��iorlr�ri�typesrP�typingrrr	r
 449  rrr
 450  rrr,ZIPython.corerZIPython.lib.prettyrZIPython.testing.skipdoctestrZ
 451  IPython.utilsrrZIPython.utils.dir2rZIPython.utils.pathrZIPython.utils.textrZIPython.utils.wildcardrrZIPython.utils.coloransirZIPython.utils.colorablerZIPython.utils.decoratorsr�pygmentsrZpygments.lexersrZpygments.formattersrrr4r r3r!r"r6�FunctionTyper�r�objectr�r�
 452  ModuleType�
 453  MethodTyper~rrrr��upperr�ZColorsr.rr<r]r�rSrUrVr2rdrtr8r�r�r�r�r�r�rgr�rr�r,r,r,r-�<module>s�, 
 454  ��
 455  
 456  �������?
 457  
 458  %#