MCPcopy Create free account
hub / github.com/pyathena-dev/PyAthena / makedirs

Method makedirs

pyathena/filesystem/s3.py:910–931  ·  view source on GitHub ↗

Recursively create a directory, creating the bucket if necessary. Creating the bucket requires ``allow_bucket_creation=True`` on the filesystem constructor; see :meth:`mkdir`. Args: path: S3 path (e.g., "s3://bucket" or "s3://bucket/prefix"). exist_o

(self, path: str, exist_ok: bool = False)

Source from the content-addressed store, hash-verified

908 raise FileNotFoundError(bucket)
909
910 def makedirs(self, path: str, exist_ok: bool = False) -> None:
911 """Recursively create a directory, creating the bucket if necessary.
912
913 Creating the bucket requires ``allow_bucket_creation=True`` on the
914 filesystem constructor; see :meth:`mkdir`.
915
916 Args:
917 path: S3 path (e.g., "s3://bucket" or "s3://bucket/prefix").
918 exist_ok: If False, raise FileExistsError when the path is a
919 bucket that already exists.
920
921 Raises:
922 FileExistsError: If the path is a bucket that already exists and
923 ``exist_ok`` is False.
924 PermissionError: If the bucket would be created but bucket
925 creation is not enabled on this filesystem instance.
926 """
927 try:
928 self.mkdir(path, create_parents=True)
929 except FileExistsError:
930 if not exist_ok:
931 raise
932
933 def rmdir(self, path: str) -> None:
934 """Remove an S3 bucket, which must be empty.

Callers 1

test_mkdir_and_rmdirMethod · 0.80

Calls 1

mkdirMethod · 0.95

Tested by 1

test_mkdir_and_rmdirMethod · 0.64