Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/dill/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/dill/__pycache__/session.cpython-311.pyc

�

�܋f�[�	���dZgd�ZddlZddlZddlZddlZddlmZmZm	Z	ddlm
Z
mZmZm
Z
mZmZmZmZmZmZmZddlmZmZddlZddlZejej����Zd�Ze
eeee
fZd	evreed	fz
Zd
Ze d�eD����Zd�Z!d
�Z"d�Z#			ddee$ej%fdeee
e$fde&ddfd�Z'dd�Z(e'je(_Gd�d��Z)d�Z*d d�Z+		d!dee$ej%fdeee
e$fdee
fd�Z,d!d�Z-e,je-_		d"dee$ej%fde&de.fd�Z/dD]Z0e1ee0e2��e0���[0dS)#z,
Pickle and restore the intepreter session.
)�dump_module�load_module�load_module_asdict�dump_session�load_session�N)�_dill�Pickler�	Unpickler�)�BuiltinMethodType�FunctionType�
MethodType�
ModuleType�TypeType�_import_module�_is_builtin_module�_is_imported_module�_main_module�_reverse_typemap�__builtin__)�Optional�Unionc��ddlm}ddlm}||t��|t��i���}t
j���D]�\}}|dvst|t��s�d|vr||j
t|��<|j���D]W\}}|j
|�||f��|jt|���|||f���X��|S)zget map of imported modulesr)�defaultdict)�SimpleNamespace)�by_name�by_id�	top_level)�__main__�__mp_main__�.)�collectionsr�typesr�list�sys�modules�items�
isinstancerr�id�__dict__r�appendr)rr�modmap�modname�module�objname�modobjs       �]/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/dill/session.py�_module_mapr2&s5��'�'�'�'�'�'�%�%�%�%�%�%�
�_���D�!�!��k�$�������F�
�;�,�,�.�.�H�H�����1�1�1��F�J�9W�9W�1���g���+2�F��R��Z�Z�(�%��4�4�6�6�	H�	H�O�G�V��N�7�#�*�*�F�G�+<�=�=�=��L��F���$�+�+�V�W�g�,F�G�G�G�G�	H��M��
PyCapsuleType)�ctypes�typing�
subprocess�	threadingzconcurrent\.futures(\.\w+)?zmultiprocessing(\.\w+)?c#�>K�|]}tj|��V��dS�N)�re�compile)�.0�xs  r1�	<genexpr>r?>s*����G�G�a�B�J�q�M�M�G�G�G�G�G�Gr3c�p��|j|D]#\}}||urtj||ur||fcS�$t|dd���t	|t
��s"��[t
�fd�tD����r;|jt|��D] \}}}tj||ur||fcS�!dS)z.lookup name or id of obj if module is imported�
__module__Nc3�B�K�|]}|����V��dSr:)�	fullmatch)r=�regexrAs  �r1r?z!_lookup_module.<locals>.<genexpr>Gs/�����Q�Q�E�E�O�O�J�/�/�Q�Q�Q�Q�Q�Qr3�NN)
rr%r&�getattrr(�IMPORTED_AS_TYPES�any�IMPORTED_AS_MODULESrr))r,�name�obj�main_moduler0r-r/rAs       @r1�_lookup_modulerM@s����!�>�$�/�!�!�����S�=�=�S�[��1��D�D��D�=� � � ����l�D�1�1�J��#�(�)�)�(�j�.D��Q�Q�Q�Q�=P�Q�Q�Q�Q�Q�/E�(.��R��W�W�(=�	(�	(�$�F�G�W��{�7�#�;�6�6���'�'�'�'�7��:r3c��
�t��}t|j��}g}g}g}i}|j���D]�\}�
�
|ur|||<��
|jur|j||<�#t�
fd�dD����s$t
�
t��rt�
��r�
||<�ht||�
|��\}}	|�7|	|kr|�	||f����|�	||	|f����	|�	|j
t�
��|f����#t$r�
||<Y��wxYwt|��t|j��krX|j�|��||_||_||_t%|dd���t'|��rd|_|S|S)Nc3� �K�|]}�|uV��	dSr:�)r=�	singletonrKs  �r1r?z!_stash_modules.<locals>.<genexpr>[s(�����G�G�i��	�!�G�G�G�G�G�Gr3)NFT�
__loader__T)r2r�__name__r*r'rHr(rrMr+rr)�KeyError�len�update�__dill_imported�__dill_imported_as�__dill_imported_top_levelrFrrR)rLr,�newmod�imported�imported_as�imported_top_level�originalrJ�
source_moduler/rKs          @r1�_stash_modulesr`Ms���
�]�]�F�
��,�
-�
-�F��H��K����H� �)�/�/�1�1�)�)�	��c��+���#�H�T�N�N�
�K�(�
(�
(�#�_�H�T�N�N�
�G�G�G�G�3F�G�G�G�
G�
G�	)��c�:�.�.�	)�3E�c�3J�3J�	)� �H�T�N�N�%3�F�D�#�{�%S�%S�"�M�7��(��d�?�?��O�O�]�D�$9�:�:�:�:��&�&�
�w��'E�F�F�F�F�)�&�-�-�v�/?��3���/H�$�.O�P�P�P�P���)�)�)�%(�H�T�N�N�N�)�����8�}�}�s�;�/�0�0�0�0�����x�(�(�(�!)���$/��!�+=��(��6�<��.�.�6�;N�{�;[�;[�6� $�F���
��s�</D,�,D>�=D>c��	|j�d��D]#\}}|�||��|j|<�$|j�d��D]$\}}}|�||��|j|<�%|j�d��D]\}}t|��|j|<�dS#t$rYdSwxYw)NrWrXrY)r*�pop�
find_class�
__import__rT)�	unpicklerrLr-rJr/s     r1�_restore_modulesrfws��
�(�1�5�5�6G�H�H�	M�	M�M�G�T�)2�)=�)=�g�t�)L�)L�K� ��&�&�&1�&:�&>�&>�?S�&T�&T�	P�	P�"�G�W�d�)2�)=�)=�g�w�)O�)O�K� ��&�&�(�1�5�5�6Q�R�R�	=�	=�M�G�T�)3�G�)<�)<�K� ��&�&�	=�	=���
�
�
����
���s�B4B8�8
C�CF�filenamer.�refimported�returnc��dD]c\}}||vrZd|�d|��}|dkr|dz
}tj|dzt��t��|rt	d|�d|�d	�����d|�d|��}|�d
|��}ddlm}|d
}|}	|	�t}	n$t|	t��rt|	��}	t|	t��st	d|	z���t|d��r|}
n)|�ttdz��}t|d��}
	t|
|fi|��}|	|_|rt#|	��}	|	|_d|_d|_d|_d|_|	|ju|_|�|	��|
|ur|
���n#|
|ur|
���wwxYwdS)a�Pickle the current state of :py:mod:`__main__` or another module to a file.

    Save the contents of :py:mod:`__main__` (e.g. from an interactive
    interpreter session), an imported module, or a module-type object (e.g.
    built with :py:class:`~types.ModuleType`), to a file. The pickled
    module can then be restored with the function :py:func:`load_module`.

    Args:
        filename: a path-like object or a writable stream. If `None`
            (the default), write to a named file in a temporary directory.
        module: a module object or the name of an importable module. If `None`
            (the default), :py:mod:`__main__` is saved.
        refimported: if `True`, all objects identified as having been imported
            into the module's namespace are saved by reference. *Note:* this is
            similar but independent from ``dill.settings[`byref`]``, as
            ``refimported`` refers to virtually all imported objects, while
            ``byref`` only affects select objects.
        **kwds: extra keyword arguments passed to :py:class:`Pickler()`.

    Raises:
       :py:exc:`PicklingError`: if pickling fails.

    Examples:

        - Save current interpreter session state:

          >>> import dill
          >>> squared = lambda x: x*x
          >>> dill.dump_module() # save state of __main__ to /tmp/session.pkl

        - Save the state of an imported/importable module:

          >>> import dill
          >>> import pox
          >>> pox.plus_one = lambda x: x+1
          >>> dill.dump_module('pox_session.pkl', module=pox)

        - Save the state of a non-importable, module-type object:

          >>> import dill
          >>> from types import ModuleType
          >>> foo = ModuleType('foo')
          >>> foo.values = [1,2,3]
          >>> import math
          >>> foo.sin = math.sin
          >>> dill.dump_module('foo_session.pkl', module=foo, refimported=True)

        - Restore the state of the saved modules:

          >>> import dill
          >>> dill.load_module()
          >>> squared(2)
          4
          >>> pox = dill.load_module('pox_session.pkl')
          >>> pox.plus_one(1)
          2
          >>> foo = dill.load_module('foo_session.pkl')
          >>> [foo.sin(x) for x in foo.values]
          [0.8414709848078965, 0.9092974268256817, 0.1411200080598672]

        - Use `refimported` to save imported objects by reference:

          >>> import dill
          >>> from html.entities import html5
          >>> type(html5), len(html5)
          (dict, 2231)
          >>> import io
          >>> buf = io.BytesIO()
          >>> dill.dump_module(buf) # saves __main__, with html5 saved by value
          >>> len(buf.getvalue()) # pickle size in bytes
          71665
          >>> buf = io.BytesIO()
          >>> dill.dump_module(buf, refimported=True) # html5 saved by reference
          >>> len(buf.getvalue())
          438

    *Changed in version 0.3.6:* Function ``dump_session()`` was renamed to
    ``dump_module()``.  Parameters ``main`` and ``byref`` were renamed to
    ``module`` and ``refimported``, respectively.

    Note:
        Currently, ``dill.settings['byref']`` and ``dill.settings['recurse']``
        don't apply to this function.
    ))�mainr.)�byrefrhz
The argument z has been renamed rlz. to distinguish it from dill.settings['byref']r!zboth z and z arguments were usedrkr)�settings�protocolN�%r is not a module�write�session.pkl�wbFT)�warnings�warn�PendingDeprecationWarning�locals�	TypeErrorrbrmrr(�strrr�hasattr�TEMPDIR�openr	�_original_mainr`�_main�_byref�_recurse�_session�_first_pass�_main_modified�dump�close)rgr.rh�kwds�old_par�par�messagermrnrk�file�picklers            r1rr�s.��tG�W�W�����d�?�?�?�?F�w�w���L�G��'�!�!��K�K���M�'�C�-�)B�C�C�C��x�x��}�
W��i����W�W�W� U�V�V�V���(�(�7�K�0�0�K�
�X�X�f�f�
%�
%�F�"�"�"�"�"�"��
�#�H��D��|����	�D�#�	�	�$��d�#�#���d�J�'�'�5��,�t�3�4�4�4��x��!�!�$�������7�=�0�1�1�H��H�d�#�#����$��1�1�D�1�1��!%����	(�!�$�'�'�D���
���� ������"���!%�W�-C�!C������T�����x����J�J�L�L�L����x����J�J�L�L�L�L� ����
�Fs
�5A,F:�:Gc�Z�tjdt��t|f||d�|��dS)Nz-dump_session() has been renamed dump_module())r.rh)rsrtrur)rgrkrlr�s    r1rr	s9���M�A�C\�]�]�]���A��5�A�A�D�A�A�A�A�Ar3c�6�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	dS)	�_PeekableReaderz1lightweight stream wrapper that implements peek()c��||_dSr:)�stream)�selfr�s  r1�__init__z_PeekableReader.__init__s
������r3c�6�|j�|��Sr:)r��read)r��ns  r1r�z_PeekableReader.reads���{����"�"�"r3c�4�|j���Sr:)r��readline�r�s r1r�z_PeekableReader.readlines���{�#�#�%�%�%r3c�4�|j���Sr:)r��tellr�s r1r�z_PeekableReader.tells���{���!�!�!r3c�4�|j���Sr:)r�r�r�s r1r�z_PeekableReader.closes���{� � �"�"�"r3c�P�|j}	t|d��r|���|���}|�|��|�|��}|�|��|S#ttf$rtd|��d�wxYw)N�flushzstream is not peekable: %r)	r�ryr�r��seekr��AttributeError�OSError�NotImplementedError)r�r�r��position�chunks     r1�peekz_PeekableReader.peeks������	V��v�w�'�'�7��������{�{�}�}�H��K�K��!�!�!��K�K��N�N�E��K�K��!�!�!��L����(�	V�	V�	V�%�&B�F�K�K�QU�U�	V���s�A8B�#B%N)
rSrA�__qualname__�__doc__r�r�r�r�r�r�rPr3r1r�r�sy������;�;����#�#�#�&�&�&�"�"�"�#�#�#�
V�
V�
V�
V�
Vr3r�c���ddl}t|d��r|St|d��rt|d��s&	|�|��S#t$rYnwxYwt	|��S)z/return stream as an object with a peek() methodrNr�r�r�)�iory�BufferedReader�	Exceptionr�)r�r�s  r1�_make_peekabler�&s���
�I�I�I��v�v�����
��F�F�#�#�����(?�(?��	��$�$�V�,�,�,���	�	�	��D�	�����6�"�"�"s�A
�
A�Ac�p�ddlm}hd�}d}	||�d����D]6\}}}|s!|jdvr|�d��rd}�)|j|vr|cS�7td	���#ttf$r2}t|t��r|�Yd
}~d
Std��|�d
}~wwxYw)zDidentify the name of the module stored in the given file-type objectr)�genops>�UNICODE�
BINUNICODE�SHORT_BINUNICODEF�)�GLOBALr�rTz(reached STOP without finding main moduleNzunable to identify main module)	�pickletoolsr�r�rJ�endswith�UnpicklingErrorr��
ValueErrorr()	r�rkr�r��found_import�opcode�arg�pos�errors	         r1�_identify_moduler�2s��"�"�"�"�"�"�;�;�;�G��L�K� &��t�y�y��~�~� 6� 6�		N�		N��F�C���
��;�"@�@�@����%5�6�6�A�#'�L���;�'�)�)��J�J�J�*�"�"L�M�M�M����,�K�K�K��e�0�1�1�	�d�6F��4�4�4�4�4��>�?�?�U�J�����K���s$�AA2�"A2�2B5�B0� B0�0B5c�T�d|vr@tjdt��|�td���|�d��}|}t|d��r|}n)|�t
tdz��}t|d��}	t|��}t|fi|��}d|_t||��}|�|�|}t|t��rM|�d	��r)t|�d
��d��}nt#|��}|�/t|t��std|z���||_n|j}t'|��}|��|�d	��}|r|�d
��d}d
}	|r1|r/t)|	�dddd��|j|fz���|s1|s/t)|	�dddd��||jfz���|j|kr/t)|	�dddd��|j|fz���|sd|jz}
|t.j|
<|���}t|d��s|���	t.j|
=ne#t6t8f$rYnRwxYw#t|d��s|���	t.j|
=w#t6t8f$rYwwxYwxYw||usJ�t;||��|t<us||urdS|S)agUpdate the selected module (default is :py:mod:`__main__`) with
    the state saved at ``filename``.

    Restore a module to the state saved with :py:func:`dump_module`. The
    saved module can be :py:mod:`__main__` (e.g. an interpreter session),
    an imported module, or a module-type object (e.g. created with
    :py:class:`~types.ModuleType`).

    When restoring the state of a non-importable module-type object, the
    current instance of this module may be passed as the argument ``main``.
    Otherwise, a new instance is created with :py:class:`~types.ModuleType`
    and returned.

    Args:
        filename: a path-like object or a readable stream. If `None`
            (the default), read from a named file in a temporary directory.
        module: a module object or the name of an importable module;
            the module name and kind (i.e. imported or non-imported) must
            match the name and kind of the module stored at ``filename``.
        **kwds: extra keyword arguments passed to :py:class:`Unpickler()`.

    Raises:
        :py:exc:`UnpicklingError`: if unpickling fails.
        :py:exc:`ValueError`: if the argument ``main`` and module saved
            at ``filename`` are incompatible.

    Returns:
        A module object, if the saved module is not :py:mod:`__main__` or
        a module instance wasn't provided with the argument ``main``.

    Examples:

        - Save the state of some modules:

          >>> import dill
          >>> squared = lambda x: x*x
          >>> dill.dump_module() # save state of __main__ to /tmp/session.pkl
          >>>
          >>> import pox # an imported module
          >>> pox.plus_one = lambda x: x+1
          >>> dill.dump_module('pox_session.pkl', module=pox)
          >>>
          >>> from types import ModuleType
          >>> foo = ModuleType('foo') # a module-type object
          >>> foo.values = [1,2,3]
          >>> import math
          >>> foo.sin = math.sin
          >>> dill.dump_module('foo_session.pkl', module=foo, refimported=True)

        - Restore the state of the interpreter:

          >>> import dill
          >>> dill.load_module() # updates __main__ from /tmp/session.pkl
          >>> squared(2)
          4

        - Load the saved state of an importable module:

          >>> import dill
          >>> pox = dill.load_module('pox_session.pkl')
          >>> pox.plus_one(1)
          2
          >>> import sys
          >>> pox in sys.modules.values()
          True

        - Load the saved state of a non-importable module-type object:

          >>> import dill
          >>> foo = dill.load_module('foo_session.pkl')
          >>> [foo.sin(x) for x in foo.values]
          [0.8414709848078965, 0.9092974268256817, 0.1411200080598672]
          >>> import math
          >>> foo.sin is math.sin # foo.sin was saved by reference
          True
          >>> import sys
          >>> foo in sys.modules.values()
          False

        - Update the state of a non-importable module-type object:

          >>> import dill
          >>> from types import ModuleType
          >>> foo = ModuleType('foo')
          >>> foo.values = ['a','b']
          >>> foo.sin = lambda x: x*x
          >>> dill.load_module('foo_session.pkl', module=foo)
          >>> [foo.sin(x) for x in foo.values]
          [0.8414709848078965, 0.9092974268256817, 0.1411200080598672]

    *Changed in version 0.3.6:* Function ``load_session()`` was renamed to
    ``load_module()``. Parameter ``main`` was renamed to ``module``.

    See also:
        :py:func:`load_module_asdict` to load the contents of module saved
        with :py:func:`dump_module` into a dictionary.
    rkz.The argument 'main' has been renamed 'module'.Nz,both 'module' and 'main' arguments were usedr�rq�rbTz__runtime__.r!���roz@can't update{} module{} %r with the saved state of{} module{} %rz	 imported�z-type objectz__runtime__.%s)rsrtrurwrbryrxrzr{r�r
