Format: application/x-python-code
⬇ Download File (6.0 KB)
   1  o
   2  
   3  ��h��@s(ddlZddlZddlZddlmZddlmZddlmZddl	m
   4  Z
   5  ddlmZddl
   6  mZdd	lmZdd
   7  lmZddlmZddlmZdd
   8  lmZddlmZmZddlmZddlmZ e �!d�Z"dej#vZ$Gdd�de�Z%ddd�Z&e'dkr�ddl(Z(e(jj)Z*e%e(_e*e(j_)e(�+�dSdS)�N)�Pdb)�IPCompleter�)�IPythonPTCompleter)�create_ipython_shortcuts)�embed)�Path)�Token)�create_app_session)�
   9  PromptSession)�EditingMode��PygmentsTokens)�InMemoryHistory�FileHistory)�ThreadPoolExecutor)�__version__z3.ZIPY_TEST_SIMPLE_PROMPTc@sBeZdZdZdd�dd�Zddd�Zdd	�Zdd
  10  d�Zdd
  11  �ZdS)�TerminalPdbzStandalone IPython debugger.N)�pt_session_optionscOs6tj|g|�Ri|��d|_|�|�td�|_dS)Nr)r�__init__�_ptcomp�pt_initr�thread_executor)�selfr�args�kwargs�r�Oc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/terminal/debugger.pyr s
  12  zTerminalPdb.__init__c
  13  sv|duri}�fdd���jdur@t�jii�jd�}dd�t��D���fdd�}d	dl}|�||�}|j�d	|�t|��_�jj	durm�jj
  14  durht�jj
  15  ���}|�
  16  �s\|��ttj�t|����_	n
  17  t��_	n�jj	�_	t�fd
  18  d�tt�jj���t�j��j	�jd�jj�jjt�jd
  19  d��jjd�
  20  }ts��jj|d<|�|�t s�t!�"��_#t$di|���_%dSdS)z�Initialize the prompt session and the prompt loop
  21          and store them in self.pt_app and self.pt_loop.
  22  
  23          Additional keyword arguments for the PromptSession class
  24          can be specified in pt_session_options.
  25          Ncstj�jfgS�N)r	�Prompt�promptr�rrr�get_prompt_tokens0sz.TerminalPdb.pt_init.<locals>.get_prompt_tokens)�shell�	namespace�global_namespace�parentcSs"g|]
  26  }|�d�r|dd��qS)Zdo_�N��
  27  startswith��.0�mrrr�
  28  <listcomp>8s"z'TerminalPdb.pt_init.<locals>.<listcomp>cs�fdd��D�S)Ncsg|]	}|���r|�qSrr(r*��textrrr-;sz9TerminalPdb.pt_init.<locals>.gen_comp.<locals>.<listcomp>r)rr/)�
  29  methods_namesr.r�gen_comp:sz%TerminalPdb.pt_init.<locals>.gen_comprcs
  30  t���Srr
  31  r)r"rr�<lambda>Ps
  32  z%TerminalPdb.pt_init.<locals>.<lambda>T�style)
  33  �message�editing_modeZkey_bindings�historyZ	completerZenable_history_search�
  34  mouse_support�complete_styler3�color_depth�	inputhookr)&rrr#�dir�types�
  35  MethodTypeZcustom_matchers�insertrZdebugger_historyZdebugger_history_filer�
  36  expanduser�exists�touchr�os�path�strr�dict�getattrrr5�upperrr7Zpt_complete_styler9�PTK3r:�update�_use_simple_prompt�asyncio�new_event_loopZpt_loopr�pt_app)rrZcomplr1r<Znewcomp�p�optionsr)r"r0rrr&sP
  37  �
  38  
  39  
  40  
  41  �
  42  
  43  
  44  �zTerminalPdb.pt_initcCs4t��
  45  |j��Wd�S1swYdS)a�
  46          In case other prompt_toolkit apps have to run in parallel to this one (e.g. in madbg),
  47          create_app_session must be used to prevent mixing up between them. According to the prompt_toolkit docs:
  48  
  49          > If you need multiple applications running at the same time, you have to create a separate
  50          > `AppSession` using a `with create_app_session():` block.
  51          N)r
  52  rMr r!rrr�_promptcs$�zTerminalPdb._promptcCs�|jstd��|��zc|dur||_|jrt|j|jd�d}|sh|jr,|j�d�}n*|j|j	j
  53  _|jj
  54  |j	j
  55  _tsRz|j�|j���}WntyQd}Ynwtd�}|�|�}|�|�}|�||�}|r"|��WdStyv�w)aRepeatedly issue a prompt, accept input, parse an initial prefix
  56          off the received input, and dispatch to action methods, passing them
  57          the remainder of the line as argument.
  58  
  59          override the same methods from cmd.Cmd to provide prompt toolkit replacement.
  60          z.Sorry ipdb does not support use_rawinput=FalseN)�filerZEOFzipdb> )Zuse_rawinput�
  61  ValueErrorZpreloop�intro�print�stdoutZcmdqueue�pop�curframe_localsrZ
  62  ipy_completerr$�curframe�	f_globalsr%rJr�submitrP�result�EOFError�inputZprecmdZonecmdZpostcmdZpostloop�	Exception)rrS�stop�linerrr�cmdloopns:�
  63  
  64  ��zTerminalPdb.cmdloopcCs<tj|jjddd�}|jj}|tj�|dd�|j	d�dS)Nz
  65  *interactive*z *exiting interactive console...*)�configZbanner1Zexit_msg�__name__)�moduleZlocal_ns)
  66  rZInteractiveShellEmbedr#rbrXrY�sys�modules�getrW)r�argZipshell�	global_nsrrr�do_interact�s�
  67  �zTerminalPdb.do_interactr)	rc�
  68  __module__�__qualname__�__doc__rrrPrarjrrrrrs
  69  =
  70  .rcCst��|p	t��j�dS)zm
  71      Start debugging from `frame`.
  72  
  73      If frame is not specified, debugging starts from caller's frame.
  74      N)r�	set_tracere�	_getframe�f_back)�framerrrrn�srn�__main__r),rKrBreZIPython.core.debuggerrZIPython.core.completerrZptutilsrZ	shortcutsr�r�pathlibrZpygments.tokenr	Zprompt_toolkit.applicationr
  75  Zprompt_toolkit.shortcuts.promptrZprompt_toolkit.enumsrZprompt_toolkit.formatted_textrZprompt_toolkit.historyrr�concurrent.futuresrZprompt_toolkitrZptk_versionr)rH�environrJrrnrc�pdbZtrace_dispatchZold_trace_dispatch�mainrrrr�<module>s:
  76  
  77  
  78  
  79  	