
    f                     X    d Z ddlmZmZmZmZ ddlmZ ddlm	Z	 e G d de             Z
y)zLImplementation of magic functions that control various automatic behaviors.
    )BunchMagicsmagics_class
line_magic)skip_doctest)errorc                   P     e Zd ZdZ fdZedd       Zeedd              Z xZ	S )
AutoMagicsz,Magics that control various autoX behaviors.c                 J    t         t        |   |       t               | _        y )N)superr
   __init__r   _magic_state)selfshell	__class__s     S/var/www/cvtools/html/venv/lib/python3.12/site-packages/IPython/core/magics/auto.pyr   zAutoMagics.__init__   s    j$(/!G    c                     |j                         }| j                  j                  }|dv rd}n|dv rd}n|j                   }||_        t	        d| j                  j                  j                         z          y)a  Make magic functions callable without having to type the initial %.

        Without arguments toggles on/off (when off, you must call it as
        %automagic, of course).  With arguments it sets the value, and you can
        use any of (case insensitive):

         - on, 1, True: to activate

         - off, 0, False: to deactivate.

        Note that magic functions have lowest priority, so if there's a
        variable whose name collides with that of a magic fn, automagic won't
        work for that function (you get the variable instead). However, if you
        delete the variable (del var), the previously shadowed magic function
        becomes visible to automagic again.)on1trueT)off0falseF
N)lowerr   magics_manager
auto_magicprintauto_status)r   parameter_sargmmanvals        r   	automagiczAutoMagics.automagic!   sp    $ !zz((%%C))Coo%CdTZZ..::<<=r   c                    dddddt         ffd}|r=|t        t         j                               vrt         |              yt	        |      }nd}|g t        j                               dvrt         |              y|j                         v r|| j                  _        ns| j                  j                  r7| j                  j                  | j                  _	        d	| j                  _        n&	 | j                  j                  | j                  _        t        dt        j                               | j                  j                            y# t        $ r% d
x| j                  _        | j                  _	        Y hw xY w)aV  Make functions callable without having to type parentheses.

        Usage:

           %autocall [mode]

        The mode can be one of: 0->Off, 1->Smart, 2->Full.  If not given, the
        value is toggled on and off (remembering the previous state).

        In more detail, these values mean:

        0 -> fully disabled

        1 -> active, but do not apply if there are no arguments on the line.

        In this mode, you get::

          In [1]: callable
          Out[1]: <built-in function callable>

          In [2]: callable 'hello'
          ------> callable('hello')
          Out[2]: False

        2 -> Active always.  Even if no arguments are present, the callable
        object is called::

          In [2]: float
          ------> float()
          Out[2]: 0.0

        Note that even with autocall off, you can still use '/' at the start of
        a line to treat the first argument on the command line as a function
        and add parentheses to it::

          In [8]: /str 43
          ------> str(43)
          Out[8]: '43'

        # all-random (note for auto-testing)
        OffSmartFull)r         returnc                  t    d} j                         D ]  \  }}| t        |      dz   |z   dz   z  }  | d d } | S )NzValid modes: z->z, )itemsstr)r   kvvalid_modess      r   errorMessagez)AutoMagics.autocall.<locals>.errorMessageq   sP    #E#))+ 21Q$*T112#2JELr   Ntoggler   r*   zAutomatic calling is:)r0   mapkeysr   intlistr   autocallr   autocall_saveAttributeErrorr   values)r   r!   r4   r"   r3   s       @r   r:   zAutoMagics.autocall>   sL   \ 
	c 	 #c;+;+;+=">>ln%k"CC;[--/0;(;;,.!;##%&"%DJJzz""26**2E2E!!/&'

#N*.*;*;*I*IDJJ' 	%tK,>,>,@'A$**BUBU'VW & NLMMDJJ'$*;*;*INs   8%E +FF) )
__name__
__module____qualname____doc__r   r   r%   r   r:   __classcell__)r   s   @r   r
   r
      s?    6$
 > >8 PX  PXr   r
   N)rB   IPython.core.magicr   r   r   r   IPython.testing.skipdoctestr   loggingr   r
    r   r   <module>rH      s:    G F 4  wX wX wXr   