Format: application/x-python-code
⬇ Download File (103.9 KB)
   1  o
   2  
   3  ��h�]�@s�UdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
   4  Z
   5  ddlZddlZddl
   6  Z
   7  ddlZddlZddlZddlZddlZddlmZddlmZddlmZddlmZddlmZddlmZmZ m!Z"dd	lm#Z#m$Z$m%Z%dd
   8  lm&Z&zddl'm(Z(Wne)y�Gdd
   9  �d
  10  �Z(Ynwddlm*Z*ddl+m!Z!m,Z,m-Z-mZm.Z.m/Z/m0Z0mZm1Z1m2Z2m3Z3m4Z4m5Z5ddl6m7Z7ddl8m9Z9ddl:Z;ddl<m=Z=m>Z>m?Z?m@Z@mAZAddlBmCZCmDZDddlEmFZFddlGmHZHddlImJZJddlKmLZLddlMmNZNddlOmPZPddlQmRZRddlSmTZTmUZUddlVmWZWmXZXddlYmZZZddl[m\Z\ddl]m^Z^dd l_m`Z`maZadd!lbmcZcdd"ldmeZedd#lfmgZgdd$lhmiZidd%ljmkZkdd&llmmZmdd'lnmoZodd(lpmqZqdd)lrmsZsdd*ltmuZumZmvZvmwZwdd+lxmyZydd,lzm{Z{dd-l|m}Z}dd.l~mZm�Z�m�Z�dd/l�m�Z�m�Z�dd0l�m�Z�dd1l�m�Z�dd2l�m�Z�m�Z�m�Z�m�Z�dd3l�m�Z�e#ee�d4<zddl�m�Z�d5d4�Z�Wne��y�dZ�Ynwej�dd6�d7k�r�dd8l�m�Z�Gd9d:�d:e��Z�dd;lm�Z�ej�ej�ej�fZ�ej�ej�fZ�d<d=l�m�Z�m�Z�m�Z�m�Z�m�Z�e
  11  ��d>�Z�d?e�fd@dA�Z�eydBdC��Z�eydDdE��Z�GdFdG�dGe��Z�GdHdI�dIe2�Z�eyGdJdK�dKe���Z�GdLdM�dMe��Z�GdNdO�dO�Z�e��e�dPdQ��Z�GdRdS�dSe7�Z�GdTdU�dUej�dV�Z�e���e��dS)WzMain IPython class.�N)�stmt)�open)�error)�Path)�Callable)�List�Dict�Any)�Optional�Sequence�Tuple��warn)�
  12  PickleShareDBc@s:eZdZdZdd�Zd
  13  dd�Zdd�Zd	d
  14  �Zdd�ZdS)rTcC�dS�N�)�self�pathrr�Sc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/interactiveshell.py�__init__/�zPickleShareDB.__init__NcCstd|�d�dd�|S�Nz5This is now an optional IPython functionality, using �3 requires you to install the `pickleshare` library.���
  15  stacklevelr
  16  )r�key�defaultrrr�get2�
  17  
  18  �zPickleShareDB.getcC�td|�d�dd�dSrr
  19  �rrrrr�__getitem__9r zPickleShareDB.__getitem__cCr!)Nz7This is now an optional IPython functionality, setting rrrr
  20  )rr�valuerrr�__setitem__@�
  21  
  22  �zPickleShareDB.__setitem__cCr!)Nz8This is now an optional IPython functionality, deleting rrrr
  23  r"rrr�__delitem__Fr&zPickleShareDB.__delitem__r)	�__name__�
  24  __module__�__qualname__Z_mockrrr#r%r'rrrrr,s
  25  r)�TemporaryDirectory)
  26  r	�Bool�CaselessStrEnumr�Enum�Instance�Integerr�Type�Unicoder�observe�validate)�SingletonConfigurable��import_item)�magic�oinspect�page�	prefilter�ultratb)�Alias�AliasManager��ExitAutocall)�BuiltinTrap)�CachingCompiler)�InterruptiblePdb)�DisplayTrap)�DisplayHook)�DisplayPublisher)�
  27  InputRejected�
  28  UsageError)�EventManager�available_events)�ExtensionManager)�DisplayFormatter)�HistoryManager)�	ESC_MAGIC�
  29  ESC_MAGIC2)�Logger)�Macro)�PayloadManager)�PrefilterManager)�
  30  ProfileDir)�default_banner)�display)�get_ipython_dir)�skip_doctest)�
  31  PyColorize�io�openpy�	py3compat)�undoc)�
  32  ask_yes_no)�Struct)�ensure_dir_exists�get_home_dir�get_py_filename)�	getoutput�system)�StrDispatch)�prepended_to_syspath)�DollarFormatter�LSString�SList�
  33  format_screen)�OInfo�	sphinxifycst�|���fdd�}|S)Ncs<t��}t��|�|d�Wd�S1swYdS)N)z	text/html�
  34  text/plain)r+�sphxrl)�	docstring�dirname�Zwrapped_docstringrr�sphinxify_docstring�s
  35  
  36  �$�z&sphinxify.<locals>.sphinxify_docstring)rnZwrap_main_docstring)Zoinforrrrqrrl�s
  37  r)��)�BaseExceptionGroupc@�eZdZdZdS)�ProvisionalWarningz-
  38      Warning class for unstable features
  39      N�r(r)r*�__doc__rrrrrw�srw)�Module�)�_asyncio_runner�
  40  _curio_runner�_pseudo_sync_runner�_should_be_async�_trio_runnerz^\s+raise|^\s+return|^\s+pass�scCs$zt|�WdStyYdSw)zQ
  41      Variant of "str.isnumeric()" that allow negative values and other ints.
  42      TF)�int�
  43  ValueError)r�rrr�is_integer_string�s�r�c	CsHd}z|j}Wn	tyYnwz||_W|Sttfy#Y|Sw)z-Copied from code.py, to remove the dependencyr)�	softspace�AttributeError�	TypeError)�fileZnewvalueZoldvaluerrrr��s
  44  ���r�cOrrr)�a�kwrrr�no_op��r�c@seZdZdS)�SpaceInInputN)r(r)r*rrrrr��sr�cs eZdZdZ�fdd�Z�ZS)�SeparateUnicodez�A Unicode subclass to validate separate_in, separate_out, etc.
  45  
  46      This is a Unicode based trait that converts '0'->'' and ``'\\n'->'\n'``.
  47      cs*|dkrd}|�dd�}tt|��||�S)N�0�z\n�
  48  )�replace�superr�r4)r�objr$��	__class__rrr4�szSeparateUnicode.validate)r(r)r*ryr4�
  49  __classcell__rrr�rr��sr�c@seZdZdZdZdS)�DummyModztA dummy module used for IPython's interactive module when
  50      a namespace must be assigned to the module's __dict__.N)r(r)r*ry�__spec__rrrrr��sr�c@s4eZdZdZdZdZdZdZdZdd�Z	dd�Z
  51  dS)	�
  52  ExecutionInfoz~The arguments used for a call to :meth:`InteractiveShell.run_cell`
  53  
  54      Stores information about what is going to happen.
  55      NFTcCs"||_||_||_||_||_dSr)�raw_cell�
  56  store_history�silent�
  57  shell_futures�cell_id)rr�r�r�r�r�rrrrs
  58  
  59  zExecutionInfo.__init__cCsP|jj}t|j�dkr|jdd�dn|j}d|t|�||j|j|j|jfS)N�2z..zW<%s object at %x, raw_cell="%s" store_history=%s silent=%s shell_futures=%s cell_id=%s>)	r�r*�lenr��idr�r�r�r�)r�namer�rrr�__repr__	s$����zExecutionInfo.__repr__)r(r)r*ryr�r�r�r�r�rr�rrrrr��sr�c@sneZdZUdZdZeeed<dZee	ed<dZ
  60  eeed<dZdZ
  61  dd�Zedd	��Zd
  62  d�Zdd
  63  �ZdS)�ExecutionResultzmThe result of a call to :meth:`InteractiveShell.run_cell`
  64  
  65      Stores information about what took place.
  66      N�execution_count�error_before_exec�
  67  error_in_execcC�
  68  ||_dSr)�info)rr�rrrr(�
  69  zExecutionResult.__init__cCs|jduo	|jduSr�r�r��rrrr�success+�zExecutionResult.successcCs$|jdur|j�|jdur|j�dS)z>Reraises error if `success` is `False`, otherwise does nothingNr�r�rrr�raise_error/s
  70  
  71  
  72  �zExecutionResult.raise_errorc	Cs4|jj}d|t|�|j|j|jt|j�t|j�fS)Nz]<%s object at %x, execution_count=%s error_before_exec=%s error_in_exec=%s info=%s result=%s>)	r�r*r�r�r�r��reprr��result�rr�rrrr�6s&�zExecutionResult.__repr__)r(r)r*ryr�r
  73  r��__annotations__r��boolr��
  74  BaseExceptionr�r�r�propertyr�r�r�rrrrr�s
  75  
  76  r�cOs.|dvrtd|�d���t|g|�Ri|��S)N>rr{rzIPython won't let you open fd=zi by default as it is likely to crash IPython. If you know what you are doing, you can use builtins' open.)r��io_open)r��args�kwargsrrr�_modified_open;s
  77  
  78  �r�cs8eZdZUdZdZegdd�jdd�Zeej	e
  79  d<edd	d
  80  d�jdd�Ze
  81  ddd�jdd�Ze
  82  dd
  83  d�jdd�Zedfedfedfedfd�Zedddd�jdd�Zed�dd��Zed�dd��Ze
  84  ddd�jdd�Zeedd�jdd�Zeddd�jdd�Ze ddd�jdd�Z!e
  85  ddd�jdd�Z"e#dd d!d�jdd�Z$e
  86  d�jdd�Z%e
  87  dd"d�jdd�Z&e'e(dd#�Z)e*e+�Z,e*e-�Z.e*e/�Z0e*e1j2d$d�jdd�Z3e
  88  dd%d�jdd�Z4e5d&�d'd(��Z6e
  89  dd)d�jdd�Z7e5d*�d+d,��Z8dZ9e
  90  d�Z:e'e;�Z<ed-�d.d/��Z=e d0�Z>ed1�Z?ed�jdd�Z@e'd2d3�ZAeBd4d5��ZCegd6d�ZDee
  91  d7<eBd8d9��ZEe
  92  dd:d�jdd�ZFedd;d�jdd�ZGedd<d�jdd�ZHedd	d=�jdd�ZIe
  93  dd>d�jdd�ZJe
  94  dd?d�jdd�ZKe
  95  dd@d�jdd�ZLe
  96  d�jdd�ZMe dAdBd�jdd�ZNe ddCd�jdd�ZOegdD�dEdFd�jdd�ZPe
  97  ddGd�jdd�ZQeRdH�jdd�ZSeRd�jdd�ZTeRd�jdd�ZUe
  98  d�jdd�ZVe#dIdJdKd�jdd�ZWe'dLdd#�ZXe'dMdd#�ZYe'dN�ZZe'dO�Z[e'dPdd#�Z\e'dQdd#�Z]e'dRdd#�Z^e'dS�Z_e'dTdd#�Z`eBdUdV��Zaeb�ZcdZde
  99  ddWd�Zee'dXdYddZ�Zf			[�dq�fd\d]�	Zgd^d_�Zhe5d`�dadb��Zi�drdcdd�Zjdedf�Zkdgdh�Zldidj�Zmdkdl�Zndmdn�Zododp�Zpe5dq��drdrds��Zqdtdu�Zrdvdw�Zsdxdy�Ztdzd{�Zud|d}�Zve5dq��drd~d��Zwd�d��Zxd�d��Zyd�d��Zzd�d��Z{d�d��Z|d�d��Z}e~d�efd�d���Z�d�d��Z�d�d��Z�d�d��Z�eBd�d���Z��drd�d��Z�d�d��Z��dsd�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�eBe�e�dd��Z��dtd�d��Z�dZ��dud�d��Z�eBd�d���Z��dud�d��Z�d�d��Z�d�d��Z�eBd�d���Z��dvd�d��Z��dtd�d��Z��drd�d„Z��dwd�dĄZ�d�dƄZ�e~d�e�d�e�e�e�e�ffd�dʄ�Z�	�drd�e�d�e�e�e�e�e�fd�e�fd�d̈́Z�e~d�dτ�Z��drd�e�fd�dфZ��drd�e�fd�dӄZ��dxd�dՄZ��dxd�dׄZ��dyd�dلZ�d�dۄZ�e�Z�d�d݄Z�d�d߄Z�d�d�Z��drd�d�Z�d�d�Z��drd�d�Z�		�dzd�d�Z�d�e�fd�d�Z��d{d�d�Z�d�d��Z�e��dtd�d��Z�d�d�Z�d�d��Z�e��dud�d���Z��dx�d|d�d��Z��drd�d��Z�d�d��Z�eà�e�j�jǡ�d}�d�d��ZȐde�f�d�d�Zɐd~�de�d�e�f�d�d�Zʐd�d�Zːd	�d
 100  �Z̐d�d�Z͐d
 101  �d�Zΐd�d�d�Zϐd�d�ZŐd�d�ZАd�d�Zѐd�d�Z�e�ZӐd��d�d�ZԐd�d�ZՐd�d�Z֐d�d �Zאd!�d"�Zؐd#�d$�Zِd%�d&�Zڐd'�d(�Zېd)�d*�Zܐd+�d,�Zݐd-�d.�Z�ddd�d/��d0�d1�Zߐd��d2�d3�Z��d4�d5�Z�				�d��d6�d7�Z�d8e��d9e��d:e��d;e��d<e�d�e�f�d=�d>�Z�dd�d?��d8e�d�e�f�d@�dA�Z�			�d�ddd�dB��d8e��dCe�e��dDe�e�d�e�f�dE�dF�Z�dG�dH�Z�dI�dJ�Z�dEe�df�dKe�e��dLe�f�dM�dN�Z�drd�dO��dP�dQ�Z�e�Z�dRe�d�e�e�e�ff�dS�dT�Z�dZ�e�e�e
 102  �dU<�dr�dV�dW�Z�dr�dX�dY�Z�d��dZ�d[�Z�d	e�f�d\�d]�Z��d��d_�d`�Z��du�da�db�Z��dc�dd�Z��dt�de�df�Z��d��dg�dh�Z��di�dj�Z��dk�dl�Z��dm�dn�Z��do�dp�Z��Z�S(��InteractiveShellz*An enhanced, interactive shell for Python.Nz�
 103          A list of ast.NodeTransformer subclass instances, which will be applied
 104          to user input before code is run.
 105          )�helpT)�config�ast_transformers)rr{rra�
 106          Make IPython automatically call any callable object even if you didn't
 107          type explicit parentheses. For example, 'str 43' becomes 'str(43)'
 108          automatically. The value can be '0' to disable the feature, '1' for
 109          'smart' autocall, where it is not applied if there are no more
 110          arguments on the line, and '2' for 'full' autocall, where all callable
 111          objects are automatically called (even if no arguments are present).
 112          )�
 113  default_valuer�z@
 114          Autoindent IPython code entered interactively.
 115          zJ
 116          Automatically run await statement in the top level repl.
 117          F)�asyncioZcurioZtrioZsync�-IPython.core.interactiveshell._asyncio_runnerzOSelect the loop runner that will be used to execute top-level asynchronous code)r��
 118  allow_noner��loop_runnercCstd�S)Nr�r6r�rrr�_default_loop_runnerv�z%InteractiveShell._default_loop_runnercCsht|jt�r(|j|jvr|j|j\}}||_|St|j�}t|�s&td��|St|j�s1td��|jS)Nzloop_runner must be callable)�
 119  isinstancer$�str�loop_runner_map�	autoawaitr7�callabler�)rZproposal�runnerr�rrr�_import_runnerzs
 120  
 121  zInteractiveShell._import_runnerzK
 122          Enable magic commands to be called without the leading %.
 123          z7The part of the banner to be printed before the profiler�z6The part of the banner to be printed after the profilei�a�
 124          Set the size of the output cache.  The default is 1000, you can
 125          change it permanently in your config file.  Setting it to 0 completely
 126          disables the caching system, and the minimum value accepted is 3 (if
 127          you provide a value less than 3, it is reset to 0 and a warning is
 128          issued).  This limit is defined because otherwise you'll spend more
 129          time re-flushing a too small cache than working
 130          z�
 131          Use colors for displaying information about objects. Because this
 132          information is passed through a pager (like 'less'), and some pagers
 133          get confused with color codes, this capability can be turned off.
 134          )�Neutral�NoColorZLightBG�Linuxr�z;Set the color scheme (NoColor, Neutral, Linux, or LightBG).z?Don't call post-execute functions that have failed in the past.)r�z/Class to use to instantiate the shell inspectorzm
 135          Enables rich html representation of docstrings. (This requires the
 136          docrepr module).
 137          rrcC�|drtdt�dSdS)N�newz[`sphinxify_docstring` is provisional since IPython 5.0 and might change in future versions.�rrw�rZchangerrr�_sphinxify_docstring_changed���z-InteractiveShell._sphinxify_docstring_changedzg
 138          (Provisional API) enables html representation in mime bundles sent
 139          to pagers.
 140          �enable_html_pagercCr�)Nr�zY`enable_html_pager` is provisional since IPython 5.0 and might change in future versions.r�r�rrr�_enable_html_pager_changed�r�z+InteractiveShell._enable_html_pager_changed�exitercCst|�Srr?r�rrr�_exiter_default�r�z InteractiveShell._exiter_defaultr{z<ipython console>z1IPython.core.inputtransformer2.TransformerManagerrcC�|jjSr)�input_transformer_managerZcleanup_transformsr�rrr�input_transformers_cleanup�r�z+InteractiveShell.input_transformers_cleanupz]A list of string input transformers, to be applied after IPython's own input transformations.�input_transformers_postcCs ddlm}|dtdd�|jS)z�Make this available for backward compatibility (pre-7.0 release) with existing code.
 141  
 142          For example, ipykernel ipykernel currently uses
 143          `shell.input_splitter.check_complete`
 144          rr
 145  zU`input_splitter` is deprecated since IPython 7.0, prefer `input_transformer_manager`.rr)�warningsr�DeprecationWarningr�)rrrrr�input_splitter�s
 146  �zInteractiveShell.input_splitterz�
 147          Start logging to the default log file in overwrite mode.
 148          Use `logappend` to specify a log file to **append** logs to.
 149          z1
 150          The name of the logfile to use.
 151          z�
 152          Start logging to the given file in append mode.
 153          Use `logfile` to specify a log file to **overwrite** logs to.
 154          )r�zL
 155          Automatically call the pdb debugger after every exception.
 156          zhIf True, anything that would be passed to the pager
 157          will be displayed as regular output instead.z(Show rewritten input, e.g. for autocall.i'zTotal length of command historyzn
 158          The number of saved history entries to be loaded
 159          into the history buffer at startup.
 160          )�all�last�	last_expr�none�last_expr_or_assignr�z�
 161          'all', 'last', 'last_expr' or 'none', 'last_expr_or_assign' specifying
 162          which nodes should be run interactively (displaying output from expressions).
 163          ztWarn if running in a virtual environment with no IPython installed (so IPython from the global environment is used).r�)�Context�Plain�VerboseZMinimalr�z0Switch modes for the IPython exception handlers.zIPython.core.alias.AliasManagerz'IPython.core.prefilter.PrefilterManagerz%IPython.core.builtin_trap.BuiltinTrapz%IPython.core.display_trap.DisplayTrapz(IPython.core.extensions.ExtensionManagerz#IPython.core.payload.PayloadManagerz(IPython.core.history.HistoryAccessorBasez IPython.core.magic.MagicsManagerz#IPython.core.application.ProfileDircCs*|jdurtj�|jj�}|�dd�SdS)NZprofile_r�)�profile_dir�osr�basename�locationr�r�rrr�profileLs
 164  �zInteractiveShell.profilez#Did last executed command succeededz-IPython.core.interactiveshell.ExecutionResultz$Result of executing the last command)r�r��rNcs�tt|�jdi|��d|jvrtd�|g|_|�|�|�|�|��|�	�|�
 165  �|�||�|��|�
 166  �ttj�|jjd��|_|��|��|��|��|��|��|��|��|��|��|��t |_!|�"�|�#�|�$|�|�%�|�&�|�'�|�(�|�)�|�*�|�+�|�,�|�-�|�.�|�/�|j0�1d|�t2�3|j4�d|_5dS)NZ
 167  PromptManagerz|As of IPython 5.0 `PromptManager` config will have no effect and has been replaced by TerminalInteractiveShell.prompts_class�dbZshell_initializedr)6r�r�rr�r�
 168  configurables�init_ipython_dir�init_profile_dir�init_instance_attrs�init_environment�init_virtualenv�init_create_namespaces�save_sys_module_state�init_sys_modulesrr�r�joinr�r�r��init_history�
 169  init_encoding�init_prefilter�init_syntax_highlighting�
 170  init_hooks�init_events�init_pushd_popd_magic�init_user_ns�init_logger�
 171  init_builtins�init_inspector�inputZraw_input_original�init_completer�init_io�init_traceback_handlers�init_prompts�init_display_formatter�init_display_pub�
 172  init_data_pub�init_displayhook�init_magics�
 173  init_alias�
 174  init_logstart�init_pdb�init_extension_manager�init_payload�events�trigger�atexit�register�atexit_operations�trio_runner)r�ipython_dirr��user_module�user_ns�custom_exceptionsr�r�rrr]sT
 175  
 176  
 177  
 178  
 179  zInteractiveShell.__init__cCs|S)z.Return the currently running IPython instance.rr�rrr�get_ipython�r�zInteractiveShell.get_ipythonrcCst|d�dS)Nr�)r`r�rrr�_ipython_dir_changed��z%InteractiveShell._ipython_dir_changedcCs |dur|j|_dS||_dS)zSSet the autoindent flag.
 180  
 181          If called with no arguments, it acts as a toggle.N)�
 182  autoindent)rr$rrr�set_autoindent�s
 183  zInteractiveShell.set_autoindentcCr�r)r)r�trrrr�set_trio_runner�r�z InteractiveShell.set_trio_runnercCs|dur	||_dSt�|_dSr)rrW)rrrrrr��sz!InteractiveShell.init_ipython_dircCs&|dur	||_dSt�|jd�|_dS)Nr)r�rTZcreate_profile_dir_by_namer)rr�rrrr��s
 184  �z!InteractiveShell.init_profile_dircCs>d|_|��|_t�|_g|_g|_t��|_	d|_
 185  i|_dS)NFr)�more�compiler_class�compiler_�meta�	tempfiles�tempdirsr��getcwdZstarting_dirZindent_current_nsp�
 186  _post_executer�rrrr��s
 187  
 188  
 189  z$InteractiveShell.init_instance_attrscC�dS)z6Any changes we need to make to the user's environment.Nrr�rrrr��r�z!InteractiveShell.init_environmentcCs0z
 190  tjjpd|_WdStyd|_YdSw)N�ascii)�sys�stdin�encodingZstdin_encodingr�r�rrrr��s
 191  �zInteractiveShell.init_encoding�colorscs$tj|j|d�j��fdd�|_dS)N)�style�parentcs
 192  �|d�S)Nr�r)�src�Zpyformatrr�<lambda>s
 193  z;InteractiveShell.init_syntax_highlighting.<locals>.<lambda>)rY�Parserr3�formatZ
 194  pycolorize�r�changesrr7rr��sz)InteractiveShell.init_syntax_highlightingcCrrrr�rrr�
 195  refresh_styler�zInteractiveShell.refresh_stylecCst�|_g|_dSr)ra�home_dirZ	dir_stackr�rrrr	s
 196  z&InteractiveShell.init_pushd_popd_magiccCst|jddd�|_dS)Nzipython_log.py�rotate)ZlogfnameZlogmode)rPr>�loggerr�rrrrs�zInteractiveShell.init_loggercCsL|jr
 197  |�d|j�dS|jr|�d|j�dS|jr$|�d�dSdS)zIInitialize logging in case it was requested at the command line.
 198          zlogstart %s appendzlogstart %s�logstartN)�	logappendr8�logfilerAr�rrrrs�zInteractiveShell.init_logstartcCs$dtjd<ttjd<t|d�|_dS)NTZ__IPYTHON__rV)�shell)�builtin_mod�__dict__rVrA�builtin_trapr�rrrrs
 199  
 200  zInteractiveShell.init_builtinscCs|�tjtj|j|j�|_dSr)�inspector_classr9Z
 201  InspectColorsrYZANSICodeColorsr3�object_info_string_level�	inspectorr;rrrr(s
 202  �zInteractiveShell.init_inspectorcCrrrr�rrrr2szInteractiveShell.init_iocCsdt_dt_dt_dS)NzIn : z...: zOut: )r0�ps1Zps2Zps3r�rrrr
 203  7s
 204  zInteractiveShell.init_promptscC�t|d�|_|j�|j�dS�N)r5)rL�display_formatterr��appendr�rrrr>�z'InteractiveShell.init_display_formattercCs"|j||d�|_|j�|j�dS)N)r5rD)�display_pub_classZdisplay_pubr�rOr�rrrrBsz!InteractiveShell.init_display_pubcCs0|jsd|_dS|j|d�|_|j�|j�dSrM)�data_pub_classZdata_pubr�rOr�rrrr
 205  Fs
 206  zInteractiveShell.init_data_pubcCs4|j|||jd�|_|j�|j�t|jd�|_dS)N)r5rD�
 207  cache_size)�hook)�displayhook_classrS�displayhookr�rOrD�display_trapr�rrrrMs�z!InteractiveShell.init_displayhook�pcCsH|g}|��r"tt�|��}|��s|j|}|}|�|�|��s|S)a�Gets path links including all symlinks
 208  
 209          Examples
 210          --------
 211          In [1]: from IPython.core.interactiveshell import InteractiveShell
 212  
 213          In [2]: import sys, pathlib
 214  
 215          In [3]: paths = InteractiveShell.get_path_links(pathlib.Path(sys.executable))
 216  
 217          In [4]: len(paths) == len(set(paths))
 218          Out[4]: True
 219  
 220          In [5]: bool(paths)
 221          Out[5]: True
 222          )�
 223  is_symlinkrr��readlink�is_absoluter5rO)rX�paths�new_pathrrr�get_path_linksYs
 224  
 225  �zInteractiveShell.get_path_linksc
 226  shdtjvrdStjddkrtd�dSttj�}ttjd����|�|�}t�j	�dkrG�j	ddkrG�j	d}|dt�j	d	d���t
 227  �fd
 228  d�|D��rTdStjdkretttjdd
 229  d��}n6ttjdddd�}tj
 230  dd�}t�dtjd�}|r�tt|�j|����}|��r�|��}t|�j|�}|jr�td�ddl}	tj�d|�|	�|�dS)a�Add the current virtualenv to sys.path so the user can import modules from it.
 231          This isn't perfect: it doesn't use the Python interpreter with which the
 232          virtualenv was built, and it ignores the --no-site-packages option. A
 233          warning will appear suggesting the user installs IPython in the
 234          virtualenv, but for many cases, it probably works well enough.
 235  
 236          Adapted from code snippets online.
 237  
 238          http://blog.ufsoft.org/2009/1/29/ipython-and-virtualenv
 239          ZVIRTUAL_ENVNr�z=Virtual env path set to '', please check if this is intended.rr{Zcygdrivez:/rsc3s"�|]}�|jd��kVqdS)r{N)�parents�resolve)�.0rX�Zp_venvrr�	<genexpr>�s� z3InteractiveShell.init_virtualenv.<locals>.<genexpr>�win32�Libz
 240  site-packages�libzpython{}.{}z\bpy(?:thon)?([23])\.(\d+)\bzlAttempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.r)r��environrrr0�
 241  executabler`r^r��parts�any�platformr��version_info�re�searchr:�groups�exists�	warn_venv�siter�insert�
 242  addsitedir)
 243  rrXr\Z
 244  drive_nameZvirtual_envZvirtual_env_pathZp_verZre_mZpredicted_pathrrrrbrr�ts@
 245  
 246  
 247  
 248  
 249  ��z InteractiveShell.init_virtualenvcCs8tjtjtjtjd�|_|jj|_tj	�
 250  |jj�|_dS)zuSave the state of hooks in the sys module.
 251  
 252          This has to be called after self.user_module is created.
 253          )r1�stdout�stderr�
 254  excepthookN)r0r1rurvrw�_orig_sys_module_staterr(�_orig_sys_modules_main_name�modulesr�_orig_sys_modules_main_modr�rrrr��s�
 255  z&InteractiveShell.save_sys_module_statecCsXz|j��D]
 256  \}}tt||�qWn	tyYnw|jdur*|jtj|j<dSdS)z$Restore the state of the sys module.N)rx�items�setattrr0r�r{rzry)r�k�vrrr�restore_sys_module_state�s��
 257  �z)InteractiveShell.restore_sys_module_statecCs<|j}|jr|jdkr|d|j7}|jr|d|j7}|S)Nrz
 258  IPython profile: %s
 259  r�)�banner1r��banner2�r�bannerrrrr��szInteractiveShell.bannercCs|dur|j}tj�|�dSr)r�r0ru�writer�rrr�show_banner�szInteractiveShell.show_bannercCsZt�|_i|_tjj}|jD]}|�|t||�d�q|jr+|�dt	�
 260  t	j�d�dSdS)N�dZ
 261  show_in_pager�Z)r_�hooks�strdispatchers�IPython�core�__all__�set_hook�getattr�display_pager:Zas_hook)rr��	hook_namerrrr��s
 262  �zInteractiveShell.init_hooksr�c
 263  Cs"t�||�}|dur |j�|t��}|�|||�||j|<dS|dur=|j�|t��}|�t�|�||�||j|<dSt	|j
 264  |d�}|tjj
 265  j
 266  vrVtd|tjj
 267  j
 268  f�|tjj
 269  jvrltjj
 270  j|}	td�||	���|sttjj
 271  ��}z|�||�Wnty�|}Ynwt|j
 272  ||�dS)a	set_hook(name,hook) -> sets an internal IPython hook.
 273  
 274          IPython exposes some of its internal API as user-modifiable hooks.  By
 275          adding your function to one of these hooks, you can modify IPython's
 276          behavior to call at runtime your own routines.Nz#Warning! Hook '%s' is not one of %sz>Hook {} has been deprecated since IPython 5.0. Use {} instead.)�types�
 277  MethodTyper�rreZadd_sZadd_rermr(r�r�r�r�r��print�
 278  deprecatedr�r:ZCommandChainDispatcher�addr�r})
 279  rr�rT�priority�str_keyZre_key�fZsdpZdp�alternativerrrr��s>
 280  
 281  ����zInteractiveShell.set_hookcCs t|t�|_|j�d|j�dS)N�pre_execute)rIrJrr�_clear_warning_registryr�rrrr'szInteractiveShell.init_eventscC�td��)z�DEPRECATED: Use ip.events.register('post_run_cell', func)
 282  
 283          Register a function for calling after code execution.
 284          zpip.register_post_execute is deprecated since IPython 1.0, use ip.events.register('post_run_cell', func) instead.)r�)r�funcrrr�register_post_execute,s�z&InteractiveShell.register_post_executecCsd|jvr|jd=dSdS)N�__warningregistry__)�user_global_nsr�rrrr�6s
 285  �z(InteractiveShell._clear_warning_registrycCsjtj�|�}z|j|}Wnty"tj|dd�}|j|<Yn	w|j��||_	||_
 286  dd�|_|S)a�Return a new 'main' module object for user code execution.
 287  
 288          ``filename`` should be the path of the script which will be run in the
 289          module. Requests with the same filename will get the same module, with
 290          its namespace cleared.
 291  
 292          ``modname`` should be the module name - normally either '__main__' or
 293          the basename of the file without the extension.
 294  
 295          When scripts are executed via %run, we must keep a reference to their
 296          __main__ module around so that Python doesn't
 297          clear it, rendering references to module globals useless.
 298  
 299          This method keeps said reference in a private dict, keyed by the
 300          absolute path of the script. This way, for multiple executions of the
 301          same script we only keep one copy of the namespace (the last one),
 302          thus preventing memory leaks from old references while allowing the
 303          objects from the last execution to be accessible.
 304          z(Module created for script run in IPython��doccSr.�NTrrrrrr8csz/InteractiveShell.new_main_mod.<locals>.<lambda>)r�r�abspath�_main_mod_cache�KeyErrorr��
 305  ModuleTyperF�clearr(�__file__�__nonzero__)r�filename�modnameZmain_modrrr�new_main_modAs��
 306  
 307  zInteractiveShell.new_main_modcCs|j��dS)a�Clear the cache of main modules.
 308  
 309          Mainly for use by utilities like %reset.
 310  
 311          Examples
 312          --------
 313          In [15]: import IPython
 314  
 315          In [16]: m = _ip.new_main_mod(IPython.__file__, 'IPython')
 316  
 317          In [17]: len(_ip._main_mod_cache) > 0
 318          Out[17]: True
 319  
 320          In [18]: _ip.clear_main_mod_cache()
 321  
 322          In [19]: len(_ip._main_mod_cache) == 0
 323          Out[19]: True
 324          N)r�r�r�rrr�clear_main_mod_cachegsz%InteractiveShell.clear_main_mod_cachecCs|j|_dSr)�pdb�call_pdbr�rrrr�szInteractiveShell.init_pdbcCs|jSr)�	_call_pdbr�rrr�
 325  _get_call_pdb�szInteractiveShell._get_call_pdbcCs"|dvrtd��||_||j_dS)N)rr{FTz"new call_pdb value must be boolean)r�r��
 326  InteractiveTBr�)r�valrrr�
 327  _set_call_pdb�szInteractiveShell._set_call_pdbz,Control auto-activation of pdb at exceptionscCs6|s|jsdSttd�std�dS|jjdd�dS)a:Call the pdb debugger.
 328  
 329          Keywords:
 330  
 331            - force(False): by default, this routine checks the instance call_pdb
 332              flag and does not actually invoke the debugger if the flag is false.
 333              The 'force' option forces the debugger to activate even if the flag
 334              is false.
 335          N�last_tracebackz1No traceback has been produced, nothing to debug.T��force)r��hasattrr0rr��debugger)rr�rrrr��s
 336  
 337  zInteractiveShell.debuggercCsP|dus|durd|_|�||�\|_|_i|_i|_|jj|jtjd�|_dS)NF)Zuser_globalZ
 338  user_local�builtin)	�default_user_namespaces�prepare_user_modulerr�user_ns_hiddenr�rFrEZns_table�rrrrrrr��s%�z'InteractiveShell.init_create_namespacescCr�r)rrFr�rrrr��r�zInteractiveShell.user_global_nscCsp|dur|dur|�dd�t�}||_|durtjddd�}|j�dt�|j�dt�|dur4|j}||fS)a�Prepare the module and namespace in which user code will be run.
 339  
 340          When IPython is started normally, both parameters are None: a new module
 341          is created automatically, and its __dict__ used as the namespace.
 342  
 343          If only user_module is provided, its __dict__ is used as the namespace.
 344          If only user_ns is provided, a dummy module is created, and user_ns
 345          becomes the global namespace. If both are provided (as they may be
 346          when embedding), user_ns is the local namespace, and user_module
 347          provides the global namespace.
 348  
 349          Parameters
 350          ----------
 351          user_module : module, optional
 352              The current user module in which IPython is being run. If None,
 353              a clean module will be created.
 354          user_ns : dict, optional
 355              A namespace in which to run interactive commands.
 356  
 357          Returns
 358          -------
 359          A tuple of user_module and user_ns, each properly initialised.
 360          Nr(�__main__z@Automatically created module for IPython interactive environmentr��__builtin__�__builtins__)�
 361  setdefaultr�rFr�r�rEr�rrrr�s�z$InteractiveShell.prepare_user_modulecCs|jj}|jtj|<dSr)rr(r0rz)r�	main_namerrrr�-sz!InteractiveShell.init_sys_modulescCs�i}|jj|d<|jj|d<|jj|d<|jj|d<|jj|d<|j|d<|j|d<|j|d<t|d	<|j�|�|j	�|�d
 362  S)a�Initialize all user-visible namespaces to their minimum defaults.
 363  
 364          Certain history lists are also initialized here, as they effectively
 365          act as user namespaces.
 366  
 367          Notes
 368          -----
 369          All data structures here are only filled in, they are NOT reset by this
 370          method.  If they were not empty before, data will simply be added to
 371          them.
 372          Z_ihZ_ohZ_dh�InZOutr�exit�quitrN)
 373  �history_managerZinput_hist_parsed�output_histZdir_histrr�r�r��updater)r�nsrrrrAs
 374  
 375  
 376  zInteractiveShell.init_user_nscCs$|j|j|jgdd�|j��D�S)z�Get a list of references to all the namespace dictionaries in which
 377          IPython might store a user-created object.
 378  
 379          Note that this does not include the displayhook, which also caches
 380          objects from the output.cSsg|]}|j�qSr)rF)ra�mrrr�
 381  <listcomp>�sz0InteractiveShell.all_ns_refs.<locals>.<listcomp>)rr�r�r��valuesr�rrr�all_ns_refs|s�zInteractiveShell.all_ns_refscCsR|jdusJ�|j�|�|rd|_d|_d|_|jjr!|j��|j|j	ur,|j�
 382  �|j	}t|���}|�
 383  d�|�
 384  d�|�
 385  d�|D]}||=qF|j�
 386  �|��|rat|d�satd�n|r�td	�ttj���}||jD]}|�d
 387  �r{qstj|=qs|j��|j��tjdkr�dD]}||jjd
 388  vr�|j�||�q�|��dS)z�Clear all internal namespaces, and attempt to release references to
 389          user objects.
 390  
 391          If new_session is True, a new history session will be opened.
 392          Nr{Tr�r�r(�_sys_modules_keysz&Cannot restore sys.module, no snapshotzculling sys module...�multiprocessing�posix)r�r&�less�man�line)r��resetr��last_execution_succeeded�last_execution_resultrVZ
 393  do_full_cache�flushrr�r��set�keys�discardr�rr�r�r0rzr��
 394  startswith�
 395  alias_managerZ
 396  clear_aliasesZinit_aliasesr�r��magics_manager�magicsZsoft_define_aliasr�)r�new_sessionZ
 397  aggressiver�Z	drop_keysr~Zcurrent_keys�cmdrrrr��sH
 398  
 399  
 400  
 401  
 402  
 403  
 404  
 405  
 406  
 407  
 408  
 409  �zInteractiveShell.resetc
 410  s|dvr
 411  td|��|j}|r$|D]}z||=Wqty!YqwdSz|j|�Wnty>}ztd|�|�d}~ww|jdusFJ�|�|jj�|D]}�fdd�|��D�}|D]}||=q^qO|j	j
 412  �urnd|_	dD]}t|j|��ur�t
 413  |j|d�qpdS)a�Delete a variable from the various namespaces, so that, as
 414          far as possible, we're not keeping any hidden references to it.
 415  
 416          Parameters
 417          ----------
 418          varname : str
 419              The name of the variable to delete.
 420          by_name : bool
 421              If True, delete variables with the given name in each
 422              namespace. If False (default), find the variable in the user
 423              namespace, and delete references to it.
 424          )r�r�zRefusing to delete %szname '%s' is not definedNcsg|]
 425  \}}|�ur|�qSrr)ra�n�o�r�rrr��sz,InteractiveShell.del_var.<locals>.<listcomp>)�_�__Z___)r�r�r�r�	NameErrorr�rOr�r|r�r�r�rVr})r�varnameZby_nameZns_refsr��eZ	to_deleter�rr�r�del_var�s>
 426  
 427  �������zInteractiveShell.del_varc
 428  Csh|dur0zt�|�}Wnty}ztd�|�d}~ww|jD]}|D]
 429  }|�|�r.||=q$q dSdS)aDClear selective variables from internal namespaces based on a
 430          specified regular expression.
 431  
 432          Parameters
 433          ----------
 434          regex : string or compiled pattern, optional
 435              A regular expression pattern that will be used in searching
 436              variable names in the users namespaces.
 437          Nz*regex must be a string or compiled pattern)rmr(r�r�rn)r�regexr�r�r��varrrr�reset_selective�s
 438  
 439  ��
 440  
 441  ���z InteractiveShell.reset_selectivecCs�d}t|t�r
 442  |}n@t|tttf�rFt|t�r|��}n|}i}t�d�}|D]}zt||j	|j
 443  �||<Wq'td||jj
 444  f�Yq'ntd��|j�|�|j}|rb|D]}|�|d�qWdS|�|�dS)a�Inject a group of variables into the IPython user namespace.
 445  
 446          Parameters
 447          ----------
 448          variables : dict, str or list/tuple of str
 449              The variables to inject into the user's namespace.  If a dict, a
 450              simple update is done.  If a str, the string is assumed to have
 451              variable names separated by spaces.  A list/tuple of str can also
 452              be used to give the variable names.  If just the variable names are
 453              give (list/tuple/str) then the variable values looked up in the
 454              callers frame.
 455          interactive : bool
 456              If True (default), the variables will be listed with the ``who``
 457              magic.
 458          Nr{z!Could not get variable %s from %sz'variables must be a dict/str/list/tuple)r��dictr��list�tuple�splitr0�	_getframe�eval�	f_globals�f_localsr��f_code�co_namer�rr�r��pop)r�	variables�interactiveZvdict�vlist�cfr�r�rrr�push
 459  s2
 460  
 461  
 462  
 463  
 464  
 465  ���zInteractiveShell.pushcCsD|��D]\}}||jvr|j||ur|j|=|j�|d�qdS)a�Remove a dict of variables from the user namespace, if they are the
 466          same as the values in the dictionary.
 467  
 468          This is intended for use by extensions: variables that they've added can
 469          be taken back out if they are unloaded, without removing any that the
 470          user has overwritten.
 471  
 472          Parameters
 473          ----------
 474          variables : dict
 475              A dictionary mapping object names (as strings) to the objects.
 476          N)r|rr�r�)rr�r�r�rrr�
 477  drop_by_id:s
 478  ��zInteractiveShell.drop_by_id�oname�returncCs�|�d�}g}d}|D]J}|�d�rJ|�d�^}}|��s$d}||fS|�|�|D]}|ddkr?t|dd��s?d}n
 479  |�|dd��q+q|��sPd}|�|�q||fS)a�
 480          Given an object name, return a list of parts of this object name.
 481  
 482          Basically split on docs when using attribute access,
 483          and extract the value when using square bracket.
 484  
 485  
 486          For example foo.bar[3].baz[x] -> foo, bar, 3, baz, x
 487  
 488  
 489          Returns
 490          -------
 491          parts_ok: bool
 492              whether we were properly able to parse parts.
 493          parts: list of str
 494              extracted parts
 495  
 496  
 497  
 498          �.T�]�[F�����N)r��endswith�isidentifierrOr�)rZ	raw_partsri�parts_okrXr��indices�indrrr�_find_partsOs*
 499  
 500  
 501  �zInteractiveShell._find_parts�
 502  namespacesc	Cs�|��}|�|�\}}|�t�s!|�t�s!|s!tddddddd�S|dur3d|jfd|jfdtj	fg}d}d}d}d}d}	d}
 503  |}|d|dd�}}
 504  |D]L\}}z||}
 505  Wn	t
 506  yaYqNwt|
 507  �D]-\}}z#|
 508  }	|t|
 509  �dkr||�
 510  |
 511  |�}
 512  nt|�r�|
 513  t|�}
 514  nt|
 515  |�}
 516  WqfYnd	}|}nqN|s�d}
 517  |�t�r�|�t�}|�|�}
 518  n|�t�r�|�t�}|�|�}
 519  n|�|�}
 520  |
 521  dur�|�|�}
 522  |
 523  dur�d	}d
 524  }d	}t|
 525  t�}|s�|dvr�t|�}
 526  d	}d}t|
 527  ||	|||d�S)
 528  aFind an object in the available namespaces.
 529  
 530  
 531          Returns
 532          -------
 533          OInfo with fields:
 534            - ismagic
 535            - isalias
 536            - found
 537            - obj
 538            - namespac
 539            - parent
 540  
 541          Has special code to detect magic functions.
 542          FN)�ismagic�isalias�foundr��	namespacer5�InteractivezInteractive (global)zPython builtinrr{TzIPython internal)z''z""z[]z{}z())r�rr5rrr)�striprr�rNrOrkrr�rErFr��	enumerater��_getattr_propertyr�r�r��lstrip�find_cell_magic�find_line_magicr�r=r�)rrr
 543  r	rirrrZospacer5r�Zoname_partsZ
 544  oname_headZ
 545  oname_restZnsnamer��idx�partrrr�_ofind|s�����	��
 546  ��
 547  
 548  
 549  
 550  
 551  
 552  
 553  �zInteractiveShell._ofindcCs^t|t�s*zt|�r|t|�WStt|�|�}Wn	ty"Ynwt|t�r*|St||�S)z�Property-aware getattr to use in object finding.
 554  
 555          If attrname represents a property, return it unevaluated (in case it has
 556          side effects or raises an error.
 557  
 558          )r��typer�r�r�r�r�)r��attrname�attrrrrr�s
 559  �
 560  
 561  z"InteractiveShell._getattr_propertycCs|�||�S)z6Find an object and return a struct with info about it.)r)rrr
 562  rrr�_object_find szInteractiveShell._object_findc	Ks�|�||�}|jrtdurtd��t|�|��}nd}|js%t|jtj	�r\t
 563  |j|�}|jr0t
 564  n|}|dkr?||j||�dS|dkrT||j|||fd|ji|��dS||j|�dStd|�dS)zyGeneric interface to the inspector system.
 565  
 566          This function is meant to be called by pdef, pdoc & friends.
 567          Nz'Module ``docrepr`` required but missingZpdocZpinfor�zObject `%s` not found.z	not found)rrrrl�ImportError�object_inspectrr�r5r9Z	HOOK_NAMEr�rJrrjr�r�r�)	r�methrr
 568  r�r��	docformatZpmethod�	formatterrrr�_inspect$s2��
 569  �	zInteractiveShell._inspectcCsl|j�)|�|�}|jr|jj|j|||d�Wd�Stj|dd�Wd�S1s/wYdS)zGet object info about oname)r��detail_levelNF)r�r)rGrrrJr�r�r9�object_info)rrr&r�rrrr!Fs
 570  ��$�zInteractiveShell.object_inspectcCs|�||�dS)z!Get object info as formatted textrm)�object_inspect_mime)rrr&rrr�object_inspect_textQr!z$InteractiveShell.object_inspect_textc	Cst|j�-|�|�}|jr,|jrt|�|��nd}|jj|j|||||d�Wd�St	|��1s3wYdS)z�Get object info as a mimebundle of formatted representations.
 571  
 572          A mimebundle is a dictionary, keyed by mime-type.
 573          It must always have the key `'text/plain'`.
 574          N)r�r&r$�
 575  omit_sections)
 576  rGrrrrrlr!rJZ	_get_infor�r�)rrr&r*r�r#rrrr(Us$
 577  �����z$InteractiveShell.object_inspect_mimecCs t||d�|_|j�|j�dS)z:Sets up the command history, and starts regular autosaves.�rDr5N)rMr�r�rOr�rrrr�rszInteractiveShell.init_historycCsNtjd|d�|_tjddd|j|d�|_tj|_|j|�|jj	|j
 578  d�dS)Nr�)�color_schemer5r�r{)�moder,�	tb_offset�debugger_clsr5)r-)r<�SyntaxTBZAutoFormattedTBr/r�r0rw�sys_excepthook�set_custom_exc�set_mode�xmode)rrrrrr	}s�
 579  z(InteractiveShell.init_traceback_handlerscsZt|t�s	td��d	dd�}dd���dur|}nd	��fdd�	}t�||�|_||_dS)
 580  a�set_custom_exc(exc_tuple, handler)
 581  
 582          Set a custom exception handler, which will be called if any of the
 583          exceptions in exc_tuple occur in the mainloop (specifically, in the
 584          run_code() method).
 585  
 586          Parameters
 587          ----------
 588          exc_tuple : tuple of exception classes
 589              A *tuple* of exception classes, for which to call the defined
 590              handler.  It is very important that you use a tuple, and NOT A
 591              LIST here, because of the way Python's except statement works.  If
 592              you only want to trap a single exception, use a singleton tuple::
 593  
 594                  exc_tuple == (MyCustomException,)
 595  
 596          handler : callable
 597              handler must have the following signature::
 598  
 599                  def my_handler(self, etype, value, tb, tb_offset=None):
 600                      ...
 601                      return structured_traceback
 602  
 603              Your handler must return a structured traceback (a list of strings),
 604              or None.
 605  
 606              This will be made into an instance method (via types.MethodType)
 607              of IPython itself, and it will be called if any of the exceptions
 608              listed in the exc_tuple are caught. If the handler is None, an
 609              internal basic one is used, which just prints basic info.
 610  
 611              To protect IPython from crashes, if your handler ever raises an
 612              exception or returns an invalid result, it will be immediately
 613              disabled.
 614  
 615          Notes
 616          -----
 617          WARNING: by putting in your own exception handler into IPython's main
 618          execution loop, you run a very good chance of nasty crashes.  This
 619          facility should only be used if you really know what you are doing.
 620          z/The custom exceptions must be given as a tuple.NcSs*td�td|�td|�td|�dS)Nz'*** Simple custom exception handler ***zException type :zException value:zTraceback      :)r�)r�etyper$�tbr.rrr�
 621  dummy_handler�s
 622  
 623  z6InteractiveShell.set_custom_exc.<locals>.dummy_handlercSsVd|}|dur
 624  gSt|t�r|gSt|t�st|��|D]}t|t�s(t|��q|S)a?validate structured traceback return type
 625  
 626              return type of CustomTB *should* be a list of strings, but allow
 627              single strings or None, which are harmless.
 628  
 629              This function will *always* return a list of strings,
 630              and will raise a TypeError if stb is inappropriate.
 631              z,CustomTB must return list of strings, not %rN)r�r�r�r�)�stb�msgr�rrr�validate_stb�s	
 632  
 633  
 634  �z5InteractiveShell.set_custom_exc.<locals>.validate_stbc	s�z�|||||d�}�|�WS|�dd�tdtjd�|jjt���}t|j�|��td�|jj||||d�}Y|S)z�wrap CustomTB handler, to protect IPython from user code
 635  
 636                  This makes it harder (but not impossible) for custom exception
 637                  handlers to crash IPython.
 638                  �r.rNz'Custom TB Handler failed, unregistering�r�zThe original exception:)r2r�r0rvr��structured_traceback�exc_info�stb2text)rr5r$r6r.r8��handlerr:rr�wrapped�s
 639  �z0InteractiveShell.set_custom_exc.<locals>.wrappedr)r�r�r�r�r��CustomTBr)r�	exc_tuplerAr7rBrr@rr2�s
 640  +
 641  
 642  zInteractiveShell.set_custom_exccCs|j|||fdd�dS)aTOne more defense for GUI apps that call sys.excepthook.
 643  
 644          GUI frameworks like wxPython trap exceptions and call
 645          sys.excepthook themselves.  I guess this is a feature that
 646          enables them to keep running after exceptions that would
 647          otherwise kill their mainloop. This is a bother for IPython
 648          which expects to catch all of the program exceptions with a try:
 649          except: statement.
 650  
 651          Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
 652          any app directly invokes sys.excepthook, it will look to the user like
 653          IPython crashed.  In order to work around this, we can disable the
 654          CrashHandler and replace it with this excepthook instead, which prints a
 655          regular traceback using our InteractiveTB.  In this fashion, apps which
 656          call sys.excepthook will generate a regular-looking exception from
 657          IPython, and the CrashHandler will only be triggered by real IPython
 658          crashes.
 659  
 660          This hook should be used sparingly, only in places which are not likely
 661          to be true IPython errors.
 662          rr;N)�
 663  showtraceback)rr5r$r6rrrrw�szInteractiveShell.excepthookcCs�|durt��\}}}n|\}}}|dur%ttd�r%tjtjtj}}}|dur-td��|t_|t_|t_tjdkr>|t_|||fS)z�get exc_info from a given tuple, sys.exc_info() or sys.last_type etc.
 664  
 665          Ensures sys.last_type,value,traceback hold the exc_info we found,
 666          from whichever source.
 667  
 668          raises ValueError if none of these contain any information
 669          N�	last_typezNo exception to find)rs�)	r0r>r�rF�
 670  last_valuer�r�rl�last_exc)rrDr5r$r6rrr�
 671  _get_exc_infos 
 672  
 673  
 674  �
 675  
 676  zInteractiveShell._get_exc_infocCstd|tjd�dS)ztShow a short message for UsageErrors
 677  
 678          These are special exceptions that shouldn't show a traceback.
 679          zUsageError: %sr<N)r�r0rv)r�excrrr�show_usage_error5sz!InteractiveShell.show_usage_errorcCs&|�|�\}}}t�||�}d�|�S)z}
 680          Return as a string (ending with a newline) the exception that
 681          just occurred, without any traceback.
 682          r�)rJ�	traceback�format_exception_onlyr�)rrDr5r$r6r9rrr�get_exception_only<s
 683  z#InteractiveShell.get_exception_onlyc
 684  sfz�z
 685  |�|�\}}}Wntytdtjd�YWdSwt|t�r,|�||�WdS|tur8|�	|�WdS|rHdg}	|	�
 686  |j�||��nL�fdd���|�rWt
 687  ��n1zt|d�rb|��}	n
 688  |jj||||d�}	Wnty�td	�t
 689  ��YWdSw|�|||	�|jr�|jd
 690  d�WdS|�|||	�WdSty�td|��tjd�YdSw)
 691  aDisplay the exception that just occurred.
 692  
 693          If nothing is known about the exception, this is the method which
 694          should be used throughout the code for presenting user tracebacks,
 695          rather than directly invoking the InteractiveTB object.
 696  
 697          A specific showsyntaxerror() also exists, but this method can take
 698          care of calling it if needed, so unless you are explicitly catching a
 699          SyntaxError exception, don't try to analyze the stack manually and
 700          simply call this method.zNo traceback available to show.r<Nz>An exception has occurred, use %tb to see the full traceback.
 701  cs |durdSt|t�p�|j�S�NF)r�ru�__context__)r���contains_exceptiongrouprrrSgs��z?InteractiveShell.showtraceback.<locals>.contains_exceptiongroup�_render_traceback_r;zMUnexpected exception formatting exception. Falling back to standard exceptionTr�r�)rJr�r�r0rv�
 702  issubclass�SyntaxError�showsyntaxerrorrHrL�extendr�rOrM�	print_excr�rTr=�	Exception�_showtracebackr�r��KeyboardInterrupt)
 703  rrDr�r.�exception_only�running_compiled_coder5r$r6r8rrRrrEEsR
 704  �
 705  �
 706  
 707  
 708  �����zInteractiveShell.showtracebackr8cCsD|j�|�}zt|�WdSty!t|�dd����YdSw)z�Actually show a traceback.
 709  
 710          Subclasses may override this method to put the traceback on a different
 711          place, like a side channel.
 712          �utf-8�backslashreplaceN)r�r?r��UnicodeEncodeError�encode�decode)rr5�evaluer8r�rrrr[�s�zInteractiveShell._showtracebackcCsd|��\}}}|rt|t�rz||_WnY|rt�|�ng}|j�|||�}|�|||�dS)a�Display the syntax error that just occurred.
 713  
 714          This doesn't display a stack trace because there isn't one.
 715  
 716          If a filename is given, it is stuffed in the exception instead
 717          of what was there before (because Python's parser always uses
 718          "<string>" when reading from a string).
 719  
 720          If the syntax error occurred when running a compiled code (i.e. running_compile_code=True),
 721          longer stack trace will be displayed.
 722          N)	rJrUrVr�rM�
 723  extract_tbr0r=r[)rr�r^r5r$r�Zelistr8rrrrW�s
 724  z InteractiveShell.showsyntaxerrorcCs|��dS)z�Called by _run_cell when there's an IndentationError in code entered
 725          at the prompt.
 726  
 727          This is overridden in TerminalInteractiveShell to show a message about
 728          the %paste magic.N)rWr�rrr�showindentationerror�sz%InteractiveShell.showindentationerrorcCs
 729  ||_dS)z� Sets the 'default' input string for the next command line.
 730  
 731          Example::
 732  
 733              In [1]: _ip.set_next_input("Hello Word")
 734              In [2]: Hello Word_  # cursor is here
 735          N)Z
 736  rl_next_input)rr�r�rrr�set_next_input�s
 737  	zInteractiveShell.set_next_inputcCs|j��dS)z3return the current level of indentation as a string� )r�Zget_indent_spacesr�rrr�_indent_current_str�sz$InteractiveShell._indent_current_strcCs�ddlm}ddlm}m}m}m}|||j|j|d�|_	|j
 738  �|j	�|j�
 739  dt��}||jd<||j	_|jd|dd�|jd|dd�|jd|d	d�|jd|d
 740  d�|jd|dd�|jd|dd�d
 741  S)aNInitialize the completion machinery.
 742  
 743          This creates completion machinery that can be used by client code,
 744          either interactively in-process (typically triggered by the readline
 745          library), programmatically (such as in test suites) or out-of-process
 746          (typically over the network by remote frontends).
 747          r)�IPCompleter)�cd_completer�magic_run_completer�module_completer�reset_completer)rDr�global_namespacer5Zcomplete_command�import)r��fromz%aimportz%runz%cdz%resetN)ZIPython.core.completerrjZIPython.core.completerlibrkrlrmrnrr��	Completerr�rOr�rreZcustom_completersr�)rrjrkrlrmrnZsdisprrrr�s"�
 748  zInteractiveShell.init_completercCs:|j�|j�|||�Wd�S1swYdS)aReturn the completed text and a list of completions.
 749  
 750          Parameters
 751          ----------
 752          text : string
 753              A string of text to be completed on.  It can be given as empty and
 754              instead a line/position pair are given.  In this case, the
 755              completer itself will split the line like readline does.
 756          line : string, optional
 757              The complete line that text is part of.
 758          cursor_pos : int, optional
 759              The position of the cursor on the input line.
 760  
 761          Returns
 762          -------
 763          text : string
 764              The actual text that was completed.
 765          matches : list
 766              A sorted list with all possible completions.
 767  
 768          Notes
 769          -----
 770          The optional arguments allow the completion to take more context into
 771          account, and are part of the low-level completion API.
 772  
 773          This is a wrapper around the completion mechanism, similar to what
 774          readline does at the command line when the TAB key is hit.  By
 775          exposing it as a method, it can be used by other non-readline
 776          environments (such as GUIs) for text completion.
 777  
 778          Examples
 779          --------
 780          In [1]: x = 'hello'
 781  
 782          In [2]: _ip.complete('x.l')
 783          Out[2]: ('x.l', ['x.ljust', 'x.lower', 'x.lstrip'])
 784          N)rGrr�complete)r�textr�Z
 785  cursor_posrrrrs�s)$�zInteractiveShell.completecCs"t�||j�}|jj�||�dS)a�Adds a new custom completer function.
 786  
 787          The position argument (defaults to 0) is the index in the completers
 788          list where you want the completer to be inserted.
 789  
 790          `completer` should have the following signature::
 791  
 792              def completion(self: Completer, text: string) -> List[str]:
 793                  raise NotImplementedError
 794  
 795          It will be bound to the current Completer instance and pass some text
 796          and return a list with current completions to suggest to the user.
 797          N)r�r�rrZcustom_matchersrs)rZ	completer�posZnewcomprrr�set_custom_completer#	sz%InteractiveShell.set_custom_completercCs4|r|j|j_|j|j_dS|j|j_|j|j_dS)zSet the frame of the completer.N)r�rrrr�rorr�)r�framerrr�set_completer_frame5	s
 798  
 799  
 800  z$InteractiveShell.set_completer_framecCs�ddlm}tj|||�|�d�|_|j�|j�|jj|_	|�	|j
 801  |j|j|j
 802  |j|j|j|j|j|j|j|j|j|j�|�	|j�|j}|�dd�|�dd�|�dd	�|�d
 803  dd�|�d
 804  dd�|�ddd�|�d|j�dS)Nr)r�)rDr5Zuser_magicsZedZedit�hist�history�repZrecallZSVG�svg�cell�HTML�htmlr�Z	writefiler3)�IPython.corer�r8�
 805  MagicsManagerZ
 806  UserMagicsr�r�rOrZregister_magicsZ
 807  AutoMagicsZBasicMagicsZ
 808  CodeMagicsZConfigMagicsZ
 809  DisplayMagics�ExecutionMagicsZExtensionMagicsZ
 810  HistoryMagicsZ
 811  LoggingMagicsZNamespaceMagicsZOSMagicsZPackagingMagicsZPylabMagicsZScriptMagicsZAsyncMagicsZregister_alias�run_line_magicr3)rr�ZmmanrrrrB	s,�
 812  �zInteractiveShell.init_magicsr�cCs|jj|||d�dS)N)�
 813  magic_kind�
 814  magic_name)r��register_function)rr�r�r�rrr�register_magic_functione	s
 815  �z(InteractiveShell.register_magic_functionr�cCsX|j|jd�|}||�}|dur|S|jj�|�}|dur dS|�d|�||�}|S)aT
 816          Try to find a magic potentially lazy-loading it.
 817  
 818          Parameters
 819          ----------
 820  
 821          type_: "line"|"cell"
 822              the type of magics we are trying to find/lazy load.
 823          magic_name: str
 824              The name of the magic we are trying to find/lazy load
 825  
 826  
 827          Note that this may have any side effects
 828          )r�r}N�load_ext)rrr��lazy_magicsrr�)r�type_r��finder�fn�lazy�resrrr�_find_with_lazy_loadk	sz%InteractiveShell._find_with_lazy_loadcCs|�d|�}|dur|jj�|�}|r|�d|�|�|�}|dur;|�|�}d}|dur/dnd|}t|||f��|}	t|t	j
 829  d�rG|}
 830  n|�||	�}
 831  |
 832  g}i}t|dd�r_|�|	�|d	<|j
 833  �||i|��}
 834  Wd�n1stwYt|t	jd�r�t�|
 835  �r�dS|
 836  S)
 837  a�Execute the given line magic.
 838  
 839          Parameters
 840          ----------
 841          magic_name : str
 842              Name of the desired magic function, without '%' prefix.
 843          line : str
 844              The rest of the input line as a single string.
 845          _stack_depth : int
 846              If run_line_magic() is called from magic() then _stack_depth=2.
 847              This is added to ensure backward compatibility for use of 'get_ipython().magic()'
 848          r�Nr�z'Line magic function `%%%s` not found%s.r�z= (But cell magic `%%%%%s` exists, did you mean that instead?)F�needs_local_scope�local_ns)r�r�r�rr�rrrHr�r8�MAGIC_NO_VAR_EXPAND_ATTR�
 849  var_expand�get_local_scoperG�MAGIC_OUTPUT_CAN_BE_SILENCEDrE�semicolon_at_end_of_expression)rr�r��_stack_depthr�r��cm�etpl�extra�stack_depth�magic_arg_sr�r�r�rrrr��	s8
 850  
 851  
 852  ��
 853  zInteractiveShell.run_line_magiccCst�|d�jS)z�Get local scope at given stack depth.
 854  
 855          Parameters
 856          ----------
 857          stack_depth : int
 858              Depth relative to calling frame
 859          r{)r0r�r�)rr�rrrr��	sz InteractiveShell.get_local_scopecCs|�d|�}|dur$|�|�}d}|durdnd�|�}t|�||���|dkr?d�|�}|�|�dur;|d�|�7}t|��d}	t|tjd	�rK|}
 860  n|�||	�}
 861  i}t|d
 862  d	�r^|j|d<|j	�|
 863  |f}||i|��}
 864  Wd�n1swwYt|tj
 865  d	�r�t�|�r�dS|
 866  S)aTExecute the given cell magic.
 867  
 868          Parameters
 869          ----------
 870          magic_name : str
 871              Name of the desired magic function, without '%' prefix.
 872          line : str
 873              The rest of the first input line as a single string.
 874          cell : str
 875              The body of the cell as a (possibly multiline) string.
 876          r}Nz Cell magic `%%{0}` not found{1}.r�z; (But line magic `%{0}` exists, did you mean that instead?)z2%%{0} is a cell magic, but the cell body is empty.z- Did you mean the line magic %{0} (single %)?rFr�r�)
 877  r�rr:rHr�r8r�r�rrGr�rEr�)rr�r�r}r�Zlmr�r��messager�r�r�r�r�rrr�run_cell_magic�	s8
 878  �
 879  
 880  �
 881  zInteractiveShell.run_cell_magiccC�|jjd�|�S)zUFind and return a line magic by name.
 882  
 883          Returns None if the magic isn't found.r��r�r�r�rr�rrrr�	�z InteractiveShell.find_line_magiccCr�)zUFind and return a cell magic by name.
 884  
 885          Returns None if the magic isn't found.r}r�r�rrrr
 886  r�z InteractiveShell.find_cell_magiccCs|jj|�|�S)zbFind and return a magic of the given type by name.
 887  
 888          Returns None if the magic isn't found.r�)rr�r�rrr�
 889  find_magic
 890  r�zInteractiveShell.find_magiccCs<tjdtdd�|�d�\}}}|�tj�}|j||dd�S)a�
 891          DEPRECATED
 892  
 893          Deprecated since IPython 0.13 (warning added in
 894          8.1), use run_line_magic(magic_name, parameter_s).
 895  
 896          Call a magic function by name.
 897  
 898          Input: a string containing the name of the magic function to call and
 899          any additional arguments to be passed to the magic.
 900  
 901          magic('name -opt foo bar') is equivalent to typing at the ipython
 902          prompt:
 903  
 904          In[1]: %name -opt foo bar
 905  
 906          To call a magic without arguments, simply use magic('name').
 907  
 908          This provides a proper Python function to call IPython's magics in any
 909          valid Python code you can type at the interpreter, including loops and
 910          compound statements.
 911          zr`magic(...)` is deprecated since IPython 0.13 (warning added in 8.1), use run_line_magic(magic_name, parameter_s).rrrh)r�)r�rr��	partitionrr;rNr�)rZarg_sr�r�r�rrrr8
 912  s�zInteractiveShell.magiccCsBddlm}t|t�r|�|�}t||j�std��||j|<dS)a#Define a new macro
 913  
 914          Parameters
 915          ----------
 916          name : str
 917              The name of the macro.
 918          themacro : str or Macro
 919              The action to do upon invoking the macro.  If a string, a new
 920              Macro object is created by passing the string to it.
 921          r)�macroz-A macro must be a string or a Macro instance.N)r�r�r�r�rQr�r)rr�Zthemacror�rrr�define_macro2
 922  s
 923  
 924  zInteractiveShell.define_macrocCs2|���d�rtd��t|j|dd��|jd<dS)a2Call the given cmd in a subprocess, piping stdout/err
 925  
 926          Parameters
 927          ----------
 928          cmd : str
 929              Command to execute (can not end in '&', as background processes are
 930              not supported.  Should not be a command that expects input
 931              other than simple text.
 932          �&�#Background processes not supported.r{��depth�
 933  _exit_codeN)�rstripr�OSErrorrdr�r�rr�rrr�system_pipedJ
 934  s
 935  zInteractiveShell.system_pipedc	CsB|j|dd�}|dkrd}n|��d}d}||vr"t�d�|��tjdkriddlm}|��0}|d	ur;d
 936  ||f}zt	�
 937  |�}WntyXtd|�
 938  �tjd�d
 939  }YnwWd	�n1scwYn1t	j�dd	�}z
 940  tj|d|d�}Wnty�td|�
 941  �tjd�d}Ynw|dkr�|d}||jd<d	S)z�Call the given cmd in a subprocess using os.system on Windows or
 942          subprocess.call using the system shell on other platforms.
 943  
 944          Parameters
 945          ----------
 946          cmd : str
 947              Command to execute.
 948          r{r�r�r)�pipZconda�cdzhYou executed the system command !{0} which may not work as expected. Try the IPython magic %{0} instead.rd)�AvoidUNCPathNz"pushd %s &&"%sr�r<������SHELLT)rDrh��r�)r�r�r�rr:r0rkZIPython.utils._process_win32r�r�rdr\r�rOrvrgr�
 949  subprocess�callr)rr�Zmain_cmdZhas_magic_alternativesr�r�ecrhrrr�
 950  system_rawa
 951  sD	�
 952  �����
 953  zInteractiveShell.system_rawcCsL|���d�rtd��t|j||dd��}|r t|���}|St|�}|S)a[Get output (possibly including stderr) from a subprocess.
 954  
 955          Parameters
 956          ----------
 957          cmd : str
 958              Command to execute (can not end in '&', as background processes are
 959              not supported.
 960          split : bool, optional
 961              If True, split the output into an IPython SList.  Otherwise, an
 962              IPython LSString is returned.  These are objects similar to normal
 963              lists and strings, with a few convenience attributes for easier
 964              manipulation of line-based output.  You can use '?' on them for
 965              details.
 966          depth : int, optional
 967              How many frames above the caller are the local variables which should
 968              be expanded in the command string? The default (0) assumes that the
 969              expansion variables are in the stack frame calling this function.
 970          r�r�r{r�)r�rr�rcr�ri�
 971  splitlinesrh)rr�r�r��outrrrrc�
 972  s�zInteractiveShell.getoutputcC� t||d�|_|j�|j�dS�Nr+)r>r�r�rOr�rrrr�
 973  �zInteractiveShell.init_aliascCr�r�)rK�extension_managerr�rOr�rrrr�
 974  r�z'InteractiveShell.init_extension_managercCrLrM)rR�payload_managerr�rOr�rrrr�
 975  rPzInteractiveShell.init_payloadcCs*t||d�|_|j�|j�|jj|_dSr�)rS�prefilter_managerr�rO�prefilter_linesr;r�rrrr��
 976  szInteractiveShell.init_prefiltercCs|jsdStd|�dS)a�Print to the screen the rewritten form of the user's command.
 977  
 978          This shows visual feedback by rewriting input lines that cause
 979          automatic calling to kick in, like::
 980  
 981            /f x
 982  
 983          into::
 984  
 985            ------> f(x)
 986  
 987          after the user's input prompt.  This helps the user understand that the
 988          input line was transformed automatically by IPython.
 989          Nz------> )�show_rewritten_inputr�r�rrr�auto_rewrite_input�
 990  sz#InteractiveShell.auto_rewrite_inputcCs6|��\}}}|j�||�}d||jt�|�d�}|S)zJreturn simple exception dict
 991  
 992          for use in user_expressions
 993          r)�statusrMZenamerd)rJr�rOr(r\Zsafe_unicode)rr5rdr6r8r>rrr�_user_obj_error�
 994  s�z InteractiveShell._user_obj_errorcCs |j�|�\}}d||d�}|S)zRformat a user object to display dict
 995  
 996          for use in user_expressions
 997          �ok)r��data�metadata)rNr:)rr�r��mdr$rrr�_format_user_objs�z!InteractiveShell._format_user_objcCsVi}|j}|j}|��D]\}}z|�t|||��}Wn|��}Y|||<q|S)a�Evaluate a dict of expressions in the user's namespace.
 998  
 999          Parameters
1000          ----------
1001          expressions : dict
1002              A dict with string keys and string values.  The expression values
1003              should be valid Python expressions, each of which will be evaluated
1004              in the user namespace.
1005  
1006          Returns
1007          -------
1008          A dict, keyed like the input expressions dict, with the rich mime-typed
1009          display_data of each value.
1010          )rr�r|r�r�r�)rZexpressionsr�r�	global_nsr�exprr$rrr�user_expressionss
1011  
1012  z!InteractiveShell.user_expressionscCs<|j�t||j|j�Wd�dS1swYdS)z4Execute a normal python statement in user namespace.N)rG�execr�rr�rrr�ex=s"�zInteractiveShell.excCs:|j�t||j|j�Wd�S1swYdS)zeEvaluate python expression expr in user namespace.
1013  
1014          Returns the result of evaluation
1015          N)rGr�r�r)rr�rrr�evBs$�zInteractiveShell.ev)�exit_ignore�raise_exceptionsr�c
1016  GsRt|�����}z|�d��Wd�n1swYWntd|�YdSt|j�}t|��j|j�Nz|ddd�\}}t	�
1017  ||||rO|jnd�Wn,tys}	z|	j
1018  ri|ra�|si|jdd�WYd}	~	nd}	~	w|ry�|jdd�YWd�n1s�wYWd�dSWd�dS1s�wYdS)	ajA safe version of the builtin execfile().
1019  
1020          This version will never throw an exception, but instead print
1021          helpful error messages to the screen.  This only works on pure
1022          Python files with the .py extension.
1023  
1024          Parameters
1025          ----------
1026          fname : string
1027              The name of the file to be executed.
1028          *where : tuple
1029              One or two namespaces, passed to execfile() as (globals,locals).
1030              If only one is given, it is passed as both.
1031          exit_ignore : bool (False)
1032              If True, then silence SystemExit for non-zero status (it is always
1033              silenced for zero status, as it is so common).
1034          raise_exceptions : bool (False)
1035              If True raise exceptions everywhere. Meant for testing.
1036          shell_futures : bool (False)
1037              If True, the code will share future statements with the interactive
1038              shell. It will both be affected by previous __future__ imports, and
1039              any __future__ imports in the code will affect the shell. If False,
1040              __future__ imports are not shared in either direction.
1041  
1042          �rbN�,Could not open file <%s> for safe execution.rrT�r]r;)r�
1043  expanduserr`rrr�r5rfrGr\Zexecfiler(�
1044  SystemExit�coderE)
1045  r�fnamer�r�r��where�dname�glob�locr�rrr�
1046  safe_execfileJs<��
1047  �
1048  ��P�zInteractiveShell.safe_execfilecst�������z��d��Wd�n1swYWntd��YdSt�j�}�fdd�}t|��?z|�D]}|j|d|d�}|rQ|�	�q@|j
1049  sVnq@Wn|r_�|��td��YWd�dSWd�dS1s}wYdS)	a�Like safe_execfile, but for .ipy or .ipynb files with IPython syntax.
1050  
1051          Parameters
1052          ----------
1053          fname : str
1054              The name of the file to execute.  The filename must have a
1055              .ipy or .ipynb extension.
1056          shell_futures : bool (False)
1057              If True, the code will share future statements with the interactive
1058              shell. It will both be affected by previous __future__ imports, and
1059              any __future__ imports in the code will affect the shell. If False,
1060              __future__ imports are not shared in either direction.
1061          raise_exceptions : bool (False)
1062              If True raise exceptions everywhere.  Meant for testing.
1063          r�Nr�c3sb��jdkr(ddlm}|�dd�}|jsdS|jD]}|jdkr%|jVqdS�jdd	�VdS)
1064  z,generator for sequence of code blocks to runz.ipynbr)�read�)Z
1065  as_versionNr�r_�r2)�suffixZnbformatr��cellsZ	cell_type�source�	read_text)r��nbr}�r�rr�	get_cells�s�
1066  
1067  
1068  ��z5InteractiveShell.safe_execfile_ipy.<locals>.get_cellsT)r�r�z$Unknown failure executing file: <%s>)rr�r`rrr�r5rf�run_cellr�r�rE)rr�r�r�r�r�r}r�rr�r�safe_execfile_ipy�s:��
1069  
1070  
1071  
1072  
1073  ����"z"InteractiveShell.safe_execfile_ipyc
1074  Csvz*z|�tjt|�ddd��WWdSty*}z|jr�WYd}~WdSd}~ww|��td|�YdS)a�A safe version of runpy.run_module().
1075  
1076          This version will never throw an exception, but instead print
1077          helpful error messages to the screen.
1078  
1079          `SystemExit` exceptions with status code 0 or None are ignored.
1080  
1081          Parameters
1082          ----------
1083          mod_name : string
1084              The name of the module to be executed.
1085          where : dict
1086              The globals namespace.
1087          r�T)�run_name�	alter_sysNz&Unknown failure executing module: <%s>)r��runpy�
1088  run_moduler�r�r�rEr)r�mod_namer�r�rrr�safe_run_module�s �����z InteractiveShell.safe_run_modulec
1089  Cs^d}z|�|||||�}W|j�d�|s|j�d|�|S|j�d�|s.|j�d|�ww)a�Run a complete IPython cell.
1090  
1091          Parameters
1092          ----------
1093          raw_cell : str
1094              The code (including IPython code such as %magic functions) to run.
1095          store_history : bool
1096              If True, the raw and translated cell will be stored in IPython's
1097              history. For user code calling back into IPython's machinery, this
1098              should be set to False.
1099          silent : bool
1100              If True, avoid side-effects, such as implicit displayhooks and
1101              and logging.  silent=True forces store_history=False.
1102          shell_futures : bool
1103              If True, the code will share future statements with the interactive
1104              shell. It will both be affected by previous __future__ imports, and
1105              any __future__ imports in the code will affect the shell. If False,
1106              __future__ imports are not shared in either direction.
1107  
1108          Returns
1109          -------
1110          result : :class:`ExecutionResult`
1111          NZpost_executeZ
1112  post_run_cell)�	_run_cellrr)rr�r�r�r�r�r�rrrr��s
1113  ���zInteractiveShell.run_cellr�r�r�r�r�c
1114  
1115  Cs�d}z|�|�}Wnty|}t��}Ynw|dusJ�|j|||||||d�}|jr2|j}	n|j|||d�r>|j}	nt}	z2z|	|�}
1116  WW|
1117  St	yr}zt
1118  |||||�}t|�}
1119  ||
1120  _|j
1121  dd�WYd}~W|
1122  Sd}~ww|
1123  YS)z/Internal method to run a complete IPython cell.N)r�r�r��transformed_cell�preprocessing_exc_tupler��r�r�T�r^)�transform_cellrZr0r>�run_cell_asyncr�should_run_asyncr�r~r�r�r�r�rE)
1124  rr�r�r�r�r�r�r��coror�r�r�r�rrrr�sP���	�
1125  ���zInteractiveShell._run_cellr�cCsp|jsdS|durdS|dusJ�|dur2tjdtdd�z
1126  |�|�}Wt|�Sty1YdSw|}t|�S)aTReturn whether a cell should be run asynchronously via a coroutine runner
1127  
1128          Parameters
1129          ----------
1130          raw_cell : str
1131              The code to be executed
1132  
1133          Returns
1134          -------
1135          result: bool
1136              Whether the code needs to be run with a coroutine runner or not
1137          .. versionadded:: 7.0
1138          FNz�`should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.rr)r�r�rr�r�rZr)rr�r�r�r}rrrr�Gs&�
1139  ��z!InteractiveShell.should_run_async)r�r�r�r�r�c�s��t|�|||�}t|��|r|��rd�_��_�S|rd��r%�j�_���fdd�}	�j�d�|s<�j�d|�|durbtj	dt
1140  d	d
1141  �z��|�}
1142  Wnty^t
1143  ��}|}
1144  Yn
1145  wd}n	|duri|}
1146  n|}
1147  d|
1148  vrud|
1149  vrud��r��jdus~J��j��j|
1150  |�|s��j�|
1151  |�|dur���|��r��jd
1152  7_|	|d
1153  �S|r��jn���}�j��
1154  |j|
1155  �j|d�}�j��z	|j|
1156  |d�}
1157  Wn��jy�}z&t
1158  ��\}}}��|||�|	|�WYd}~Wd�Wd�Sd}~wt�y'}z���|	|�WYd}~Wd�Wd�Sd}~wttt t!t"f�yT}z��#�|	|�WYd}~Wd�Wd�Sd}~wwz��$|
1159  �}
1160  Wn)t%�y�}z���|	|�WYd}~Wd�Wd�Sd}~ww��j&_'|�r�dn�j(}�j)|
1161  j*|||�d�IdH}|�_��_d�j&_'Wd�n	1�s�wYWd�n	1�s�wY��r�jdu�s�J��j�+�j��jd
1162  7_�S)a�Run a complete IPython cell asynchronously.
1163  
1164          Parameters
1165          ----------
1166          raw_cell : str
1167            The code (including IPython code such as %magic functions) to run.
1168          store_history : bool
1169            If True, the raw and translated cell will be stored in IPython's
1170            history. For user code calling back into IPython's machinery, this
1171            should be set to False.
1172          silent : bool
1173            If True, avoid side-effects, such as implicit displayhooks and
1174            and logging.  silent=True forces store_history=False.
1175          shell_futures : bool
1176            If True, the code will share future statements with the interactive
1177            shell. It will both be affected by previous __future__ imports, and
1178            any __future__ imports in the code will affect the shell. If False,
1179            __future__ imports are not shared in either direction.
1180          transformed_cell: str
1181            cell that was passed through transformers
1182          preprocessing_exc_tuple:
1183            trace if the transformation failed.
1184  
1185          Returns
1186          -------
1187          result : :class:`ExecutionResult`
1188  
1189          .. versionadded:: 7.0
1190          TFcs(�r	�jd7_|�_d�_��_�S)Nr{F)r�r�r�r�)r$�r�rr�rrr��sz:InteractiveShell.run_cell_async.<locals>.error_before_execr�Zpre_run_cellNz�`run_cell_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.rrzget_ipython().run_line_magic(Zpaster{)Zraw_code)r�r�)�
1191  interactivity�compilerr�),r�r��isspacer�r�r�rrr�rr�r�rZr0r>r�Zstore_inputsr@�logrEr(r'rG�cacherWZ	ast_parserrC�IndentationErrorrf�
1192  OverflowErrorrVr�r��MemoryErrorrW�
1193  transform_astrGrVZexec_result�ast_node_interactivity�
1194  run_ast_nodes�bodyZstore_output)rr�r�r�r�r�r�r�r�r�r}r��	cell_nameZcode_astr�r5r$r6r�Z
1195  has_raisedrr�rr�qs��(��
1196  
1197  ������
1198  �������
1199  �
1200  ���,zInteractiveShell.run_cell_asynccCs�|j�|�}t|���dkr)|j�|j�|�d}Wd�n1s$wY|jdd�}|jD]}||�}q2d�|�}|S)aTransform an input cell before parsing it.
1201  
1202          Static transformations, implemented in IPython.core.inputtransformer2,
1203          deal with things like ``%magic`` and ``!system`` commands.
1204          These run on all input.
1205          Dynamic transformations, for things like unescaped magics and the exit
1206          autocall, depend on the state of the interpreter.
1207          These only apply to single line inputs.
1208  
1209          These string-based transformations are followed by AST transformations;
1210          see :meth:`transform_ast`.
1211          r{r�NT)�keependsr�)	r�r�r�r�rGr�r�r�r�)rr�r}�linesZ	transformrrrr�
1212  s�
1213  
1214  
1215  zInteractiveShell.transform_cellcCs||jD]0}z|�|�}Wqty�ty3}ztd||f�|j�|�WYd}~qd}~ww|jr<t�|�|S)a�Apply the AST transformations from self.ast_transformers
1216  
1217          Parameters
1218          ----------
1219          node : ast.Node
1220              The root node to be transformed. Typically called with the ast.Module
1221              produced by parsing user input.
1222  
1223          Returns
1224          -------
1225          An ast.Node corresponding to the node it was called with. Note that it
1226          may also modify the passed object, so don't rely on references to the
1227          original AST.
1228          z>AST transformer %r threw an error. It will be unregistered. %sN)r��visitrGrZr�remove�ast�fix_missing_locations)r�nodeZtransformerr�rrrr:
1229  s"
1230  ����
1231  zInteractiveShell.transform_ast�nodelistr	c	�sL�|sdS|dkrPt|dt�rN|d}t|tj�r't|j�dkr'|jd}nt|t�r0|j}nd}t|tj�rNt�	t�|j
1232  t����}t�|�|�
1233  |�d}d}	|dkrct|dtj	�rad}nd	}|d	krm|g}
1234  }n"|dkr|dd�|dd�}
1235  }n|d
1236  kr�g|}
1237  }ntd|��z�dd
1238  �}g}
1239  |
1240  D]	}|
1241  �
1242  |df�q�|D]	}|
1243  �
1244  |df�q�|
1245  D]Q\}}|dkr�t|gg�}n
1246  |dkr�t�|g�}|�|jr�ttdd�nd��||||�}||�}Wd�n1s�wY|j|||d�IdH�rWdSq�ttjd��rt�WdSWdS|�rt��d|_|��YdS)a%Run a sequence of AST nodes. The execution mode depends on the
1247          interactivity parameter.
1248  
1249          Parameters
1250          ----------
1251          nodelist : list
1252            A sequence of AST nodes to run.
1253          cell_name : str
1254            Will be passed to the compiler as the filename of the cell. Typically
1255            the value returned by ip.compile.cache(cell).
1256          interactivity : str
1257            'all', 'last', 'last_expr' , 'last_expr_or_assign' or 'none',
1258            specifying which nodes should be run interactively (displaying output
1259            from expressions). 'last_expr' will run the last node interactively
1260            only if it is an expression (i.e. expressions in loops or other blocks
1261            are not displayed) 'last_expr_or_assign' will run the last expression
1262            or the last assignment. Other values for this parameter will raise a
1263            ValueError.
1264  
1265          compiler : callable
1266            A function with the same interface as the built-in compile(), to turn
1267            the AST nodes into code objects. Default is the built-in compile().
1268          result : ExecutionResult, optional
1269            An object to store exceptions that occur during execution.
1270  
1271          Returns
1272          -------
1273          True if an exception occurred while running code, False if it finished
1274          running.
1275          Nr�rr{rr�Fr�r�r�zInteractivity was %rcSstj|j@tjk}|Sr)�inspect�CO_COROUTINE�co_flags)r��is_asyncrrr�compare�
1276  sz/InteractiveShell.run_ast_nodes.<locals>.comparer��single�PyCF_ALLOW_TOP_LEVEL_AWAIT��async_T)r��
1277  _assign_nodesr�Assignr��targets�_single_targets_nodes�target�Name�Exprr��LoadrrOr�rzr�extra_flagsr�r��run_coder�r0rur�r>r�rE)rrr	r�r�r�ZasgrZnnodeZ_asyncZto_run_execZto_run_interactiverZto_runrr-�modr��asyrrrr\
1278  sz�&
1279  
1280  
1281  ��
1282  ����
1283  zInteractiveShell.run_ast_nodesrc
1284  �sZ�d}tj|j}t_||_d}z"z|r t||j|j�IdHnt||j|j�W|t_n|t_wWnvtyX}z|durA||_|j	dd�t
1285  ddd�WYd}~|Sd}~wtjyst�
1286  �\}}	}
1287  |durp|	|_Y|SY|S|jy�t�
1288  �\}}	}
1289  |dur�|	|_|�||	|
1290  �Y|S|dur�t�
1291  �d|_|j	dd�Y|Sd	}|S)
1292  a?Execute a code object.
1293  
1294          When an exception occurs, self.showtraceback() is called to display a
1295          traceback.
1296  
1297          Parameters
1298          ----------
1299          code_obj : code object
1300            A compiled code object, to be executed
1301          result : ExecutionResult, optional
1302            An object to store exceptions that occur during execution.
1303          async_ :  Bool (Experimental)
1304            Attempt to run top-level asynchronous code in a default loop.
1305  
1306          Returns
1307          -------
1308          False : successful execution.
1309          True : an error occurred.
1310          Z__ipython_bottom__TNr�z'To exit: use 'exit', 'quit', or Ctrl-D.r{rr�F)r0rwr1r�r�rr�r�r�rEr�bdbZBdbQuitr>rrC)rZcode_objr�rZ__tracebackhide__�old_excepthookZoutflagr�r5r$r6rrrr$�
1311  sN����
1312  ����zInteractiveShell.run_coder�cCs |j�|�\}}|d|p
1313  dfS)a�Return whether a block of code is ready to execute, or should be continued
1314  
1315          Parameters
1316          ----------
1317          code : string
1318              Python input code, which can be multiline.
1319  
1320          Returns
1321          -------
1322          status : str
1323              One of 'complete', 'incomplete', or 'invalid' if source is not a
1324              prefix of valid code.
1325          indent : str
1326              When status is 'incomplete', this is some whitespace to insert on
1327              the next line of the prompt.
1328          rhr)r��check_complete)rr�r�Znspacesrrrr)szInteractiveShell.check_complete�active_eventloopcCr�)Nz"Implement enable_gui in a subclass)�NotImplementedError)r�guirrr�
1329  enable_gui3szInteractiveShell.enable_guicCs�ddlm}|�s|dvrddl}ddlm}|�||j�\}}|dkrC|jdur-||_n||jkrCtd||jf�|�|j�\}}|�|�ddlm}|||�|�	|�|�
1330  |j�|jj
1331  d	_||fS)
1332  a�Enable interactive matplotlib and inline figure support.
1333  
1334          This takes the following steps:
1335  
1336          1. select the appropriate eventloop and matplotlib backend
1337          2. set up matplotlib for interactive use with that backend
1338          3. configure formatters for inline figure display
1339          4. enable the selected gui eventloop
1340  
1341          Parameters
1342          ----------
1343          gui : optional, string
1344              If given, dictates the choice of matplotlib GUI backend to use
1345              (should be one of IPython's supported backends, 'qt', 'osx', 'tk',
1346              'gtk', 'wx' or 'inline'), otherwise we use the default chosen by
1347              matplotlib (as dictated by the matplotlib build-time options plus the
1348              user's matplotlibrc configuration file).  Note that not all backends
1349              make sense in all contexts, for example a terminal ipython can't
1350              display figures inline.
1351          r{)�_matplotlib_manages_backends)N�autorN)�
1352  pylabtoolszHWarning: Cannot change to a different GUI toolkit: %s. Using %s instead.)�configure_inline_supportr�)r0r.Z matplotlib_inline.backend_inliner�Zfind_gui_and_backend�pylab_gui_selectr�Zactivate_matplotlibr1r-Z
1353  mpl_runnerr�r��registryZdefault_runner)rr,r.Zmatplotlib_inline�pt�backendr1rrr�enable_matplotlib6s(
1354  
1355  �
1356  
1357  
1358  
1359  �z"InteractiveShell.enable_matplotlibc	szddlm}��|�\}}i�|�|�dh}t����j��|�}��fdd�|D�}�j����j���|||fS)aActivate pylab support at runtime.
1360  
1361          This turns on support for matplotlib, preloads into the interactive
1362          namespace all of numpy and pylab, and configures IPython to correctly
1363          interact with the GUI event loop.  The GUI backend to be used can be
1364          optionally selected with the optional ``gui`` argument.
1365  
1366          This method only adds preloading the namespace to InteractiveShell.enable_matplotlib.
1367  
1368          Parameters
1369          ----------
1370          gui : optional, string
1371              If given, dictates the choice of matplotlib GUI backend to use
1372              (should be one of IPython's supported backends, 'qt', 'osx', 'tk',
1373              'gtk', 'wx' or 'inline'), otherwise we use the default chosen by
1374              matplotlib (as dictated by the matplotlib build-time options plus the
1375              user's matplotlibrc configuration file).  Note that not all backends
1376              make sense in all contexts, for example a terminal ipython can't
1377              display figures inline.
1378          import_all : optional, bool, default: True
1379              Whether to do `from numpy import *` and `from pylab import *`
1380              in addition to module imports.
1381          welcome_message : deprecated
1382              This argument is ignored, no welcome message will be displayed.
1383          r)�import_pylabr�cs"g|]
1384  }�j|�|ur|�qSr)r)rar��r�rrrr��s"z1InteractiveShell.enable_pylab.<locals>.<listcomp>)	ZIPython.core.pylabtoolsr7r6r��intersectionr�
1385  differencer�r�)	rr,Z
1386  import_allZwelcome_messager7r5ZignoredZbothZ	clobberedrr8r�enable_pylabms
1387  
1388  zInteractiveShell.enable_pylabcCsh|j��}z	t�|d�}Wn	tyYnw|�|j�z|j|g|d�}W|Sty3Y|Sw)a(Expand python variables in a string.
1389  
1390          The depth argument indicates how many frames above the caller should
1391          be walked to look for the local namespace where to expand variables.
1392  
1393          The global namespace for expansion is always the user's interactive
1394          namespace.
1395          r{)r�r�)	r�copyr0r�r�r�r��vformatrZ)rr�r�r$r�rwrrrr��s
1396  	���zInteractiveShell.var_expand�
1397  ipython_edit_cCshttj|d��}|j�|�tjd|t|�d�\}}t�|�t|�}|j	�|�|r2|j
1398  |dd�|S)a�Make a new tempfile and return its filename.
1399  
1400          This makes a call to tempfile.mkstemp (created in a tempfile.mkdtemp),
1401          but it registers the created filename internally so ipython cleans it up
1402          at exit time.
1403  
1404          Optional inputs:
1405  
1406            - data(None): if data is given, it gets written out to the temp file
1407              immediately, and the file is closed again.)�prefixz.py)�dirr_r�)r�tempfile�mkdtempr+rO�mkstempr�r��closer*�
1408  write_text)rr�r?Zdir_path�handler��	file_pathrrr�
1409  mktempfile�s
1410  zInteractiveShell.mktempfilecCs|jrdSt|||�Sr�)�quietr^)r�promptrZ	interruptrrrr^�szInteractiveShell.ask_yes_nocCst�tjjj�dS)zShow a usage messageN)r:r�r��usageZinteractive_usager�rrr�
1411  show_usage�r�zInteractiveShell.show_usagecCsN|jj||d�}d�dd�|D��}|s%d|vrd}|S|d|�d��}|S)axReturn as a string a set of input history slices.
1412  
1413          Parameters
1414          ----------
1415          range_str : str
1416              The set of slices is given as a string, like "~5/6-~4/2 4:8 9",
1417              since this function is for use by magic functions which get their
1418              arguments as strings. The number before the / is the session
1419              number: ~n goes n back from the current session.
1420  
1421              If empty string is given, returns history of current session
1422              without the last input.
1423  
1424          raw : bool, optional
1425              By default, the processed input is used.  If this is true, the raw
1426              input history is used instead.
1427  
1428          Notes
1429          -----
1430          Slices can be described with two notations:
1431  
1432          * ``N:M`` -> standard python form, means including items N...(M-1).
1433          * ``N-M`` -> include items N..M (closed endpoint).
1434          ��rawr�css�|]\}}}|VqdSrr)rar��xrrrrc�s�z7InteractiveShell.extract_input_lines.<locals>.<genexpr>r�N)r�Zget_range_by_strr��rfind)rZ	range_strrNrrtrrr�extract_input_lines�s�z$InteractiveShell.extract_input_linescCs|j||d�}|r|Sz|�d�rtj||d�WSWn,tyF}z |s;ddlm}||�}	|	���d�WYd}~St	d|�|�d}~ww|g}
1435  z
1436  |
1437  �
1438  dt|��Wn	ty]Ynw|
1439  D][}t
1440  j�|�r�z
1441  tj||d�WSty�}z,|s�t|d	dd
1442  ��}|��Wd�WYd}~S1s�wYt	d|�|�d}~wwt
1443  j�t
1444  j�|��r�t	d|��q`|r�|j|dd
1445  �}
1446  |
1447  dr�|
1448  dr�|
1449  dSzt||j�}Wnty�}zt	d|�|�d}~wwt|t�r�|St|t�r�|jStd||��)aVGet a code string from history, file, url, or a string or macro.
1450  
1451          This is mainly used by magic functions.
1452  
1453          Parameters
1454          ----------
1455          target : str
1456              A string specifying code to retrieve. This will be tried respectively
1457              as: ranges of input history (see %history for syntax), url,
1458              corresponding .py file, filename, or an expression evaluating to a
1459              string or Macro in the user namespace.
1460  
1461              If empty string is given, returns complete history of current
1462              session, without the last line.
1463  
1464          raw : bool
1465              If true (default), retrieve raw history. Has no effect on the other
1466              retrieval mechanisms.
1467  
1468          py_only : bool (default False)
1469              Only try to fetch python code, do not try alternative methods to decode file
1470              if unicode fails.
1471  
1472          Returns
1473          -------
1474          A string of code.
1475          ValueError is raised if nothing is found, and TypeError if it evaluates
1476          to an object of another type. In each case, .args[0] is a printable
1477          message.
1478          rM)zhttp://zhttps://)�skip_encoding_cookier)�urlopen�latin1Nz'%s' seem to be unreadable.�rr�z('%s' is a directory, not a regular file.r{)r&rr�zI'%s' was not found in history, as a file, url, nor in the user namespace.z#%s is neither a string nor a macro.)rQr�r[Zread_py_url�UnicodeDecodeError�urllib.requestrSr�rcr�rsrb�IOErrorr�r�isfileZread_py_filer��isdirr�r!r�rrZr�r�rQr$r�)rrrNZpy_onlyrRZ	search_nsr�r�rS�responseZpotential_targetZtgtr�r'�codeobjrrr�find_user_codesr
1479  ����0��������
1480  
1481  �zInteractiveShell.find_user_codecCs6t|dd�sd|_|jdd�|j��d|_dSdS)z�
1482          At exist operation that need to be called at most once.
1483          Second call to this function per instance will do nothing.
1484          �_atexit_once_calledFT)r�N)r�r^r�r�Zend_sessionr�rrr�_atexit_onceTs
1485  
1486  �zInteractiveShell._atexit_oncec	Cs�|��|jD]}z|��|j�|�WqtyYqw|`|jD]}z
1487  t�|�|j�|�Wq$ty<Yq$w|`t|d�rV|j	dkrXt
1488  j�d�t
1489  j�
1490  �dSdSdS)a�This will be executed at the time of exit.
1491  
1492          Cleanup operations and saving of persistent data that is done
1493          unconditionally by IPython should be performed here.
1494  
1495          For things that may depend on startup flags or platform specifics (such
1496          as having readline or not), register a separate atexit function in the
1497          code that has the appropriate information, rather than trying to
1498          clutter
1499          �editing_mode�viz[0 qN)r_r*�unlinkr
1500  �FileNotFoundErrorr+�shutil�rmtreer�r`r0rur�r�)rZtfileZtdirrrrrgs*
1501  �
1502  
1503  ��z"InteractiveShell.atexit_operationscCs|��dSr)r�r�rrr�cleanup�szInteractiveShell.cleanupcCrrr)rr-rrr�switch_doctest_mode�rz$InteractiveShell.switch_doctest_mode)NNNNr�r)r�NN)F)NN)TF)T)r)rr)NNNFFrP)rN)r�N)r{)r�)Tr)FF)FFTN)FFT)NTF)Nr>)TFTF)�r(r)r*ryZ	_instancer�tagr�r�NodeTransformerr�r.Zautocallr,r"r�r|r}r�r~r�r	r�rr�r4r�Z	automagicr2rUr�r�r0rSZ
1504  color_infor-r3�debugZdisable_failing_post_executer/rLrNr1rErUrFrQrBr'r9Z	InspectorrHrrr3r�r�r�rRZexit_nowr@r�r�r�r�rr�r�r�r�r�rArCrBrIr�r�r�rIZhistory_lengthZhistory_load_lengthrrqr�Zseparate_inZseparate_outZ
1505  separate_out2Zwildcards_case_sensitiver4r�r�rGrWr�r�r�r�r�r�rr-r2r�r�rrr r#r%r�r�r�r�r�r�r=rrrrrrr
1506  rrr
1507  r�staticmethodrr^r�r�r�r�r�r�r�rr�r�r�r�rr�r�r�r�r�r�r�r�r�rr�r�r�r�r�rr�rr��ListTyperr
1508  r�AnyTyperkrrrr%r!r)r(r�rCr/r	r2rwrJrLrOrEr[rWrfrXrgrirrsrvrxr�	functools�wrapsr8r�r�r�r�r�r�r�rrr�r�r�r�rdrcrrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr(rrr$Zruncoder)r*r-r6r;rgr�rHr^rLrQr]r_rrfrgr�rrr�rr�Fs,
1509  ���	��������
1510  
1511  �������	�
1512  ����������
1513  ��
1514  
1515  �
1516  �
1517  ������
1518  ��������������������
1519  �N
1520  	
1521  
1522  	A
1523  	5
1524  &�N
1525  ,;
1526  	@.0 -���
1527  �z
1528  )"	g"	�L
1529  #+
1530  #7
1531  3&A!D:�*������:
1532  ���-�
1533  ����
1534  �,&���{@ 70%S"r�c@rv)�InteractiveShellABCz,An abstract base class for InteractiveShell.Nrxrrrrrp�srp)�	metaclass)�ry�abcrrr'�builtinsrErnrr�rmr�rdr�r0rArMr�r�rrZrr��loggingr�pathlibr�typingrrrlrZDictTyper	rmr
1535  rrrZpicklesharer�ModuleNotFoundErrorr+Z	traitletsr,r-r.r/r0r1r2rr3r4Ztraitlets.config.configurabler5Ztraitlets.utils.importstringr7ZIPython.core.hooksr�r�r8r9r:r;r<ZIPython.core.aliasr=r>ZIPython.core.autocallr@ZIPython.core.builtin_traprAZIPython.core.compileroprBZIPython.core.debuggerrCZIPython.core.display_traprDZIPython.core.displayhookrEZIPython.core.displaypubrFZIPython.core.errorrGrHZIPython.core.eventsrIrJZIPython.core.extensionsrK�IPython.core.formattersrLZIPython.core.historyrMZIPython.core.inputtransformer2rNrOZIPython.core.loggerrPZIPython.core.macrorQZIPython.core.payloadrRZIPython.core.prefilterrSZIPython.core.profiledirrTZIPython.core.usagerU�IPython.displayrVZ
1536  IPython.pathsrWZIPython.testing.skipdoctestrXZ
1537  IPython.utilsrYr[r\ZIPython.utils.decoratorsr]ZIPython.utils.ior^ZIPython.utils.ipstructr_ZIPython.utils.pathr`rarbZIPython.utils.processrcrdZIPython.utils.strdispatchreZIPython.utils.syspathcontextrfZIPython.utils.textrgrhrirjZIPython.core.oinspectrkr�Zdocrepr.sphinxifyrlrnr rlZexceptiongrouprur�rwrz�	AugAssign�	AnnAssignrrrZ
1538  async_helpersr|r}r~rr�r(Z	dedent_rer�r�r�r�rZr�r��objectr�r�r�ror�r��ABCMetarprrrrr�<module>s�#<�
1539  
1540  
1541  
1542  %
1543  
1544  h