Skip to content

Commit

Permalink
dev(narugo): fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
narugo1992 committed Sep 23, 2024
1 parent cbb6930 commit 27775b4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
6 changes: 6 additions & 0 deletions cheesechaser/datapool/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def mock_resource(self, resource_id, resource_info, silent: bool = False) -> Con
:param resource_id: The ID of the resource to mock.
:param resource_info: Additional information about the resource.
:param silent: If True, suppresses progress bar of each standalone files during the mocking process.
:type silent: bool
:return: A tuple containing the path to the mocked resource and its info.
:raises NotImplementedError: If not implemented by a subclass.
"""
Expand All @@ -150,6 +152,8 @@ def batch_download_to_directory(self, resource_ids, dst_dir: str, max_workers: i
:type save_metainfo: bool
:param metainfo_fmt: Format string for metadata filenames.
:type metainfo_fmt: str
:param silent: If True, suppresses progress bar of each standalone files during the mocking process.
:type silent: bool
:raises OSError: If there's an issue creating the destination directory or copying files.
Expand Down Expand Up @@ -358,6 +362,8 @@ def mock_resource(self, resource_id, resource_info, silent: bool = False) -> Con
:param resource_id: The ID of the resource to mock.
:param resource_info: Additional information about the resource.
:param silent: If True, suppresses progress bar of each standalone files during the mocking process.
:type silent: bool
:return: A tuple containing the path to the temporary directory and the resource info.
:raises ResourceNotFoundError: If the resource cannot be found or downloaded.
Expand Down
4 changes: 4 additions & 0 deletions cheesechaser/datapool/danbooru.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ def mock_resource(self, resource_id, resource_info, silent: bool = False) -> Con
:type resource_id: Any
:param resource_info: Additional information about the resource.
:type resource_info: Any
:param silent: If True, suppresses progress bar of each standalone files during the mocking process.
:type silent: bool
:return: A context manager yielding a tuple of (temporary directory, resource info).
:rtype: ContextManager[Tuple[str, Any]]
:raises ResourceNotFoundError: If the resource is not found in either pool.
Expand Down Expand Up @@ -337,6 +339,8 @@ def mock_resource(self, resource_id, resource_info, silent: bool = False) -> Con
:type resource_id: Any
:param resource_info: Additional information about the resource.
:type resource_info: Any
:param silent: If True, suppresses progress bar of each standalone files during the mocking process.
:type silent: bool
:return: A context manager yielding a tuple of (temporary directory, resource info).
:rtype: ContextManager[Tuple[str, Any]]
:raises ResourceNotFoundError: If the resource is not found in either WebP pool.
Expand Down
2 changes: 2 additions & 0 deletions cheesechaser/datapool/nhentai.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ def mock_resource(self, resource_id, resource_info, silent: bool = False) -> Con
:type resource_id: int
:param resource_info: Additional information about the resource.
:type resource_info: Any
:param silent: If True, suppresses progress bar of each standalone files during the mocking process.
:type silent: bool
:yield: A tuple containing the path to the temporary directory with the images and the resource info.
:rtype: Tuple[str, Any]
:raises ResourceNotFoundError: If the specified manga resource is not found.
Expand Down
2 changes: 2 additions & 0 deletions cheesechaser/pipe/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ def retrieve(self, resource_id, resource_metainfo, silent: bool = False):
:param resource_id: The ID of the resource to retrieve.
:param resource_metainfo: Additional metadata for the resource.
:param silent: If True, suppresses progress bar of each standalone files during the mocking process.
:type silent: bool
:raises NotImplementedError: If not implemented by a subclass.
"""
raise NotImplementedError # pragma: no cover
Expand Down
4 changes: 4 additions & 0 deletions cheesechaser/pipe/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def retrieve(self, resource_id, resource_metainfo, silent: bool = False):
:param resource_id: The identifier of the resource to retrieve.
:param resource_metainfo: Metadata information about the resource.
:param silent: If True, suppresses progress bar of each standalone files during the mocking process.
:type silent: bool
:return: A PIL Image object of the retrieved image.
:rtype: PIL.Image.Image
:raises ResourceNotFoundError: If no image file is found.
Expand Down Expand Up @@ -107,6 +109,8 @@ def retrieve(self, resource_id, resource_metainfo, silent: bool = False):
:param resource_id: The identifier of the resource to retrieve.
:param resource_metainfo: Metadata information about the resource.
:param silent: If True, suppresses progress bar of each standalone files during the mocking process.
:type silent: bool
:return: A DataAttachedImage object containing the image and any associated data.
:rtype: DataAttachedImage
:raises ResourceNotFoundError: If no image file is found.
Expand Down
22 changes: 11 additions & 11 deletions cheesechaser/utils/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def get_hf_token() -> Optional[str]:
:rtype: Optional[str]
:usage:
token = get_hf_token()
if token:
print("Token found")
else:
print("Token not set in environment variables")
>>> token = get_hf_token()
>>> if token:
>>> print("Token found")
>>> else:
>>> print("Token not set in environment variables")
"""
return os.environ.get('HF_TOKEN')

Expand All @@ -45,9 +45,9 @@ def get_hf_client() -> HfApi:
:rtype: HfApi
:usage:
client = get_hf_client()
# Use the client to interact with the Hugging Face Hub
models = client.list_models()
>>> client = get_hf_client()
>>> # Use the client to interact with the Hugging Face Hub
>>> models = client.list_models()
"""
return HfApi(token=get_hf_token())

Expand All @@ -64,8 +64,8 @@ def get_hf_fs() -> HfFileSystem:
:rtype: HfFileSystem
:usage:
fs = get_hf_fs()
# Use the file system to interact with files on the Hugging Face Hub
files = fs.ls('username/repo_name')
>>> fs = get_hf_fs()
>>> # Use the file system to interact with files on the Hugging Face Hub
>>> files = fs.ls('username/repo_name')
"""
return HfFileSystem(token=get_hf_token())

0 comments on commit 27775b4

Please sign in to comment.