
    <h                         S r SSKJr  SSKrSSKrSSKJrJr  SSKJ	r	J
r
Jr  SSKJr  SSKJr  SSKJrJr  SS	KJr  \R*                  S
4S jr\
 " S S\	5      5       rg)zExtra magics for terminal use.    )errorN)TryNext
UsageError)Magicsmagics_class
line_magic)ClipboardEmpty)skip_doctest)SListstrip_email_quotes)	py3compatFc              #      #    U(       d  [        SU -  5        SnOSn  U" U5      nX@:X  a  gUv    M  ! [         a    [        S5         gf = f7f)zGYield pasted lines until the user enters the given sentinel value.
    zAPasting code; enter '%s' alone on the line to stop or use Ctrl-D.: Nz<EOF>)printEOFError)sentinell_inputquietpromptls        jC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\IPython/terminal/magics.pyget_pasted_linesr      sd      Q 	
	A}   	'N	s.   A4 A4 AA	AAAc                      ^  \ rS rSrU 4S jrSS jrS rSS jr\SS j5       r	\
\SS j5       5       r\SS j5       r\R                  S	:X  a  \S
 5       rSrU =r$ SrU =r$ )TerminalMagics'   c                 ,   > [         [        U ]  U5        g )N)superr   __init__)selfshell	__class__s     r   r   TerminalMagics.__init__)   s    nd,U3    c                    U(       a?  [        UR                  5       5      U R                  R                  U'   [	        SU-  5        gU R                  U5      nX@R                  R                  S'   SU R                  l         U R                  R                  XC5        SU R                  l        g! SU R                  l        f = f)zLExecute a block, or store it in a variable, per the user's request.
        zBlock assigned to '%s'pasted_blockTFN)r   
splitlinesr!   user_nsr   preclean_inputusing_paste_magicsrun_cell)r    blocknamestore_historybs        r   store_or_executeTerminalMagics.store_or_execute,   s     ',U-=-=-?'@DJJt$*T12##E*A12JJ~.,0DJJ)6

##A505

-

