# Path: diva/converters.py
# @singledispatch
# def convert_to_html(val):
#     # default is to just display the value as a string
#     return '<p>{}</p>'.format(str(val))
# 
# Path: diva/utilities.py
# @singledispatch
# def get_utilities_for_value(val):
#     return type_utils.get(type(val), [])    
# 
# def label_utility(ui_name):
#     """
#     Get a label utility with the given name
#     """
#     def gen_html(val):
#         return render_template('utility_label.html', name=ui_name)
#     # this will never be called
#     def apply(val, form_data):
#         pass
#     return {'generate_html': gen_html, 'apply': apply}
# 
# Path: diva/utils.py
# def render_template(filename, **variables):
#     return env.get_template(filename).render(variables)


from .converters import convert_to_html
from .utilities import get_utilities_for_value, label_utility
from .utils import render_template
from functools import partial
        if layout is None:
            self.layout = [[0, i, 1, 1] for i in range(len(items))]
        else:
            self.layout = layout

def get_grid_size(layout):
    max_x = max([x + w for x, y, w, h in layout])
    max_y = max([y + h for x, y, w, h in layout])
    return (max_x, max_y)

def get_grid(dash):
    grid_size = get_grid_size(dash.layout)

    # create a list of panes
    panes = []
    for index, (item, coord) in enumerate(zip(dash.items, dash.layout)):
        pane = {}
        # add 1 to point b/c CSS grids start at (1, 1) not (0, 0)
        css_coord = coord[0] + 1, coord[1] + 1, coord[2], coord[3]
        pane['x'], pane['y'], pane['w'], pane['h'] = css_coord
        pane['html'] = convert_to_html(item)
        pane['name'] = 'report {}'.format(index) 
        panes.append(pane)
    return {'size': grid_size, 'panes': panes}
 
@convert_to_html.register(Dashboard)
def dashboard_to_html(dash):
    grid = get_grid(dash)
    return render_template('dashboard.html', grid=grid)
    

# Path: diva/converters.py
# @singledispatch
# def convert_to_html(val):
#     # default is to just display the value as a string
#     return '<p>{}</p>'.format(str(val))
# 
# Path: diva/utilities.py
# @singledispatch
# def get_utilities_for_value(val):
#     return type_utils.get(type(val), [])    
# 
# def label_utility(ui_name):
#     """
#     Get a label utility with the given name
#     """
#     def gen_html(val):
#         return render_template('utility_label.html', name=ui_name)
#     # this will never be called
#     def apply(val, form_data):
#         pass
#     return {'generate_html': gen_html, 'apply': apply}
# 
# Path: diva/utils.py
# def render_template(filename, **variables):
#     return env.get_template(filename).render(variables)


# Path: diva/dashboard.py
from .converters import convert_to_html
from .utilities import get_utilities_for_value, label_utility
from .utils import render_template
from functools import partial

        if layout is None:
            self.layout = [[0, i, 1, 1] for i in range(len(items))]
        else:
            self.layout = layout

def get_grid_size(layout):
    max_x = max([x + w for x, y, w, h in layout])
    max_y = max([y + h for x, y, w, h in layout])
    return (max_x, max_y)

def get_grid(dash):
    grid_size = get_grid_size(dash.layout)

    # create a list of panes
    panes = []
    for index, (item, coord) in enumerate(zip(dash.items, dash.layout)):
        pane = {}
        # add 1 to point b/c CSS grids start at (1, 1) not (0, 0)
        css_coord = coord[0] + 1, coord[1] + 1, coord[2], coord[3]
        pane['x'], pane['y'], pane['w'], pane['h'] = css_coord
        pane['html'] = convert_to_html(item)
        pane['name'] = 'report {}'.format(index) 
        panes.append(pane)
    return {'size': grid_size, 'panes': panes}
 
@convert_to_html.register(Dashboard)
def dashboard_to_html(dash):
    grid = get_grid(dash)
    return render_template('dashboard.html', grid=grid)
    

@get_utilities_for_value.register(Dashboard)