def stats_to_list(stats_dict, localize=pytz):
    """
    Parse the output of ``SESConnection.get_send_statistics()`` in to an
    ordered list of 15-minute summaries.
    """
    result = stats_dict['GetSendStatisticsResponse']['GetSendStatisticsResult']
    # Make a copy, so we don't change the original stats_dict.
    result = copy.deepcopy(result)
    datapoints = []
    if localize:
        current_tz = localize.timezone(settings.TIME_ZONE)
    else:
        current_tz = None
    for dp in result['SendDataPoints']:
        if current_tz:
            utc_dt = datetime.strptime(dp['Timestamp'], '%Y-%m-%dT%H:%M:%SZ')
            utc_dt = localize.utc.localize(utc_dt)
            dp['Timestamp'] = current_tz.normalize(
                utc_dt.astimezone(current_tz))
        datapoints.append(dp)

    datapoints.sort(key=lambda x: x['Timestamp'])

    return datapoints
def stats_to_list ( stats_dict , localize = pytz ) : result = stats_dict [ 'GetSendStatisticsResponse' ] [ 'GetSendStatisticsResult' ] result = copy . deepcopy ( result ) datapoints = [ ] if localize : current_tz = localize . timezone ( settings . TIME_ZONE ) else : current_tz = None for dp in result [ 'SendDataPoints' ] : if current_tz : utc_dt = datetime . strptime ( dp [ 'Timestamp' ] , '%Y-%m-%dT%H:%M:%SZ' ) utc_dt = localize . utc . localize ( utc_dt ) dp [ 'Timestamp' ] = current_tz . normalize ( utc_dt . astimezone ( current_tz ) ) datapoints . append ( dp ) datapoints . sort ( key = lambda x : x [ 'Timestamp' ] ) return datapoints
Parse the output of ``SESConnection.get_send_statistics()`` in to an
    ordered list of 15-minute summaries.