def pprint(rate_limit):
"""
Pretty print rate limit dictionary to be easily parsable and readable
across multiple lines
"""
# Ignoring the 'rate' key b/c github API claims this will be removed in
# next major version:
# https://developer.github.com/v3/rate_limit/#deprecation-notice
def print_(name, limits):
date_ = datetime.utcfromtimestamp(limits[name]['reset'])
print '%8s remaining: %4s limit: %4s reset: %s' % (
name,
limits[name]['remaining'],
limits[name]['limit'],
date_.strftime('%d-%m-%Y %H:%M:%S'))
print_('core', rate_limit['resources'])
print_('search', rate_limit['resources'])
评论列表
文章目录