ó
    Ñ]j  ã                   ó¾   • 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        ÚT/home/mande/repo/quber/.venv/lib/python3.13/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   ø€ ÜŒn˜dÑ,¨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×-=Ñ-=Ó-?Ó'@ˆD�J‰J×Ñ˜tÑ$ÜÐ*¨TÑ1Õ2à×#Ñ# EÓ*ˆAØ12�J‰J×Ñ˜~Ñ.Ø,0ˆD�J‰JÔ)ð6Ø—
‘
×#Ñ# AÔ5à05�—
‘
Õ-ø°�—
‘
Õ-ú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 !™HŸN™N×,Ñ,Ø˜!˜"�IˆEö ˜E !™HŸN™N×,Ó,ä! $§)¡)¨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Š   € ð �J‰J×Ñ×"Ñ" 4Ó(ˆð ‰9ÜÐAÓBÐBÜ˜!œS×!Ñ!ÜØHóJð Jô 	Ð/°!·'±'¸$¸q³/À!Ñ2DÄcÈ!ÃfÐ1MÑ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°¨,°t·z±z×7LÑ7LÑ*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‰
ˆØ�$‹;Ø×ÑÔØà˜‘ˆà—8‘8˜C Ó'ˆØ—	‘	Ô*¨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Ø—J‘J×$Ñ$×2Ñ2Ó4ˆEð �d‹?Ü�J‰J×Ñ˜TŸZ™Z×2Ñ2°5Ó9Ô:Ø—>‘> $×'Ñ'Ü—
‘
× Ñ  Ô&Ü�J‰J×ÑÐ9Ô:à×Ñ˜e¸ÐÒ>øô# ó 	Ü˜m¨VÓ4ˆGÞÜ�g˜a‘jÕ!äÐ>Ô?ÜûÜó 	IÜÐ@ÓAÀqÐ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   € ô �IŠI�eÕ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$   