-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7292eb4
commit 42b33b3
Showing
13 changed files
with
156 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from __future__ import annotations | ||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from typing import List | ||
|
||
from ...typing.jikan import ( | ||
GenreData, | ||
JikanResponseData, | ||
) | ||
|
||
from dataclasses import dataclass, field | ||
|
||
from ..base import JikanResource | ||
from ..helpers import Genre | ||
|
||
__all__ = ( | ||
"AnimeGenres", | ||
) | ||
|
||
@dataclass | ||
class AnimeGenres(JikanResource): | ||
_genres_endpoint = "/genres/anime" | ||
|
||
data: JikanResponseData[List[GenreData]] = field(repr = False) | ||
|
||
def __iter__(self): | ||
for genre in self.data["data"]: | ||
yield Genre(genre) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from __future__ import annotations | ||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from ...typing.jikan import ( | ||
GenreData, | ||
) | ||
|
||
from dataclasses import dataclass, field | ||
|
||
__all__ = ( | ||
"Genre", | ||
) | ||
|
||
@dataclass | ||
class Genre(): | ||
data: GenreData = field(repr = False) | ||
|
||
id: int = field(init = False) | ||
name: str = field(init = False) | ||
url: str = field(init = False) | ||
count: int = field(init = False) | ||
|
||
def __post_init__(self): | ||
genre = self.data | ||
|
||
self.id = genre["mal_id"] | ||
self.name = genre["name"] | ||
self.url = genre["url"] | ||
self.count = genre["count"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from __future__ import annotations | ||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from typing import List | ||
|
||
from ...typing.jikan import ( | ||
GenreData, | ||
JikanResponseData, | ||
) | ||
|
||
from dataclasses import dataclass, field | ||
|
||
from ..base import JikanResource | ||
from ..helpers import Genre | ||
|
||
__all__ = ( | ||
"MangaGenres", | ||
) | ||
|
||
@dataclass | ||
class MangaGenres(JikanResource): | ||
_genres_endpoint = "/genres/manga" | ||
|
||
data: JikanResponseData[List[GenreData]] = field(repr = False) | ||
|
||
def __iter__(self): | ||
for genre in self.data["data"]: | ||
yield Genre(genre) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from __future__ import annotations | ||
from typing import TypedDict | ||
|
||
__all__ = ( | ||
"GenreData", | ||
) | ||
|
||
class GenreData(TypedDict): | ||
mal_id: int | ||
name: str | ||
url: str | ||
count: int |