Skip to content

Instantly share code, notes, and snippets.

@edsu
Last active May 18, 2020 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edsu/74359b20c6432407d43cef31b53b99db to your computer and use it in GitHub Desktop.
Save edsu/74359b20c6432407d43cef31b53b99db to your computer and use it in GitHub Desktop.
#!/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