Skip to content

Commit

Permalink
[TOSFS #10] Implement rmdir API
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Aug 19, 2024
1 parent 17449a2 commit 97acf39
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tosfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,29 @@ def info(
return self._try_dir_info(bucket, key, path, fullpath)

def rmdir(self, path: str) -> None:
"""Remove a directory, if empty."""
"""
Remove a directory if it is empty.
Parameters
----------
path : str
The path of the directory to remove. The path should be in the format
`tos://bucket_name/directory_path`.
Raises
------
FileNotFoundError
If the directory does not exist.
NotADirectoryError
If the path is not a directory.
TosfsError
If the directory is not empty or if there is an error during the removal process.
Examples
--------
>>> fs = TosFileSystem()
>>> fs.rmdir("tos://mybucket/mydir/")
"""
path = self._strip_protocol(path).rstrip("/") + "/"
bucket, key, _ = self._split_path(path)
if not key:
Expand Down

0 comments on commit 97acf39

Please sign in to comment.