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"""
# noinspection PyAbstractClass """ Class that models user-independent media data """
""" Retrieves the cache entry's ID :return: The ID """
""" Retrieves the media type :return: The media type """
""" Retrieves the username, if applicable. Else None :return: The username or None if not applicable """
""" Retrieves the cache model type :return: The model type """
self, media_type: MediaType, _format: MediaFormat, _id: Id, title: Title, relations: List[Relation], releasing_status: ReleasingStatus, releasing_start: Optional[Date], releasing_end: Optional[Date], cover_url: Optional[str] ): """ Initializes the Media Data object and checks for type issues Some values may be None, for example if a media has not completed releasing yet. This constructor initializes all common values of all media types. :param media_type: The type of media :param _format: The media format :param _id: The ID of the media :param title: The title of the media :param relations: The relations of the media to other media :param releasing_status: The releasing status of the media :param releasing_start: The day the media started releasing :param releasing_end: The day the last content was released :param cover_url: An URL pointing to a cover image for the anime :raises TypeError: If any of the parameters has a wrong type """
or Dict or List or Tuple or Set]]: """ Serializes the object into a dictionary :return: The serialized form of this object """ else self.releasing_start.serialize() else self.releasing_end.serialize()
"media_type": self.media_type.name, "format": self.format.name, "id": self.id.serialize(), "title": self.title.serialize(), "relations": list(map(lambda x: x.serialize(), self.relations)), "releasing_status": self.releasing_status.name, "releasing_start": releasing_start, "releasing_end": releasing_end, "cover_url": self.cover_url }
""" Maps a class to a media type :param media_type: The media type :return: The class mapped to that media type """
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 """ "media_type": MediaType[data["media_type"]], "format": MediaFormat[data["format"]], "id": Id.deserialize(data["id"]), "title": Title.deserialize(data["title"]), "relations": list(map( lambda x: Relation.deserialize(x), data["relations"] )), "releasing_status": ReleasingStatus[data["releasing_status"]], "cover_url": data["cover_url"] }
else:
""" Generates an order of constructor parameters for the common attributes used for media classes :return: The order of common parameters """ "format", "id", "title", "relations", "releasing_status", "releasing_start", "releasing_end", "cover_url" ]
""" Class that models anime data """
self, _format: MediaFormat, _id: Id, title: Title, relations: List[Relation], releasing_status: ReleasingStatus, releasing_start: Optional[Date], releasing_end: Optional[Date], cover_url: Optional[str], episode_count: Optional[int], episode_duration: Optional[int], ): """ Initializes the Anime Data object and checks for type issues :param _format: The media format :param _id: The ID of the anime :param title: The title of the anime :param relations: The relations of the anime :param releasing_status: The airing status of the anime :param releasing_start: The day the anime started airing :param releasing_end: The day the last episode aired :param episode_count: The amount of episodes of the anime :param episode_duration: The duration of the episodes in minutes :param cover_url: An URL pointing to a cover image for the anime :raises TypeError: If any of the parameters has a wrong type """ MediaType.ANIME, _format, _id, title, relations, releasing_status, releasing_start, releasing_end, cover_url )
or Dict or List or Tuple or Set]]: """ Serializes the object into a dictionary :return: The serialized form of this object """
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 """ "episode_count": data["episode_count"], "episode_duration": data["episode_duration"] }
""" Generates the order of class-specific additional constructor parameters :return: The order of the additional parameters """
""" Class that models manga data """
self, _format: MediaFormat, _id: Id, title: Title, relations: List[Relation], releasing_status: ReleasingStatus, releasing_start: Optional[Date], releasing_end: Optional[Date], cover_url: Optional[str], chapter_count: Optional[int], volume_count: Optional[int], ): """ Initializes the Manga Data object and checks for type issues :param _format: The media format :param _id: The ID of the manga :param title: The title of the manga :param relations: The relations of the manga :param releasing_status: The releasing status of the manga :param releasing_start: The day the manga started releasing :param releasing_end: The day the last chapter/volume released :param chapter_count: The total amount of chapters of this manga :param volume_count: The total amount of volumes of this manga :param cover_url: An URL pointing to a cover image for the manga :raises TypeError: If any of the parameters has a wrong type """ MediaType.MANGA, _format, _id, title, relations, releasing_status, releasing_start, releasing_end, cover_url )
or Dict or List or Tuple or Set]]: """ Serializes the object into a dictionary :return: The serialized form of this object """
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 """ "chapter_count": data["chapter_count"], "volume_count": data["volume_count"] }
""" Generates the order of class-specific additional constructor parameters :return: The order of the additional parameters """ |