Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for other third-party content providers
- Loading branch information
Showing
11 changed files
with
346 additions
and
156 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,38 @@ | ||
# pylint: disable=R0903 | ||
""" | ||
dayong.exts.contents | ||
~~~~~~~~~~~~~~~~~~~~ | ||
""" | ||
from typing import Any, Optional | ||
|
||
|
||
class ThirdPartyContent: | ||
"""Represents content from third-party service/content providers.""" | ||
|
||
def __init__(self, content: Any, constraint: Optional[Any] = None) -> None: | ||
if isinstance(content, list): | ||
self.content = ThirdPartyContent.collect(content, constraint) | ||
else: | ||
self.content = content | ||
|
||
@staticmethod | ||
def collect(content_list: Any, constraint: Any) -> list[Any]: | ||
"""Parse response data for specific parts. | ||
Args: | ||
content_list (Any): The sequence to be processed. | ||
constraint (Any): Any immutable type that can be used as a dictionary key. | ||
Returns: | ||
list[Any]: A list of parsed response data. | ||
""" | ||
parts: list[Any] = [] | ||
|
||
if constraint: | ||
for content in content_list: | ||
parts.append(content[constraint]) | ||
else: | ||
parts = content_list | ||
|
||
return parts |
Oops, something went wrong.