| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/lib/python3/dist-packages/IPython/core/magics/__pycache__/ |
Upload File : |
�
�@�c� � �f � d Z ddlmZmZmZmZ ddlmZ ddlm Z e G d� de� � � � Z
dS )zLImplementation of magic functions that control various automatic behaviors.
� )�Bunch�Magics�magics_class�
line_magic)�skip_doctest)�errorc �b � � e Zd ZdZ� fd�Zedd�� � Zeedd�� � � � Z� xZ S )�
AutoMagicsz,Magics that control various autoX behaviors.c �~ �� t t | � � � |� � t � � | _ d S )N)�superr
�__init__r �_magic_state)�self�shell� __class__s ��:/usr/lib/python3/dist-packages/IPython/core/magics/auto.pyr
zAutoMagics.__init__ s3 �� �
�j�$���(�(��/�/�/�!�G�G����� � c �� � |� � � }| j j }|dv rd}n|dv rd}n|j }||_ t d| j j � � � z � � dS )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 � automagiczAutoMagics.automagic! s� � �$ ���!�!���z�(���%�%�%��C�C�
�)�
)�
)��C�C��o�%�C����
�d�T�Z�.�:�:�<�<�<�=�=�=�=�=r c � �� dddd��dt f�fd�}|rR|t t �� � � � � vrt |� � � � dS t |� � }nd}|g t �� � � � � �d�R vrt |� � � � dS |�� � � v r
|| j _ no| j j r#| j j | j _ d | j _ n@ | j j | j _ n(# t $ r d
x| j _ | j _ Y nw xY wt dt �� � � � � | j j � � dS )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 � �� d} �� � � D ] \ }}| t |� � dz |z dz z
} �!| d d� } | S )Nz
Valid modes: z->z, ���)�items�str)r �k�v�valid_modess �r �errorMessagez)AutoMagics.autocall.<locals>.errorMessageq sY �� �#�E�#�)�)�+�+�
2�
2���1���Q���$���*�T�1�1����#�2�#�J�E��Lr N�toggler r+ zAutomatic calling is:)
r1 �map�keysr �int�listr �autocallr �
autocall_save�AttributeErrorr �values)r r"