-s   B/ /Cc                     UR                  5       nU(       a>  US   R                  5       (       d&  USS  nU(       a  US   R                  5       (       d  M&  [        SR                  U5      5      $ )Nr      
)r'   stripr   join)r    r,   liness      r   r)   TerminalMagics.preclean_input<   sW      "E!HNN,,!"IE E!HNN,,!$))E"233r$   c                 8   U R                   R                  R                  U5      nUc  [        S5      e[	        U[
        5      (       d  [        S5      e[        SUR                  SS5      S   [        U5      4-  5        U R                   R                  U5        g)z+Rerun a previously pasted command.
        Nz"No previous pasted block availablez6Variable 'pasted_block' is not a string, can't executezRe-executing '%s...' (%d chars)r4   r3   r   )
r!   r(   getr   
isinstancestrr   splitlenr+   )r    r-   r/   s      r   rerun_pastedTerminalMagics.rerun_pastedB   s     JJ""4( 9ABB!S!!HJ J 	/!''$q/!2Dc!f1MMN

Ar$   c                     U R                   R                  5         [        SSS/U R                   R                     5        g)z%Toggle autoindent on/off (deprecated)zAutomatic indentation is:OFFONN)r!   set_autoindentr   
autoindent)r    parameter_ss     r   rE   TerminalMagics.autoindentQ   s2     	

!!#)5,tzz7L7L*MNr$   c                     U R                  USSS9u  p#SU;   a  U R                  5         gSU;   nUR                  SS5      nS	R                  [	        XTS
95      nU R                  XcSS9  g)u  Paste & execute a pre-formatted code block from clipboard.

You must terminate the block with '--' (two minus-signs) or Ctrl-D
alone on the line. You can also provide your own sentinel with '%paste
-s %%' ('%%' is the new sentinel for this operation).

The block is dedented prior to execution to enable execution of method
definitions. '>' and '+' characters at the beginning of a line are
ignored, to allow pasting directly from e-mails, diff files and
doctests (the '...' continuation prompt is also stripped).  The
executed block is also assigned to variable named 'pasted_block' for
later editing with '%edit pasted_block'.

You can also pass a variable name as an argument, e.g. '%cpaste foo'.
This assigns the pasted block to variable 'foo' as string, without
dedenting or executing it (preceding >>> and + is still stripped)

'%cpaste -r' re-executes the block previously entered by cpaste.
'%cpaste -q' suppresses any additional output messages.

Do not be alarmed by garbled output on Windows (it's a readline bug).
Just press enter and type -- (and press enter again) and the block
will be what was just pasted.

Shell escapes are not supported (yet).

See Also
--------
paste : automatically pull code from clipboard.

Examples
--------
::

  In [8]: %cpaste
  Pasting code; enter '--' alone on the line to stop.
  :>>> a = ["world!", "Hello"]
  :>>> print(" ".join(sorted(a)))
  :--
  Hello world!

::
  In [8]: %cpaste
  Pasting code; enter '--' alone on the line to stop.
  :>>> %alias_magic t timeit
  :>>> %t -n1 pass
  :--
  Created `%t` as an alias for `%timeit`.
  Created `%%t` as an alias for `%%timeit`.
  354 ns ± 224 ns per loop (mean ± std. dev. of 7 runs, 1 loop each)
zrqs:stringmoderNqsz--r4   )r   Tr.   )parse_optionsr?   r:   r6   r   r0   )r    rF   optsr-   r   r   r,   s          r   cpasteTerminalMagics.cpasteW   st    l ''V('K
$;88C'		*8ABe>r$   c                    U R                  USSS9u  p#SU;   a  U R                  5         g U R                  R                  R	                  5       nS
U;  a  [        R                  R                  U R                  R                  U5      5        UR                  S5      (       d  [        R                  R                  S5        [        R                  R                  S5        U R                  XCSS9  g! [
         a7  n[        US5      nU(       a  [        US   5        O[        S5         SnAgSnAf[         a  n[        S	5      UeSnAff = f)aE  Paste & execute a pre-formatted code block from clipboard.

The text is pulled directly from the clipboard without user
intervention and printed back on the screen before execution (unless
the -q flag is given to force quiet mode).

The block is dedented prior to execution to enable execution of method
definitions. '>' and '+' characters at the beginning of a line are
ignored, to allow pasting directly from e-mails, diff files and
doctests (the '...' continuation prompt is also stripped).  The
executed block is also assigned to variable named 'pasted_block' for
later editing with '%edit pasted_block'.

You can also pass a variable name as an argument, e.g. '%paste foo'.
This assigns the pasted block to variable 'foo' as string, without
executing it (preceding >>> and + is still stripped).

Options:

  -r: re-executes the block previously entered by cpaste.

  -q: quiet mode: do not echo the pasted text back to the terminal.

IPython statements (magics, shell escapes) are not supported (yet).

See Also
--------
cpaste : manually paste code into terminal until you mark its end.
rqrI   rJ   rL   Nargsr   z&Could not get text from the clipboard.z!The clipboard appears to be emptyrM   r4   z## -- End pasted text --
TrO   )rP   r?   r!   hooksclipboard_getr   getattrr   r	   r   sysstdoutwrite
pycolorizeendswithr0   )r    rF   rQ   r-   r,   clipboard_excmessagees           r   pasteTerminalMagics.paste   s   > ''T'I
$;
	IJJ$$224E d?JJTZZ2259:>>$''

  &JJ9:e>#  	mV4Ggaj!>? 	I@AqH	Is#   $C3 3
E=-D//E<EEwin32c                 0    [         R                  " S5        g)zClear screen.
            clsN)ossystem)r    rN   s     r   rf   TerminalMagics.cls   s     IIer$    )F)r&   )r   )__name__
__module____qualname____firstlineno__r   r0   r)   r?   r   rE   r
   rR   rb   rZ   platformrf   __static_attributes____classcell__)r"   s   @r   r   r   '   s    46 4 O O
 =?  =?~ 5? 5?p ||w		 
	 r$   r   )__doc__loggingr   rg   rZ   IPython.core.errorr   r   IPython.core.magicr   r   r   IPython.lib.clipboardr	   IPython.testing.skipdoctestr
   IPython.utils.textr   r   IPython.utilsr   inputr   r   rj   r$   r   <module>r{      sT    $  	 
 2 ? ? 0 4 8 #'0e * nV n nr$   