HEX
Server: LiteSpeed
System: Linux us-phx-web1284.main-hosting.eu 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: u300739242 (300739242)
PHP: 8.2.30
Disabled: system, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/alt/python311/lib/python3.11/site-packages/jsons/__pycache__/decorators.cpython-311.pyc
�

)�;f}���dZddlmZmZmZmZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZddee	fd�Zddeefd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�ZdS)zb
This module contains decorators that facilitate the `jsons` functions in an
alternative fashion.
�)�	signature�	Parameter�isawaitable�iscoroutinefunction)�JsonSerializable�dump�load�loads�loadb�dumps�dumpb)�InvalidDecorationErrorTc�r�|tttfvrtd���t	|||||��S)a�
    Return a decorator that can call `jsons.load` upon all parameters and the
    return value of the decorated function.


    **Example**:

    >>> from datetime import datetime
    >>> @loaded()
    ... def func(arg: datetime) -> datetime:
    ...     # arg is now of type datetime.
    ...     return '2018-10-04T21:57:00Z'  # This will become a datetime.
    >>> res = func('2018-10-04T21:57:00Z')
    >>> type(res).__name__
    'datetime'

    :param parameters: determines whether parameters should be taken into
    account.
    :param returnvalue: determines whether the return value should be taken
    into account.
    :param fork_inst: if given, it uses this fork of ``JsonSerializable``.
    :param kwargs: any keyword arguments that should be passed on to
    `jsons.load`
    :param loader: the load function which must be one of (``load``,
    ``loads``, ``loadb``)
    :return: a decorator that can be placed on a function.
    zJThe 'loader' argument must be one of: jsons.load, jsons.loads, jsons.loadb)r	r
rr�_get_decorator)�
parameters�returnvalue�	fork_inst�loader�kwargss     �C/opt/alt/python311/lib/python3.11/site-packages/jsons/decorators.py�loadedr�H��B�d�E�5�)�)�)�$�&L�M�M�	M��*�k�9�f�f�M�M�M�c�r�|tttfvrtd���t	|||||��S)ac
    Return a decorator that can call `jsons.dump` upon all parameters and the
    return value of the decorated function.


    **Example**:

    >>> from datetime import datetime
    >>> @dumped()
    ... def func(arg):
    ...     # arg is now of type str.
    ...     return datetime.now()
    >>> res = func(datetime.now())
    >>> type(res).__name__
    'str'

    :param parameters: determines whether parameters should be taken into
    account.
    :param returnvalue: determines whether the return value should be taken
    into account.
    :param fork_inst: if given, it uses this fork of ``JsonSerializable``.
    :param kwargs: any keyword arguments that should be passed on to
    `jsons.dump`
    :param dumper: the dump function which must be one of (``dump``,
    ``dumps``, ``dumpb``)
    :return: a decorator that can be placed on a function.
    zJThe 'dumper' argument must be one of: jsons.dump, jsons.dumps, jsons.dumpb)rrr
rr)rrr�dumperrs     r�dumpedr2rrc�"�����������fd�}|S)Nc�z��t|���|�����g}t|��r	t|�nt|�}|S�N)�_validate_decorationr�_get_async_wrapper�_get_wrapper)�	decorated�args�wrapperr�mapper�
mapper_kwargsrrs   �����r�
_decoratorz"_get_decorator.<locals>._decoratorZsU����Y�	�2�2�2��:�{��6�=�2��0C�I�0N�0N�,�%�t�,�,�$�d�+�	��r�)rrrr&r'r(s````` rrrYs<�����������������rc�&�������������fd�}|S)Nc�b��t��r�nd�||���}�rt|������}|Sr)�_run_decorated�_map_returnvalue�	r$r�resultr#rr&r'rrs	   ������r�_wrapperz_get_wrapper.<locals>._wrapperlsQ����	�Z�+I�6�6�T� )�4���H�H���	5�%�f�i��F�&3�5�5�F��
rr))r#rrrr&r'r0s`````` rr"r"esA�������������������Orc�&�������������fd�}|S)Nc���K�t��r�nd�||���}t|��r|�d{V��}�rt|������}|Sr)r,rr-r.s	   ������r�_async_wrapperz*_get_async_wrapper.<locals>._async_wrapper~sv������	�Z�+I�6�6�T� )�4���H�H���v���	"�!�\�\�\�\�\�\�F��	5�%�f�i��F�&3�5�5�F��
rr))r#rrrr&r'r3s`````` rr!r!wsB�������������������rc�����t|��}|j�d��D������fd�tt�����D��}|S)Nc��g|]}|��Sr)r))�.0�
param_names  r�
<listcomp>z#_get_params_sig.<locals>.<listcomp>�s��7�7�7�*�:�7�7�7rc�<��g|]}�|��|f��Sr)r))r6�ir$�param_names�paramss  ���rr8z#_get_params_sig.<locals>.<listcomp>�s+���
J�
J�
J�A�t�A�w��{�1�~�.�/�
J�
J�
Jr)rr�range�len)r$�func�sigr/r;r<s`   @@r�_get_params_sigrA�s\�����
�D�/�/�C�
�^�F�7�7��7�7�7�K�
J�
J�
J�
J�
J�
J��s�4�y�y�9I�9I�
J�
J�
J�F��Mrc��t||��}g}|D]e\}}|jdvrt||j��r|}	n*|jt
jkr|jnd}
||f|
|d�|��}	|�|	���f|S)N)�self�cls�rDr)rA�name�hasattr�__name__�
annotationr�empty�append)r$r#rr&r'�
params_sig�new_args�argr@�new_argrDs           r�	_map_argsrP�s��� ��y�1�1�J��H��	!�	!���S��8��&�&�7�3�	�8J�+K�+K�&��G�G�$'�N�i�o�$E�$E�#�.�.�4�C��f�S�.�c�Y�.�.�,�.�.�G�	���� � � � ��Orc�n�t|��j}|tjkr|nd}||f||d�|��}|S)NrE)r�return_annotationrrJ)rr#rr&r'rRrDr/s        rr-r-�sM��!�)�,�,�>��0�I�O�C�C�
�
��C�
�V�K�
O�S�I�
O�
O��
O�
O�F��Mrc�D�|}|rt|||||��}||i|��}|Sr)rP)r#r&rr$rr'rMr/s        rr,r,�s>���H�
�P��T�9�i���O�O��
�Y��
+�F�
+�
+�F��Mrc���t|t��r%|�dd��td���t|t��rtd���dS)Nz�You cannot decorate a static- or classmethod. You can still obtain the desired behavior by decorating your method first and then place @staticmethod/@classmethod on top (switching the order).zdecorated-staticz)Cannot decorate a static- or classmethod.zCannot decorate a class.)�
isinstance�staticmethod�_warnr�type)r#rs  rr r �sy���)�\�*�*�9����"�$6�		7�	7�	7�
%�7�9�9�	9��)�T�"�"�A�$�%?�@�@�@�A�ArN)�__doc__�inspectrrrr�jsonsrrr	r
rrr
�jsons.exceptionsrrrrr"r!rArPr-r,r r)rr�<module>r]sS����K�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�3�3�3�3�3�3���"��	$N�$N�$N�$N�P��"��	$N�$N�$N�$N�N	�	�	����$���(���
�
�
� ������
A�
A�
A�
A�
Ar