def ProcessBucket(response, s3Client, s3Resource, params): result = {} for bucket in response['Buckets']: # checks if the filter flag exists and if the filter flag is a valid name if (params['f'] and IsBucketNameValid( bucket['Name'], params['f'])) or (params['f'] is None): currentBucket = Bucket() # instantiate new Bucket currentBucket.name = bucket['Name'] # set name attribute currentBucket.region = s3Client.get_bucket_location( Bucket=currentBucket.name)[ 'LocationConstraint'] # set region attribute # set creation date attribute currentBucket.creationDate = bucket['CreationDate'].ctime() # checks if there are ANY object level data requested in the argument if (any(param == True for param in params['objectParams'].values())): ProcessBucketObjects(currentBucket, bucket, params['objectParams'], s3Client, s3Resource) # insert bucket, all relevant data should be populated # check to see whether the region is already in result if so group them together, otherwise instantiate a list within a dict like: # result = {Key=RegionName, Val = [This is a list of buckets, append current one]} if currentBucket.region in result.keys(): result[currentBucket.region].append(currentBucket) else: result[currentBucket.region] = [currentBucket] return result