Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/datasets/utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,28 @@ def exists(self, download_config: Optional[DownloadConfig] = None):
"""
return xexists(str(self), download_config=download_config)

def is_file(self, download_config: Optional[DownloadConfig] = None):
"""Extend `pathlib.Path.is_file` method to support both local and remote files.

Args:
download_config : mainly use token or storage_options to support different platforms and auth types.

Returns:
`bool`
"""
return xisfile(str(self), download_config=download_config)

def is_dir(self, download_config: Optional[DownloadConfig] = None):
"""Extend `pathlib.Path.is_dir` method to support both local and remote files.

Args:
download_config : mainly use token or storage_options to support different platforms and auth types.

Returns:
`bool`
"""
return xisdir(str(self), download_config=download_config)

def glob(self, pattern, download_config: Optional[DownloadConfig] = None):
"""Glob function for argument of type :obj:`~pathlib.Path` that supports both local paths end remote URLs.

Expand Down
Loading