Last active
May 18, 2020 19:21
-
-
Save edsu/74359b20c6432407d43cef31b53b99db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import re | |
import boto3 | |
from collections import Counter | |
from humanize import naturalsize | |
s3_client = boto3.client('s3') | |
paginator = s3_client.get_paginator('list_objects') | |
sizes = Counter() | |
for page in paginator.paginate(Bucket='sga-tiles'): | |
for o in page['Contents']: | |
if re.search(r'ms_abinger_c', o['Key']): | |
sizes['ms_abinger_c'] += o['Size'] | |
elif re.search(r'ms_shelley_e', o['Key']): | |
sizes['ms_shelley_e'] += o['Size'] | |
else: | |
sizes['other'] += o['Size'] | |
for name, size in sizes.most_common(): | |
print(name, naturalsize(size)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment