X7ROOT File Manager
Current Path:
/opt/alt/python37/lib/python3.7/site-packages/jsons/serializers
opt
/
alt
/
python37
/
lib
/
python3.7
/
site-packages
/
jsons
/
serializers
/
📁
..
📄
__init__.py
(189 B)
📁
__pycache__
📄
default_complex.py
(244 B)
📄
default_date.py
(593 B)
📄
default_datetime.py
(909 B)
📄
default_decimal.py
(294 B)
📄
default_dict.py
(3.22 KB)
📄
default_enum.py
(612 B)
📄
default_iterable.py
(2.82 KB)
📄
default_list.py
(1.53 KB)
📄
default_object.py
(13.03 KB)
📄
default_path.py
(540 B)
📄
default_primitive.py
(1.06 KB)
📄
default_time.py
(487 B)
📄
default_timedelta.py
(379 B)
📄
default_timezone.py
(524 B)
📄
default_tuple.py
(1.48 KB)
📄
default_union.py
(1.45 KB)
📄
default_uuid.py
(393 B)
📄
default_zone_info.py
(365 B)
Editing: default_tuple.py
from typing import Union, Optional, Tuple from typish import get_args from jsons._compatibility_impl import tuple_with_ellipsis from jsons._dump_impl import dump from jsons.serializers.default_iterable import default_iterable_serializer def default_tuple_serializer(obj: tuple, cls: Optional[type] = None, **kwargs) -> Union[list, dict]: """ Serialize the given ``obj`` to a list of serialized objects. :param obj: the tuple that is to be serialized. :param cls: the type of the ``obj``. :param kwargs: any keyword arguments that may be given to the serialization process. :return: a list of which all elements are serialized. """ if hasattr(obj, '_fields'): return default_namedtuple_serializer(obj, **kwargs) cls_ = cls if cls and tuple_with_ellipsis(cls): cls_ = Tuple[(get_args(cls)[0],) * len(obj)] return default_iterable_serializer(obj, cls_, **kwargs) def default_namedtuple_serializer(obj: tuple, **kwargs) -> dict: """ Serialize the given ``obj`` to a dict of serialized objects. :param obj: the named tuple that is to be serialized. :param kwargs: any keyword arguments that may be given to the serialization process. :return: a dict of which all elements are serialized. """ result = {field_name: dump(getattr(obj, field_name), **kwargs) for field_name in obj._fields} return result
Upload File
Create Folder