# Path: cloudkittydashboard/api/cloudkitty.py
# def cloudkittyclient(request):
# def identify(what, name=False, key=None):


import calendar
import collections
import datetime
import decimal
import time
from horizon import tabs
from cloudkittydashboard.api import cloudkitty as api
            hourly_data[timestamp] += float(resource['rating'])

    service_names = services.keys()
    t = start_timestamp
    if end_timestamp:
        while t <= end_timestamp:
            for service in service_names:
                hourly_d = services[service]['hourly']
                hourly_d.setdefault(t, 0)
            t += 3600

    # now sort the dicts
    for service in service_names:
        d = services[service]['hourly']
        services[service]['hourly'] = collections.OrderedDict(
            sorted(d.items(), key=lambda t: t[0]))

    return services


class CostRepartitionTab(tabs.Tab):
    name = "This month"
    slug = "this_month"
    template_name = 'project/reporting/this_month.html'

    def get_context_data(self, request, **kwargs):
        today = datetime.datetime.today()
        day_start, day_end = calendar.monthrange(today.year, today.month)
        begin = "%4d-%02d-01T00:00:00" % (today.year, today.month)
        end = "%4d-%02d-%02dT23:59:59" % (today.year, today.month, day_end)

# Path: cloudkittydashboard/api/cloudkitty.py
# def cloudkittyclient(request):
# def identify(what, name=False, key=None):


# Path: cloudkittydashboard/dashboards/project/reporting/views.py
import calendar
import collections
import datetime
import decimal
import time
from horizon import tabs
from cloudkittydashboard.api import cloudkitty as api

            hourly_data[timestamp] += float(resource['rating'])

    service_names = services.keys()
    t = start_timestamp
    if end_timestamp:
        while t <= end_timestamp:
            for service in service_names:
                hourly_d = services[service]['hourly']
                hourly_d.setdefault(t, 0)
            t += 3600

    # now sort the dicts
    for service in service_names:
        d = services[service]['hourly']
        services[service]['hourly'] = collections.OrderedDict(
            sorted(d.items(), key=lambda t: t[0]))

    return services


class CostRepartitionTab(tabs.Tab):
    name = "This month"
    slug = "this_month"
    template_name = 'project/reporting/this_month.html'

    def get_context_data(self, request, **kwargs):
        today = datetime.datetime.today()
        day_start, day_end = calendar.monthrange(today.year, today.month)
        begin = "%4d-%02d-01T00:00:00" % (today.year, today.month)
        end = "%4d-%02d-%02dT23:59:59" % (today.year, today.month, day_end)

        client = api.cloudkittyclient(request)