403Webshell
Server IP : 35.80.110.71  /  Your IP : 216.73.217.120
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/IPython/extensions/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/IPython/extensions/__pycache__/autoreload.cpython-312.pyc
�

}�e�[��`�dZddlmZddlmZmZmZdZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZmZddlmZGd�d	�Zgd
�Zd�Zd�Zd
�Zd�Zd�Zd�efd�efd�efgZej9d�d�fg�d�ZGd�d�Zgd�Zdd�Z eddfd�Z!eGd�de��Z"d�Z#y)a�IPython extension to reload modules before executing user code.

``autoreload`` reloads modules automatically before entering the execution of
code typed at the IPython prompt.

This makes for example the following workflow possible:

.. sourcecode:: ipython

   In [1]: %load_ext autoreload

   In [2]: %autoreload 2

   In [3]: from foo import some_function

   In [4]: some_function()
   Out[4]: 42

   In [5]: # open foo.py in an editor and change some_function to return 43

   In [6]: some_function()
   Out[6]: 43

The module was reloaded without reloading it explicitly, and the object
imported with ``from foo import ...`` was also updated.

Usage
=====

The following magic commands are provided:

``%autoreload``, ``%autoreload now``

    Reload all modules (except those excluded by ``%aimport``)
    automatically now.

``%autoreload 0``, ``%autoreload off``

    Disable automatic reloading.

``%autoreload 1``, ``%autoreload explicit``

    Reload all modules imported with ``%aimport`` every time before
    executing the Python code typed.

``%autoreload 2``, ``%autoreload all``

    Reload all modules (except those excluded by ``%aimport``) every
    time before executing the Python code typed.

``%autoreload 3``, ``%autoreload complete``

    Same as 2/all, but also adds any new objects in the module. See
    unit test at IPython/extensions/tests/test_autoreload.py::test_autoload_newly_added_objects

  Adding ``--print`` or ``-p`` to the ``%autoreload`` line will print autoreload activity to
  standard out. ``--log`` or ``-l`` will do it to the log at INFO level; both can be used
  simultaneously.

``%aimport``

    List modules which are to be automatically imported or not to be imported.

``%aimport foo``

    Import module 'foo' and mark it to be autoreloaded for ``%autoreload 1``

``%aimport foo, bar``

    Import modules 'foo', 'bar' and mark them to be autoreloaded for ``%autoreload 1``

``%aimport -foo``

    Mark module 'foo' to not be autoreloaded.

Caveats
=======

Reloading Python modules in a reliable way is in general difficult,
and unexpected things may occur. ``%autoreload`` tries to work around
common pitfalls by replacing function code objects and parts of
classes previously in the module with new versions. This makes the
following things to work:

- Functions and classes imported via 'from xxx import foo' are upgraded
  to new versions when 'xxx' is reloaded.

- Methods and properties of classes are upgraded on reload, so that
  calling 'c.foo()' on an object 'c' created before the reload causes
  the new code for 'foo' to be executed.

Some of the known remaining caveats are:

- Replacing code objects does not always succeed: changing a @property
  in a class to an ordinary method or a method to a member variable
  can cause problems (but in old objects only).

- Functions that are removed (eg. via monkey-patching) from a module
  before it is reloaded are not upgraded.

- C extension modules cannot be reloaded, and so cannot be autoreloaded.

- While comparing Enum and Flag, the 'is' Identity Operator is used (even in the case '==' has been used (Similar to the 'None' keyword)).

- Reloading a module, or importing the same module by a different name, creates new Enums. These may look the same, but are not.
�)�magic_arguments)�Magics�magics_class�
line_magicTN)�
import_module�reload)�source_from_cachec�F�eZdZdZ	dZ	dZ	d
d�Zd�Zd�Zd�Z	d�Z
dd	�Zy)�ModuleReloaderFTNc��i|_i|_i|_i|_i|_||_d�|_|jdd��d|_y)Nc��y�N���msgs �?/usr/lib/python3/dist-packages/IPython/extensions/autoreload.py�<lambda>z)ModuleReloader.__init__.<locals>.<lambda>����TF)�	check_all�	do_reload)	�failed�modules�skip_modules�old_objects�modules_mtimes�shell�_report�check�hide_errors)�selfrs  r�__init__zModuleReloader.__init__�sT�������������� �����
�(���	
�
�
�T�U�
�3�!��rc�\�	|j|=d|j|<y#t$rY�wxYw)z-Skip reloading the named module in the futureTN)r�KeyErrorr�r!�module_names  r�mark_module_skippedz"ModuleReloader.mark_module_skipped�s9��	����[�)�*.����+�&���	��	���
�	+�+c�\�	|j|=d|j|<y#t$rY�wxYw)z9Reload the named module in the future (if it is imported)TN)rr$rr%s  r�mark_module_reloadablez%ModuleReloader.mark_module_reloadable�s9��	��!�!�+�.�%)����[�!���	��	�r(c��|j|�t|�|jd�d}tj|}||fS)z�Import a module, and mark it reloadable

        Returns
        -------
        top_module : module
            The imported module if it is top-level, or the top-level
        top_name : module
            Name of top_module

        �.r)r*r�split�sysr)r!r&�top_name�
top_modules    r�aimport_modulezModuleReloader.aimport_module�sH��	
�#�#�K�0��k�"��$�$�S�)�!�,���[�[��*�
��8�#�#rc�x�t|d�r|j�yt|dd�dvry|j}tjj|�\}}|j
�dk(r|}n	t|�}	tj|�j}||fS#t$rYywxYw#t$rYywxYw)N�__file__)NN�__name__)N�__mp_main__�__main__z.py)�hasattrr3�getattr�os�path�splitext�lowerr	�
ValueError�stat�st_mtime�OSError)r!�module�filenamer:�ext�py_filename�pymtimes       r�filename_and_mtimez!ModuleReloader.filename_and_mtime�s����v�z�*�f�o�o�.E���6�:�t�,�0Q�Q���?�?���G�G�$�$�X�.�	��c��9�9�;�%��"�K�
"�/��9��	��g�g�k�*�3�3�G��G�#�#���
"�!�
"��
�	��	�s$�/B�;B-�	B*�)B*�-	B9�8B9c
��|js|sy|s|jr(ttjj��}n#t|jj��}|D�]}tjj
|d�}||jvr�3|j|�\}}|��J	||j|kr�^	|jj
|d�|k(r�||j|<|s��|jd|�d��	|jr't|t|j |j"�nt|t|j �||jvr
|j|=��y#t$r||j|<Y��/wxYw#|j$s>t'dj)|t+j,d��tj.��||j|<Y���xYw)z/Check whether some modules need to be reloaded.NzReloading 'z'.z[autoreload of {} failed: {}]�
)�file)�enabledr�listr.r�keys�getrrFrrr$r�autoload_obj�superreloadrrrr �print�format�	traceback�
format_exc�stderr)r!rrr�modname�mrDrEs        rrzModuleReloader.check�s����|�|�I�������3�;�;�+�+�-�.�G��4�<�<�,�,�.�/�G��(	7�G��������.�A��$�+�+�+��#'�#:�#:�1�#=� �K���"��
��d�1�1�'�:�:��;��;�;�?�?�;��5��@��+2�D����(�����{�7�)�2�6�7�7��(�(�#�A�v�t�/?�/?����L�#�A�v�t�/?�/?�@�"�d�k�k�1� �K�K��4��?(	7���
�/6��#�#�G�,��
��&7��+�+��;�B�B� '��)=�)=�b�)A��"%���	�07�D�K�K��,�s �6E?�A)F�?F�F�AG<r)FT)r4�
__module__�__qualname__rJrrNr"r'r*r1rFrrrrrr�s8���G�*��I�D��L�=�!�,.�)�$�$$�437rr)�__code__�__defaults__�__doc__�__closure__�__globals__�__dict__c	�t�tD]}	t||t||���y#ttf$rY�/wxYw)z%Upgrade the code object of a functionN)�
func_attrs�setattrr8�AttributeError�	TypeError)�old�new�names   r�update_functionrg1sB�����	��C��w�s�D�1�2����	�*�	��	�s�%�7�7c��tj|�}|D]'}t|�|us�tj	|d|��)y)z�Use garbage collector to find all instances that refer to the old
    class definition and update their __class__ to point to the new class
    definition�	__class__N)�gc�
get_referrers�type�object�__setattr__)rdre�refs�refs    r�update_instancesrq:sA��
���C� �D��6����9������s�K��5�6rc	��t|jj��D]I}t||�}	t||�}||k(dur�$	t|�r�2	t||t||���Kt|jj��D]@}|t|jj��vs�)	t||t||���Bt||�y#t$r&	t||�n#ttf$rYnwxYwY��t$rY��wxYw#ttf$rY��
wxYw#ttf$rY��wxYw)zjReplace stuff in the __dict__ of a class, and upgrade
    method code objects, and add new methods, if anyTN)rKr^rLr8rb�delattrrcr=�update_genericrarq)rdre�key�old_obj�new_objs     r�update_classrxFsX���C�L�L�%�%�'�(����#�s�#��	��c�3�'�G��7�"�t�+��,��'�7�+��	��C��g�c�3�/�0�1�8�C�L�L�%�%�'�(����d�3�<�<�,�,�.�/�/�
���S�'�#�s�"3�4���S�#���9�	�
���S�!��"�I�.�
��
����	�
�	���	�*�	��	��#�I�.�
��
�s_�C#�D�=D5�#	D�-C:�9D�:D�	D�D�D�D�D�D2�1D2�5E�Ec���t|j|j�t|j|j�t|j|j�y)z+Replace get/set/del functions of a propertyN)rt�fdel�fget�fset)rdres  r�update_propertyr}ps8���3�8�8�S�X�X�&��3�8�8�S�X�X�&��3�8�8�S�X�X�&rc�6�t||�xrt||�Sr)�
isinstance)�a�b�typs   r�isinstance2r�ws���a���4�*�Q��"4�4rc�$�t||t�Sr)r�rl�r�r�s  rrr|s��+�a��D�)�rc�8�t||tj�Sr)r��types�FunctionTyper�s  rrr}s��+�a��E�$6�$6�7�rc�$�t||t�Sr)r��propertyr�s  rrr~s��+�a��H�-�rc�8�t||tj�Sr)r�r��
MethodTyper�s  rrr�s���Q��5�+;�+;�<�rc�B�t|j|j�Sr)rg�__func__r�s  rrr�s������Q�Z�Z�@�rc�H�tD]\}}|||�s�|||�yy)NTF)�UPDATE_RULES)r�r��
type_check�updates    rrtrt�s1��*���
�F��a����1�a�L���rc��eZdZd�Zd�Zy)�	StrongRefc��||_yr��obj)r!r�s  rr"zStrongRef.__init__�s	����rc��|jSrr�)r!s r�__call__zStrongRef.__call__�s���x�x�rN)r4rWrXr"r�rrrr�r��s���rr�)r4r[�__package__�
__loader__�__spec__r3�
__cached__�__builtins__c��t|d�xr|j|jk(}|r|s|tvry|sy|j|f}	|j	|g�jt
j|��y#t$rYywxYw)NrWFT)	r7rWr4�	mod_attrs�
setdefault�append�weakrefrprc)rA�drfr��autoload�	in_modulerus       r�
append_objr��s�����\�*�P�s�~�~����/P�I���T�Y�.�����?�?�D�
!�C�
�	���S�"��$�$�W�[�[��%5�6����
���
�s�4A<�<	B�Bc��|�i}t|jj��D]W\}}t||||�s�|j|f}	|j|g�j
tj|���Y	|jj�}|j}|jj�||jd<|d|jd<	||�}t|jj��D]{\}}	|j|f}||vr&|�|dk(st||||	d�s�/|	|j|<g}
||D])}|�}|��
|
j
|�t!||	��+|
r|
||<�y||=�}|S#t$rY��twxYw#tttf$rY��wxYw#|jj��xYw)a2Enhanced version of the builtin reload function.

    superreload remembers objects previously in the module, and

    - upgrades the class dictionary of every old class in the module
    - upgrades the code object of every old function and method
    - clears the module's namespace before reloading

    r4r��EnumT)rKr^�itemsr�r4r�r�r�rprc�copy�clearrbr$r��user_nsrt)
rArrrrfr�ru�old_dict�old_namerw�new_refs�old_refrvs
             rrOrO�s��������&�/�/�/�/�1�2��	��c��&�+�t�S�9������%��	��"�"�3��+�2�2�7�;�;�s�3C�D��
��?�?�'�'�)���?�?��������&.����
�#�(0��(>�����%�������f�o�o�3�3�5�6�!�
��g�����%���k�!��
��6�>�!�&�+�t�W�d�K��")�E�M�M�$����"�3�'�	-�G��i�G�����O�O�G�$��7�G�,�	-��'�K����C� �/!�2�M��_�	��	��
�~�x�0�
��
��
������x�(�
�s1�4F�A!F �%F:�	F�F� F7�6F7�:Gc�D��eZdZ�fd�Zeej
�ejdeddd��ejddd	d
d��ejd
dd	d
d��ejdd	d
d��dd�������Zedd��Z	d�Z
d�Z�xZS)�AutoreloadMagicsc����t�|�|i|��t|j�|_d|j_d|j_ttj�|_
y)NF)�superr"rr�	_reloaderrrN�setr.r�loaded_modules)r!r��kwris   �rr"zAutoreloadMagics.__init__sN���
���!�"�r�"�'��
�
�3���#(���� �&+����#�!�#�+�+�.��r�mode�now�?aGblank or 'now' - Reload all modules (except those excluded by %%aimport)
             automatically now.

             '0' or 'off' - Disable automatic reloading.

             '1' or 'explicit' - Reload only modules imported with %%aimport every
             time before executing the Python code typed.

             '2' or 'all' - Reload all modules (except those excluded by %%aimport)
             every time before executing the Python code typed.

             '3' or 'complete' - Same as 2/all, but also but also adds any new
             objects in the module.
             )rl�default�nargs�helpz-pz--print�
store_trueFz1Show autoreload activity using `print` statements)�actionr�r�z-lz--logz)Show autoreload activity using the loggerz
--hide-errorszHide autoreload errorsc�<���tj|j|�}|jj	�}t
�t
jd�}|j���fd�}|j
dur!|jdurd�|j_n_|j
dur2|jdur||j_n1�|j_n|jdur�|j_|j|j_|dk(s|dk(r|jjd�y|dk(s|d	k(rd|j_y|d
k(s|dk(r4d|j_d|j_d|j_y|dk(s|d
k(r4d|j_d|j_d|j_y|dk(s|dk(r4d|j_d|j_d|j_yt#d|�d���)a*	%autoreload => Reload modules automatically

        %autoreload or %autoreload now
        Reload all modules (except those excluded by %aimport) automatically
        now.

        %autoreload 0 or %autoreload off
        Disable automatic reloading.

        %autoreload 1 or %autoreload explicit
        Reload only modules imported with %aimport every time before executing
        the Python code typed.

        %autoreload 2 or %autoreload all
        Reload all modules (except those excluded by %aimport) every time
        before executing the Python code typed.

        %autoreload 3 or %autoreload complete
        Same as 2/all, but also but also adds any new objects in the module. See
        unit test at IPython/extensions/tests/test_autoreload.py::test_autoload_newly_added_objects

        The optional arguments --print and --log control display of autoreload activity. The default
        is to act silently; --print (or -p) will print out the names of modules that are being
        reloaded, and --log (or -l) outputs them to the log at INFO level.

        The optional argument --hide-errors hides any errors that can happen when trying to
        reload code.

        Reloading Python modules in a reliable way is in general
        difficult, and unexpected things may occur. %autoreload tries to
        work around common pitfalls by replacing function code objects and
        parts of classes previously in the module with new versions. This
        makes the following things to work:

        - Functions and classes imported via 'from xxx import foo' are upgraded
          to new versions when 'xxx' is reloaded.

        - Methods and properties of classes are upgraded on reload, so that
          calling 'c.foo()' on an object 'c' created before the reload causes
          the new code for 'foo' to be executed.

        Some of the known remaining caveats are:

        - Replacing code objects does not always succeed: changing a @property
          in a class to an ordinary method or a method to a member variable
          can cause problems (but in old objects only).

        - Functions that are removed (eg. via monkey-patching) from a module
          before it is reloaded are not upgraded.

        - C extension modules cannot be reloaded, and so cannot be
          autoreloaded.

        �
autoreloadc�&���|��|�yrr)r�l�ps ��r�plz'AutoreloadMagics.autoreload.<locals>.plvs���
�c�F�
�c�FrFc��yrrrs rrz-AutoreloadMagics.autoreload.<locals>.<lambda>{rrT�r��0�off�1�explicit�2�all�3�completezUnrecognized autoreload mode "z".N)r�parse_argstringr�r�r<rP�logging�	getLogger�info�logr�rr rrJrrNr=)r!�line�argsr��loggerr�r�r�s      @@rr�zAutoreloadMagics.autoreloads����B�.�.�t����E���y�y��� �����"�"�<�0���K�K��	��:�:���4�8�8�u�#4�%5�D�N�N�"�
�Z�Z�4�
��x�x�4��)+����&�)*����&�
�X�X��
�%&�D�N�N�"�%)�%5�%5����"��2�:�����N�N� � ��&�
�S�[�D�E�M�%*�D�N�N�"�
�S�[�D�J�.�%)�D�N�N�"�',�D�N�N�$�*/�D�N�N�'�
�S�[�D�E�M�%)�D�N�N�"�'+�D�N�N�$�*/�D�N�N�'�
�S�[�D�J�.�%)�D�N�N�"�'+�D�N�N�$�*.�D�N�N�'��=�d�V�2�F�G�Grc�&�|}|s�t|jjj��}t|jjj��}|�t
j}|jjr|jd�n#|jddj|�z�|jddj|�z�y|jd�D�cgc]}|j���c}D]}}|jd�r/|ddj�}|jj|��C|jj|�\}}	|jj!|	|i��ycc}w)	a"%aimport => Import modules for automatic reloading.

        %aimport
        List modules to automatically import and not to import.

        %aimport foo
        Import module 'foo' and mark it to be autoreloaded for %autoreload explicit

        %aimport foo, bar
        Import modules 'foo', 'bar' and mark them to be autoreloaded for %autoreload explicit

        %aimport -foo, bar
        Mark module 'foo' to not be autoreloaded for %autoreload explicit, all, or complete, and 'bar'
        to be autoreloaded for mode explicit.
        Nz&Modules to reload:
all-except-skipped
zModules to reload:
%s
� z
Modules to skip:
%s
�,�-�)�sortedr�rrLrr.�stdoutr�write�joinr-�strip�
startswithr'r1r�push)
r!�parameter_s�streamrU�	to_reload�to_skip�_�_moduler0r/s
          r�aimportzAutoreloadMagics.aimport�s4��"����t�~�~�5�5�:�:�<�=�I��T�^�^�8�8�=�=�?�@�G��~������~�~�'�'����G�H����7�#�(�(�9�:M�M�N��L�L�3�c�h�h�w�6G�G�H�/6�}�}�S�/A�B�!�A�G�G�I�B�
<���%�%�c�*�%�a�b�k�/�/�1�G��N�N�6�6�w�?�+/�>�>�+H�+H��+Q�(�J���J�J�O�O�X�z�$:�;�
<��Bs�3Fc�v�|jjr	|jj�yy#YyxYwr)r�rJr)r!r�s  r�pre_run_cellzAutoreloadMagics.pre_run_cell�s3���>�>�!�!�
����$�$�&�"��
��s�4�8c�*�ttj�|jz
}|D]M}|jjtj|�\}}|��5||jj|<�O|jj|�y)zFCache the modification times of any modules imported in this executionN)r�r.rr�r�rFrr�)r!�newly_loaded_modulesrUr�rEs     r�post_execute_hookz"AutoreloadMagics.post_execute_hook�s��"�3�;�;�/�$�2E�2E�E��+�	A�G����:�:�3�;�;�w�;O�P�J�A�w��"�9@����-�-�g�6�	A�
	
���"�"�#7�8r)r�)r�N)
r4rWrXr"rr�argument�strr�r�r�r��
__classcell__)ris@rr�r�s����/��$�_�$�$�&��_����
���
��(�_�������
@���_�������
8���_������
%�	�aH�
���)�'��TaH�F�$<��$<�L�9rr�c���t|�}|j|�|jjd|j�|jjd|j
�y)zLoad the extension in IPython.r��post_executeN)r��register_magics�events�registerr�r�)�ip�auto_reloads  r�load_ipython_extensionr��sN��"�2�&�K����{�#��I�I���~�{�'?�'?�@��I�I���~�{�'D�'D�Er)F)$r[�IPython.corer�IPython.core.magicrrr�__skip_doctest__r9r.rRr�r�rjr��	importlibrr�importlib.utilr	rr`rgrqrxr}r�r��extendrtr�r�r�rOr�r�rrr�<module>rs���i�V)�?�?���$
�
����	��+�,�O7�O7�n�
��	6�'�T'�5�
*�<�8�7��I�-��?���

���
=�@�	
������	
�	��$ &�4�t�C�V�K9�v�K9��K9�\Fr

Youez - 2016 - github.com/yon3zu
LinuXploit