Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""LICENSE Copyright 2018 Hermann Krumrey <hermann@krumreyh.com>
This file is part of anime-list-apis.
anime-list-apis is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
anime-list-apis is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with anime-list-apis. If not, see <http://www.gnu.org/licenses/>. LICENSE"""
""" Abstract class that defines methods for subclasses to implement to make sure that they can be serialized """
or Dict or List or Tuple or Set]]: """ Serializes the object into a dictionary :return: The serialized form of this object """
or Dict or List or Tuple or Set]]: """ Implements the serialization of the object :return: The serialized form of this object """ raise NotImplementedError() # pragma: no cover
or Dict or List or Tuple or Set]]): """ Deserializes a dictionary into an object of this type :param data: The data to deserialize :return: The deserialized object :raises TypeError: If a type error occurred :raises ValueError: If the data could not be deserialized """
or Dict or List or Tuple or Set]]): """ Implements the deserialisation of this object :param data: The data to deserialize :return: The deserialized object :raises TypeError: If a type error occurred :raises ValueError: If the data could not be deserialized """ raise NotImplementedError() # pragma: no cover
""" Checks if this object is equal to another object. The object is guaranteed to be an instance of this class or a subclass :param other: The other object to compare this object to :return: True if the objects are equal, False otherwise """ # noinspection PyUnresolvedReferences
""" Compares another object with this one. :param other: The other object with which to compare this object with :return: True if the objects are equal, False otherwise """ else:
""" Generates a string representation of this object. By default, this returns valid JSON. :return: The string representation of this object """
""" Checks if an object is an instance of a type :param obj: The object to check :param typ: The type it should be :param none_allowed: If True, allows None values :return: True if the object is of that type, else False """
# Since bools are ints, make sure that an int object # isn't actually a bool
else:
""" Raises a TypeError if the object does not match the type :param obj: The object to check :param typ: The type the object should be :param none_allowed: If True, allows None values :return: None :raises TypeError: If the types do not match """
# noinspection PyAbstractClass """ Class that allows for easier subclassing of Media classes """
""" Maps a class to a media type :param media_type: The media type :return: The class mapped to that media type """ raise NotImplementedError() # pragma: no cover
cls, data: Dict[str, Optional[str or int or float or bool or Dict or List or Tuple or Set]]) \ -> Dict[str, Optional[str or int or float or bool or Dict or List or Tuple or Set]]: """ Deserializes the common child components of the data dictionary :param data: The data to deserialize :return: The deserialized dictionary """ raise NotImplementedError() # pragma: no cover
cls, data: Dict[str, Optional[str or int or float or bool or Dict or List or Tuple or Set]]) \ -> Dict[str, Optional[str or int or float or bool or Dict or List or Tuple or Set]]: """ Deserializes class-specific child components of the data dictionary :param data: The data to deserialize :return: The deserialized dictionary """ raise NotImplementedError() # pragma: no cover
""" Generates an order of constructor parameters for the common attributes used for media classes :return: The order of common parameters """ raise NotImplementedError() # pragma: no cover
""" Generates the order of class-specific additional constructor parameters :return: The order of the additional parameters """ raise NotImplementedError() # pragma: no cover
or Dict or List or Tuple or Set]]): """ Deserializes a dictionary into an object of this type :param data: The data to deserialize :return: The deserialized object :raises TypeError: If a type error occurred :raises ValueError: If the data could not be deserialized """
# Auto-resolve the subclass to use MediaType[data["media_type"]] ) # type: MediaSerializable
_cls._get_common_deserialized_components(data) # noinspection PyProtectedMember _cls._get_specific_deserialized_components(data)
# noinspection PyProtectedMember _cls._get_common_parameter_order() + \ _cls._get_additional_parameter_order()
# noinspection PyCallingNonCallable |