Skip to content

Instantly share code, notes, and snippets.

@jamesls
Created October 26, 2015 22:39
Show Gist options
  • Save jamesls/0d1005415d30d2f9f44a to your computer and use it in GitHub Desktop.
Save jamesls/0d1005415d30d2f9f44a to your computer and use it in GitHub Desktop.
Show all inflections used in botocore
#!/usr/bin/env python
import botocore.session
from botocore import xform_name
import time
# Original -> xform'd
all_params = {}
total_time = 0
def yield_all_names():
s = botocore.session.get_session()
for name in s.get_available_services():
service_model = s.get_service_model(name)
# We're only worrying about top level input shape
# names.
for operation_name in service_model.operation_names:
yield operation_name
op_model = service_model.operation_model(operation_name)
input_shape = op_model.input_shape
if input_shape is None:
continue
for member_name in input_shape.members:
yield member_name
for name in yield_all_names():
if name in all_params:
continue
start = time.time()
converted = xform_name(name)
current = time.time() - start
total_time += current
if name != converted:
# Only record when the params are different.
all_params[name] = converted
for key in sorted(all_params):
print "%-50s %s" % (key, all_params[key])
# Print stats about how long this took.
print "\n%s inflection, total time: %.6f" % (len(all_params), total_time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment