# Path: gtimer/private/const.py
# UNASGN = 'UNASSIGNED'
# 
# Path: gtimer/util.py
# def iteritems(dictionary):
#     return dictionary.items()
# 
# def itervalues(dictionary):
#     return dictionary.values()


from gtimer.private.const import UNASGN
from gtimer.util import iteritems, itervalues
#


def _build_master(master, times_list):
    num_times = len(times_list)
    for i, times in enumerate(times_list):
        _build_master_single(master, times, i, num_times)


def _build_master_single(master, times, index, num_times):
        for stamp, val in iteritems(times.stamps.cum):
            if stamp not in master.stamps:
                master.stamps[stamp] = [''] * num_times
            master.stamps[stamp][index] = val
        for stamp, sub_list in iteritems(times.subdvsn):
            if stamp not in master.subdvsn:
                master.subdvsn[stamp] = list()
            for sub_times in sub_list:
                is_new = True
                for master_sub in master.subdvsn[stamp]:
                    if master_sub.name == sub_times.name:
                        is_new = False
                        break
                if is_new:
                    master_sub = CompareTimes(name=sub_times.name, parent=master)
                    master.subdvsn[stamp].append(master_sub)
                _build_master_single(master_sub, sub_times, index, num_times)
        for stamp, par_dict in iteritems(times.par_subdvsn):
            if stamp not in master.par_subdvsn:
                master.par_subdvsn[stamp] = dict()

# Path: gtimer/private/const.py
# UNASGN = 'UNASSIGNED'
# 
# Path: gtimer/util.py
# def iteritems(dictionary):
#     return dictionary.items()
# 
# def itervalues(dictionary):
#     return dictionary.values()


# Path: gtimer/local/report.py
from gtimer.private.const import UNASGN
from gtimer.util import iteritems, itervalues

#


def _build_master(master, times_list):
    num_times = len(times_list)
    for i, times in enumerate(times_list):
        _build_master_single(master, times, i, num_times)


def _build_master_single(master, times, index, num_times):
        for stamp, val in iteritems(times.stamps.cum):
            if stamp not in master.stamps:
                master.stamps[stamp] = [''] * num_times
            master.stamps[stamp][index] = val
        for stamp, sub_list in iteritems(times.subdvsn):
            if stamp not in master.subdvsn:
                master.subdvsn[stamp] = list()
            for sub_times in sub_list:
                is_new = True
                for master_sub in master.subdvsn[stamp]:
                    if master_sub.name == sub_times.name:
                        is_new = False
                        break
                if is_new:
                    master_sub = CompareTimes(name=sub_times.name, parent=master)
                    master.subdvsn[stamp].append(master_sub)
                _build_master_single(master_sub, sub_times, index, num_times)
        for stamp, par_dict in iteritems(times.par_subdvsn):
            if stamp not in master.par_subdvsn:
                master.par_subdvsn[stamp] = dict()

            for par_name, par_list in iteritems(par_dict):