� L�g����ddlZddlZddlmZmZeje��Z ddlZ n$#e $re� d��ddl Z YnwxYw ddl Z n"#e $rdZ e� d��YnwxYwe ��ZGd�d��ZGd�de��ZGd �d e��ZGd �d e��ZGd �de��ZGd�de��ZdS)�N)�Any�Optionalz"ujson module not found, using json�4msgpack not installed, MsgPackSerializer unavailablec�`��eZdZUdZeeed<ed��fd� Zde defd�Z dede fd�Z �xZ S) �BaseSerializer�utf-8�DEFAULT_ENCODING)�encodingc�h��|tur|jn||_t��j|i|��dS�N)�_NOT_SETr r �super�__init__)�selfr �args�kwargs� __class__s ��p/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/aiocache/serializers/serializers.pyrzBaseSerializer.__init__s>���19�X�1E�1E��-�-�8�� ������$�)�&�)�)�)�)�)��value�returnc� �td���)Nz dumps method must be implemented��NotImplementedError�rrs r�dumpszBaseSerializer.dumps ���!�"D�E�E�Erc� �td���)Nz loads method must be implementedrrs r�loadszBaseSerializer.loads$rr) �__name__� __module__� __qualname__r r�str�__annotations__r rrrr� __classcell__�rs@rrrs���������&-��h�s�m�-�-�-�'/�*�*�*�*�*�*�*� F�3�F�3�F�F�F�F�F�3�F�3�F�F�F�F�F�F�F�Frrc��eZdZdZd�Zd�ZdS)�NullSerializera5 This serializer does nothing. Its only recommended to be used by :class:`aiocache.SimpleMemoryCache` because for other backends it will produce incompatible data unless you work only with str types because it store data as is. DISCLAIMER: Be careful with mutable types and memory storage. The following behavior is considered normal (same as ``functools.lru_cache``):: cache = Cache() my_list = [1] await cache.set("key", my_list) my_list.append(2) await cache.get("key") # Will return [1, 2] c��|S�z( Returns the same value �rs rrzNullSerializer.dumps9� ��� rc��|Sr*r+rs rrzNullSerializer.loads?r,rN�r r!r"�__doc__rrr+rrr(r((s<�������� ��� ����rr(c��eZdZdZd�Zd�ZdS)�StringSerializera� Converts all input values to str. All return values are also str. Be careful because this means that if you store an ``int(1)``, you will get back '1'. The transformation is done by just casting to str in the ``dumps`` method. If you want to keep python types, use ``PickleSerializer``. ``JsonSerializer`` may also be useful to keep type of symple python types. c� �t|��S)z� Serialize the received value casting it to str. :param value: obj Anything support cast to str :returns: str )r#rs rrzStringSerializer.dumpsRs���5�z�z�rc��|S)z< Returns value back without transformations r+rs rrzStringSerializer.loads[r,rNr.r+rrr1r1Fs<������ � ��������rr1c�B��eZdZdZdZejd��fd� Zd�Zd�Z �xZ S)�PickleSerializerzZ Transform data to bytes using pickle.dumps and pickle.loads to retrieve it back. N��protocolc�H��t��j|i|��||_dSr )rrr7)rr7rrrs �rrzPickleSerializer.__init__is*��������$�)�&�)�)�)� �� � � rc�8�tj||j���S)zy Serialize the received value using ``pickle.dumps``. :param value: obj :returns: bytes r6)�picklerr7rs rrzPickleSerializer.dumpsms���|�E�D�M�:�:�:�:rc�2�|�dStj|��S)zn Deserialize value using ``pickle.loads``. :param value: bytes :returns: obj N)r:rrs rrzPickleSerializer.loadsvs�� �=��4��|�E�"�"�"r) r r!r"r/r r:�DEFAULT_PROTOCOLrrrr%r&s@rr5r5bsx�����������'-�'>�!�!�!�!�!�!�!�;�;�;� #� #� #� #� #� #� #rr5c��eZdZdZd�Zd�ZdS)�JsonSerializera� Transform data to json string with json.dumps and json.loads to retrieve it back. Check https://docs.python.org/3/library/json.html#py-to-json-table for how types are converted. ujson will be used by default if available. Be careful with differences between built in json module and ujson: - ujson dumps supports bytes while json doesn't - ujson and json outputs may differ sometimes c�*�tj|��S)zv Serialize the received value using ``json.dumps``. :param value: dict :returns: str )�jsonrrs rrzJsonSerializer.dumps�s���z�%� � � rc�2�|�dStj|��S)z� Deserialize value using ``json.loads``. :param value: str :returns: output of ``json.loads``. N)r@rrs rrzJsonSerializer.loads�s�� �=��4��z�%� � � rNr.r+rrr>r>�s<��������!�!�!� !� !� !� !� !rr>c�4��eZdZdZdd��fd� Zd�Zd�Z�xZS)�MsgPackSerializera� Transform data to bytes using msgpack.dumps and msgpack.loads to retrieve it back. You need to have ``msgpack`` installed in order to be able to use this serializer. :param encoding: str. Can be used to change encoding param for ``msg.loads`` method. Default is utf-8. :param use_list: bool. Can be used to change use_list param for ``msgpack.loads`` method. Default is True. T)�use_listc�t��tstd���||_t��j|i|��dS)Nr)�msgpack� RuntimeErrorrDrr)rrDrrrs �rrzMsgPackSerializer.__init__�sD���� W��U�V�V� V� �� ������$�)�&�)�)�)�)�)rc�*�tj|��S)zz Serialize the received value using ``msgpack.dumps``. :param value: obj :returns: bytes )rFrrs rrzMsgPackSerializer.dumps�s���}�U�#�#�#rc�`�|jdkrdnd}|�dStj|||j���S)zo Deserialize value using ``msgpack.loads``. :param value: bytes :returns: obj rFTN)�rawrD)r rFrrD)rrrJs rrzMsgPackSerializer.loads�s<���}��/�/�e�e�T�� �=��4��}�U��d�m�D�D�D�Dr)r r!r"r/rrrr%r&s@rrCrC�sv���������(,�*�*�*�*�*�*�*� $�$�$� E� E� E� E� E� E� ErrC)�loggingr:�typingrr� getLoggerr �logger�ujsonr@� ImportError�debugrF�objectr rr(r1r5r>rCr+rr�<module>rSs������ � � � � � � � � � � � � �� �8� $� $������������� �L�L�5�6�6�6��K�K�K�K�K�����I��N�N�N�N���I�I�I��G� �L�L�G�H�H�H�H�H�I���� �6�8�8��F�F�F�F�F�F�F�F�"�����^����<�����~����8#�#�#�#�#�~�#�#�#�@!�!�!�!�!�^�!�!�!�@$E�$E�$E�$E�$E��$E�$E�$E�$E�$Es!�'�A�A� A�A0�/A0
Memory