Using key query rather than try catch

Added a unit test for empty content
This commit is contained in:
venusbb
2018-01-17 13:51:57 +00:00
parent 9179802717
commit 7d84b4629a
3 changed files with 23 additions and 11 deletions

View File

@@ -119,12 +119,8 @@ def get_list_of_files_by_suffix(bucket_name, subfolder='', suffix='', last_modif
)
for page in page_iterator:
try:
for obj in page['Contents']:
key = obj['Key'].lower()
if key.endswith(suffix.lower()):
if not last_modified or obj['LastModified'] >= last_modified:
yield key
except KeyError:
# Not content for today
pass
for obj in page.get('Contents', []):
key = obj['Key'].lower()
if key.endswith(suffix.lower()):
if not last_modified or obj['LastModified'] >= last_modified:
yield key