Secrets Manager
Botree S3 utilities.
Classes
botree.s3.Bucket(session: Session, name: str, client_kwargs: dict = dict(), resource_kwargs: dict = dict())
AWS S3 Bucket level transactions.
Source code in botree/s3.py
Functions
copy(source: Path, target: Path, source_bucket: Optional[str] = None, *args: Optional[str], **kwargs: Optional[str])
Copy an object stored in the bucket or from another bucket.
If source_bucket is not specified, the object is copied from the current bucket.
if target_key has no suffix, it assumes target_key is a folder and source_key file name is used.
Parameters:
-
source
(
Path
) –source file path
-
target
(
Path
) –target file path. If target_key has no suffix, it assumes target_key is a folder.
-
source_bucket
(
Optional[str]
) –bucket from wich source file will be copied from, by default None
Source code in botree/s3.py
delete(target: Path, **kwargs: Path)
Delete a file from S3.
Parameters:
-
target
(
Path
) –remote file path.
download(source: Path, target: Path, **kwargs: Path)
Download a file from S3.
Parameters:
-
source
(
Path
) –remote file path.
-
target
(
Path
) –local file path.
Source code in botree/s3.py
list_files(prefix: str = '', reverse: bool = False, *args: bool, **kwargs: bool) -> List[str]
List and sort (by date) all files in a given prefix.
Parameters:
-
prefix
(
str
) –S3 prefix.
-
reverse
(
bool
) –Reverse (descending) date sort, by default False
Returns:
-
List[str]
–Paths to files.
Source code in botree/s3.py
list_folders(prefix: str = '', *args: str, **kwargs: str) -> List[str]
List all folders in a given prefix.
Parameters:
-
prefix
(
str
) –S3 prefix.
Returns:
-
List[str]
–Paths to folders.
Source code in botree/s3.py
paginate_objects(prefix: str = '', page_size: int = 1000) -> Generator
Return a list all objects in a bucket with specified prefix.
Paginator is useful when you have 1000s of files in S3. S3 list_objects_v2 can list at max 1000 files in one go. :return: None
Source code in botree/s3.py
upload(source: Path, target: Path, **kwargs: Path)
Upload a file to S3.
Parameters:
-
source
(
Path
) –local file path.
-
target
(
Path
) –remote file path.
botree.s3.S3(session: Session, **kwargs: Session)
AWS S3 operations.
S3 class init.
Source code in botree/s3.py
Functions
bucket(name: str, client_kwargs: dict = dict(), resource_kwargs: dict = dict()) -> Bucket
Get a bucket resource instance.