Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Sep 5, 2024
1 parent 0bdef04 commit a3b45ae
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions tosfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ def cp_file(
If there is a server error while copying the file.
TosfsError
If there is an unknown error while copying the file.
"""
path1 = self._strip_protocol(path1)
bucket, key, vers = self._split_path(path1)
Expand Down Expand Up @@ -872,10 +873,7 @@ def _copy_basic(self, path1: str, path2: str, **kwargs: Any) -> None:
def _copy_etag_preserved(
self, path1: str, path2: str, size: int, total_parts: int, **kwargs: Any
) -> None:
"""Copy file between tos locations as multiple-part while preserving the etag.
(using the same part sizes for each part
"""
"""Copy file as multiple-part while preserving the etag."""
bucket1, key1, version1 = self._split_path(path1)
bucket2, key2, version2 = self._split_path(path2)

Expand Down Expand Up @@ -922,15 +920,21 @@ def _copy_etag_preserved(
raise TosfsError(f"Copy failed ({path1} -> {path2}): {e}") from e

def _copy_managed(
self, path1: str, path2: str, size: int, block: int = 5 * 2**30, **kwargs: Any
self,
path1: str,
path2: str,
size: int,
block: int = MANAGED_COPY_THRESHOLD,
**kwargs: Any,
) -> None:
"""Copy file between locations on tos as multiple-part.
block: int
The size of the pieces, must be larger than 5MB and at most 5GB.
The size of the pieces, must be larger than 5MB and at
most MANAGED_COPY_THRESHOLD.
Smaller blocks mean more calls, only useful for testing.
"""
if block < 5 * 2**20 or block > 5 * 2**30:
if block < 5 * 2**20 or block > MANAGED_COPY_THRESHOLD:
raise ValueError("Copy block size must be 5MB<=block<=5GB")

bucket1, key1, version1 = self._split_path(path1)
Expand Down Expand Up @@ -1593,6 +1597,7 @@ def _fill_bucket_info(bucket_name: str) -> dict:
"name": bucket_name,
}


class TosFile(AbstractBufferedFile):
"""File-like operations for TOS."""

Expand Down

0 comments on commit a3b45ae

Please sign in to comment.