mutate#
S3Path object mutation implementation.
- class s3pathlib.core.mutate.MutateAPIMixin[source]#
A mixin class that implements the S3Path object mutation.
- copy() S3Path [source]#
Create a copy of S3Path object that logically equals to this one, but is actually different identity in memory. Also, the cache data are cleared.
Example:
>>> p1 = S3Path("bucket", "folder", "file.txt") >>> p2 = p1.copy() >>> p1 == p2 True >>> p1 is p2 False
New in version 1.0.1.
- change(new_bucket: str = None, new_abspath: str = None, new_dirpath: str = None, new_dirname: str = None, new_basename: str = None, new_fname: str = None, new_ext: str = None) S3Path [source]#
Create a new S3Path by replacing part of the attributes. If no argument is given, it behaves like
copy()
.Example:
>>> s3path = S3Path("bucket", "folder", "file.txt") >>> s3path.change(new_bucket="new_bucket") S3Path('s3://new_bucket/folder/file.txt')
>>> s3path = S3Path("bucket", "folder", "file.txt") >>> s3path.change(new_basename="data.json") S3Path('s3://bucket/folder/data.json')
>>> s3path = S3Path("bucket", "folder", "file.txt") >>> s3path.change(new_fname="log") S3Path('s3://bucket/folder/log.txt')
- Parameters:
new_bucket – The new bucket name
new_abspath –
new_dirpath –
new_dirname –
new_basename –
new_fname –
new_ext –
New in version 1.0.2.