r�r�r(�
startswithr�	partitionrr}rr��formatrSr%r&�loadr�rT�	NameErrorrfr)rgr.r�rkr�re�pickle_main�is_main_imported�is_runtime_mod�	error_msg�runtime_main�loadeds            r1rrIs���L��~�~��
�<�%�	
�	
�	
����J�K�K�K����&�!�!���D��x�� � �$�������7�=�0�1�1�H��H�d�#�#��7��d�#�#���d�+�+�d�+�+�	�!�	��'�t�T�2�2���<�K�3��D��d�C� � �	,����~�.�.�
,�!�$�.�.��"5�"5�b�"9�:�:���%�d�+�+�����d�J�/�/�
=�� 4�t� ;�<�<�<�"�I�O�O��?�D�/�t�4�4���"�(�3�3�N�C�C�N��
=�)�3�3�C�8�8��<��Z�I��
�"2�
� ��$�$�[�"�b�.�I�I��}�k�2�3����"�
�*:�
� ��$�$�R���b�I�I�"�D�M�2�3�����}��+�+� ��!1�!1�"�b�"�b�!A�!A�T�]�T_�D`�!`�a�a�a� �	-�+�d�m�;�L�(,�C�K��%����!�!���x��(�(�	��J�J�L�L�L�	���L�)�)���)�$�	�	�	��D�	�����	�x��(�(�	��J�J�L�L�L�	���L�)�)���)�$�	�	�	��D�	��������T�>�>�>�>��Y��%�%�%��|���t�v�~�~��t��sC�G'J5�
J�J2�1J2�5%L�
K)�(L�)K=�:L�<K=�=Lc�X�tjdt��t|fd|i|��dS)Nz.load_session() has been renamed load_module().r.)rsrtrur)rgrkr�s   r1rr�s7���M�B�D]�^�^�^���.�.��.��.�.�.�.�.r3rVc��d|vrtd���t|d��r|}n)|�ttdz��}t	|d��}	t|��}t
|��}tj�	|��}t|��}|r1|�t|��}|j�
|j��nt|_|tj|<t!|fi|��t|d��s|���	|�tj|=n|tj|<ni#t$$rYn]wxYw#t|d��s|���	|�tj|=w|tj|<w#t$$rYwwxYwxYwt|��|_|jS)ay
    Load the contents of a saved module into a dictionary.

    ``load_module_asdict()`` is the near-equivalent of::

        lambda filename: vars(dill.load_module(filename)).copy()

    however, does not alter the original module. Also, the path of
    the loaded module is stored in the ``__session__`` attribute.

    Args:
        filename: a path-like object or a readable stream. If `None`
            (the default), read from a named file in a temporary directory.
        update: if `True`, initialize the dictionary with the current state
            of the module prior to loading the state stored at filename.
        **kwds: extra keyword arguments passed to :py:class:`Unpickler()`

    Raises:
        :py:exc:`UnpicklingError`: if unpickling fails

    Returns:
        A copy of the restored module's dictionary.

    Note:
        If ``update`` is True, the corresponding module may first be imported
        into the current namespace before the saved state is loaded from
        filename to the dictionary. Note that any module that is imported into
        the current namespace as a side-effect of using ``update`` will not be
        modified by loading the saved module in filename to a dictionary.

    Example:
        >>> import dill
        >>> alist = [1, 2, 3]
        >>> anum = 42
        >>> dill.dump_module()
        >>> anum = 0
        >>> new_var = 'spam'
        >>> main = dill.load_module_asdict()
        >>> main['__name__'], main['__session__']
        ('__main__', '/tmp/session.pkl')
        >>> main is globals() # loaded objects don't reference globals
        False
        >>> main['alist'] == alist
        True
        >>> main['alist'] is alist # was saved by value
        False
        >>> main['anum'] == anum # changed after the session was saved
        False
        >>> new_var in main # would be True if the option 'update' was set
        False
    r.z@'module' is an invalid keyword argument for load_module_asdict()r�Nrqr�)rwryrxrzr{r�r�r%r&�getrrr*rVr�__builtins__rr�r��__session__)rgrVr�r��	main_name�old_mainrks       r1rrs���p�4����Z�[�[�[��x�� � �$�������7�=�0�1�1�H��H�d�#�#����d�#�#��$�T�*�*�	��;�?�?�9�-�-���)�$�$���	,���)�)�4�4���M� � ��!2�3�3�3�3� +�D��!%���I���D�!�!�D�!�!�!��x��(�(�	��J�J�L�L�L�	����K�	�*�*�)1���I�&����	�	�	��D�	������x��(�(�	��J�J�L�L�L�	����K�	�*�*�)1���I�&�&���	�	�	��D�	��������8�}�}�D���=�sO�B'E
�D=�=
E
�	E
�
%F#�3F�F#�F�F#�
F �F#�F � F#)rMr2rfr`rr)NNFr:rE)NF)3r��__all__r;�osr%rs�dillrr	r
rr
rrrrrrrrrr6rr�pathlib�tempfile�PurePath�
gettempdirrzr2rGrI�tuplerMr`rfrx�PathLike�boolrrr�r�r�rr�dictrrJ�setattr�globalsrPr3r1�<module>r�s���������

�	�	�	�	�	�	�	�
�
�
�
�����*�*�*�*�*�*�*�*�*�*���������������������������#�"�"�"�"�"�"�"���������
�'�
�.�8�.�0�0�
1�
1�����& ��<��EV�W���&�&�&��*�?�;�=�=��[���e�G�G�3F�G�G�G�G�G�����(�(�(�T	
�	
�	
�)-�/3��C�C��C���$�%�C��U�:�s�?�+�,�C��C�

�C�C�C�C�LB�B�B�B�#�*���V�V�V�V�V�V�V�V�0
#�
#�
#�K�K�K�K�0)-�/3�r�r��C���$�%�r��U�:�s�?�+�,�r��j��	r�r�r�r�j/�/�/�/�#�*���)-��X�X��C���$�%�X��X�
�	X�X�X�X�z
�*�*�D��G�E�4�����4��)�)�)�)��D�Dr3

Hacked By AnonymousFox1.0, Coded By AnonymousFox