-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidate
rename
/rename_if_not_exists
, copy
/`copy_if_not_exis…
…ts` (#18) * Consolidate copy/rename if not exists * fix lib
- Loading branch information
1 parent
eb8d699
commit 902fd55
Showing
5 changed files
with
61 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,26 @@ | ||
from .store import ObjectStore | ||
|
||
def copy(store: ObjectStore, from_: str, to: str) -> None: | ||
def copy(store: ObjectStore, from_: str, to: str, *, overwrite: bool = True) -> None: | ||
"""Copy an object from one path to another in the same object store. | ||
If there exists an object at the destination, it will be overwritten. | ||
Args: | ||
store: The ObjectStore instance to use. | ||
from_: Source path | ||
to: Destination path | ||
""" | ||
|
||
async def copy_async(store: ObjectStore, from_: str, to: str) -> None: | ||
"""Call `copy` asynchronously. | ||
Refer to the documentation for [copy][object_store_rs.copy]. | ||
""" | ||
|
||
def copy_if_not_exists(store: ObjectStore, from_: str, to: str) -> None: | ||
""" | ||
Copy an object from one path to another, only if destination is empty. | ||
Will return an error if the destination already has an object. | ||
Performs an atomic operation if the underlying object storage supports it. | ||
If atomic operations are not supported by the underlying object storage (like S3) | ||
it will return an error. | ||
Keyword Args: | ||
overwrite: If `True`, if there exists an object at the destination, it will | ||
be overwritten. Performs an atomic operation if the underlying object | ||
storage supports it. If atomic operations are not supported by the | ||
underlying object storage (like S3) it will return an error. | ||
Args: | ||
store: The ObjectStore instance to use. | ||
from_: Source path | ||
to: Destination path | ||
If `False`, will return an error if the destination already has an object. | ||
""" | ||
|
||
async def copy_if_not_exists_async(store: ObjectStore, from_: str, to: str) -> None: | ||
"""Call `copy_if_not_exists` asynchronously. | ||
async def copy_async( | ||
store: ObjectStore, from_: str, to: str, *, overwrite: bool = True | ||
) -> None: | ||
"""Call `copy` asynchronously. | ||
Refer to the documentation for | ||
[copy_if_not_exists][object_store_rs.copy_if_not_exists]. | ||
Refer to the documentation for [copy][object_store_rs.copy]. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,27 @@ | ||
from .store import ObjectStore | ||
|
||
def rename(store: ObjectStore, from_: str, to: str) -> None: | ||
def rename(store: ObjectStore, from_: str, to: str, *, overwrite: bool = True) -> None: | ||
""" | ||
Move an object from one path to another in the same object store. | ||
By default, this is implemented as a copy and then delete source. It may not check | ||
when deleting source that it was the same object that was originally copied. | ||
If there exists an object at the destination, it will be overwritten. | ||
Args: | ||
store: The ObjectStore instance to use. | ||
from_: Source path | ||
to: Destination path | ||
Keyword Args: | ||
overwrite: If `True`, if there exists an object at the destination, it will be | ||
overwritten. If `False`, will return an error if the destination already has | ||
an object. | ||
""" | ||
|
||
async def rename_async(store: ObjectStore, from_: str, to: str) -> None: | ||
async def rename_async( | ||
store: ObjectStore, from_: str, to: str, *, overwrite: bool = True | ||
) -> None: | ||
"""Call `rename` asynchronously. | ||
Refer to the documentation for [rename][object_store_rs.rename]. | ||
""" | ||
|
||
def rename_if_not_exists(store: ObjectStore, from_: str, to: str) -> None: | ||
""" | ||
Move an object from one path to another in the same object store. | ||
Will return an error if the destination already has an object. | ||
Args: | ||
store: The ObjectStore instance to use. | ||
from_: Source path | ||
to: Destination path | ||
""" | ||
|
||
async def rename_if_not_exists_async(store: ObjectStore, from_: str, to: str) -> None: | ||
"""Call `rename_if_not_exists` asynchronously. | ||
Refer to the documentation for | ||
[rename_if_not_exists][object_store_rs.rename_if_not_exists]. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters