diff options
| author | Alex Schofield <git@ajschof.me> | 2024-08-22 12:03:38 +0100 |
|---|---|---|
| committer | Alex Schofield <git@ajschof.me> | 2024-08-22 12:03:38 +0100 |
| commit | 82a835363953538e506f91eb3199d835f0624975 (patch) | |
| tree | 8bef7c467ae3850427aa7013389fd77f334bebc2 /src | |
| parent | 4a3835d70bb143de23437e6f50f1050f810cd0b1 (diff) | |
| download | de-project-bentley-82a835363953538e506f91eb3199d835f0624975.tar.gz de-project-bentley-82a835363953538e506f91eb3199d835f0624975.zip | |
fix: change default parameters for bucket_name and client
Diffstat (limited to 'src')
| -rw-r--r-- | src/extract_lambda.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/extract_lambda.py b/src/extract_lambda.py index 24f0981..0e6dd8c 100644 --- a/src/extract_lambda.py +++ b/src/extract_lambda.py @@ -99,7 +99,9 @@ def connect_to_database() -> Connection: raise DBConnectionException("Failed to connect to database") -def extract_bucket(client=boto3.client("s3")): +def extract_bucket(client=None): + if client is None: + client = boto3.client("s3") response = client.list_buckets() extract_bucket_filter = [ bucket["Name"] for bucket in response["Buckets"] if "extract" in bucket["Name"] @@ -108,11 +110,16 @@ def extract_bucket(client=boto3.client("s3")): return extract_bucket_filter[0] -def list_existing_s3_files(bucket_name=extract_bucket(), client=boto3.client("s3")): +def list_existing_s3_files(bucket_name=None, client=None): """Creates a dictionary and populates it with the results of listing the contents of the s3 bucket, then returns the populated dictionary """ + if client is None: + client = boto3.client("s3") + if bucket_name is None: + bucket_name = extract_bucket(client) + logging.info("Listing existing S3 files") existing_files = {} |
