
    3 d>                     `    d dl mZ i dfdZi dfdZi dfdZi dfdZeeeedZdd	Zdd
ZdS )    )wraps c                     	 ddl m ddlm n# t          $ r ddlm ddlm Y nw xY wt          t                    | dffd	            }|S )zStart an IPython Shellr   )InteractiveShellEmbed)load_default_configr   c                                  }                                                      || |          } |             d S )N)banner1user_nsconfig)clear_instanceinstance)	namespacebannerr   shellr   r   s       4lib/python3.11/site-packages/scrapy/utils/console.pywrapperz%_embed_ipython_shell.<locals>.wrapper   sW    $$&&
 	,,...%..If / 
 
 	    )	IPython.terminal.embedr   IPython.terminal.ipappr   ImportErrorIPython.frontend.terminal.embedIPython.frontend.terminal.ipappr   _embed_ipython_shell)r   r   r   r   r   s      @@r   r   r      s    H@@@@@@>>>>>>> H H HIIIIIIGGGGGGGGH   #B 
 
 
 
 
 
 ! 
 Ns    **c                 T    ddl t          t                    | dffd	            }|S )zStart a bpython shellr   Nr   c                 6                         | |           d S )N)locals_r   )embed)r   r   bpythons     r   r   z%_embed_bpython_shell.<locals>.wrapper!   s    i77777r   )r   r   _embed_bpython_shell)r   r   r   r   s      @r   r   r      sJ    NNN
  #B 8 8 8 8 8 ! 8 Nr   c                 T    ddl t          t                    | dffd	            }|S )zStart a ptpython shellr   Nr   c                 \    t          |           j                            |            d S )N)locals)printreplr   )r   r   ptpythons     r   r   z&_embed_ptpython_shell.<locals>.wrapper,   s-    f9-----r   )ptpython.replr   _embed_ptpython_shell)r   r   r   r%   s      @r   r'   r'   (   sM    
 !!#B . . . . . "!. Nr   c                     ddl 	 ddl}ddl}|                    d           n# t          $ r Y nw xY wt          t                    | dffd	            }|S )zStart a standard python shellr   Nztab:completer   c                 6                         ||            d S )N)r   local)interact)r   r   codes     r   r   z&_embed_standard_shell.<locals>.wrapperA   s    V955555r   )r,   readlinerlcompleterparse_and_bindr   r   _embed_standard_shell)r   r   r-   r.   r   r,   s        @r   r0   r0   4   s    KKK0 	////      !!#B 6 6 6 6 6 "!6 Ns   % 
22)r%   ipythonr   pythonNc                     | t                                           } |t                                           }| D ])}||v r#	  ||                     c S # t          $ r Y %w xY w*dS )z[Return the first acceptable shell-embed function
    from a given list of shell names.
    N)DEFAULT_PYTHON_SHELLSkeyscopyr   )shellsknown_shellsr   s      r   get_shell_embed_funcr9   P   s      .&++-- 4,1133  L  	 +|E*,,,,,   	 s    A
AAc                 r    | i } 	 t          |          }| || |           dS dS # t          $ r Y dS w xY w)zStart Python console bound to the given namespace.
    Readline support and tab completion will be used on Unix, if available.
    N)r   r   )r9   
SystemExit)r   r   r7   r   s       r   start_python_consoler<   b   sr      	$V,, 	6EIf555555	6 	6   s   ( 
66)NN)Nr   N)		functoolsr   r   r   r'   r0   r4   r9   r<    r   r   <module>r?      s          $&b    2 $&b     %'r 	 	 	 	 %'r    * &###	     $     r   