File: //opt/alt/python311/lib/python3.11/site-packages/jsons/__pycache__/decorators.cpython-311.pyc
�
)�;f} � � � d Z ddlmZmZmZmZ ddlmZmZm Z m
Z
mZmZm
Z
ddlmZ ddee 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 � |t t t fvrt d� � �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
r r �_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 � |t t t fvrt d� � �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)r r r
r r )r r r �dumperr s r �dumpedr 2 r r c �"