# 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 _report_header(times, timer_state):
    FMT = FMTS_RPT['Header']
    state_str = "" if timer_state is None else " ({})".format(timer_state)
    rep = FMT['HDR_STR'].format('Timer Name' + FMT['APND'], times.name + state_str)
    rep += FMT['HDR_FLT'].format('Total Time (s)' + FMT['APND'], times.total)
    rep += FMT['HDR_FLT'].format('Stamps Sum' + FMT['APND'], times.stamps_sum)
    rep += FMT['HDR_FLT'].format('Self Time (Agg.)' + FMT['APND'], times.self_agg)
    return rep


def _report_stamps(times, indent=0, par=False):
    FMT = FMTS_RPT['Stamps']
    stamps = times.stamps
    rep = ''
    if indent > 0:
        rep += FMT['TMR'].format(FMT['IDT_SYM'] * indent, times.name)
    for stamp in stamps.order:
        stamp_str = stamp + FMT['SPC']
        stamp_str += FMT['PAR'] if par else ''
        rep += FMT['STMP'].format(FMT['IDT_SYM'] * indent, stamp_str, stamps.cum[stamp])
        if stamp in times.subdvsn:
            rep += _report_sub_times(times.subdvsn[stamp], indent, par=par)
        if stamp in times.par_subdvsn:
            rep += _report_par_sub_times(times.par_subdvsn[stamp], indent)
    if UNASGN in times.subdvsn:
        rep += "\n{}{}".format(FMT['IDT_SYM'] * indent, UNASGN)
        rep += _report_sub_times(times.subdvsn[UNASGN], indent, par=par)
    if UNASGN in times.par_subdvsn:
        rep += "\n{}{}".format(FMT['IDT_SYM'] * indent, UNASGN)

# 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 _report_header(times, timer_state):
    FMT = FMTS_RPT['Header']
    state_str = "" if timer_state is None else " ({})".format(timer_state)
    rep = FMT['HDR_STR'].format('Timer Name' + FMT['APND'], times.name + state_str)
    rep += FMT['HDR_FLT'].format('Total Time (s)' + FMT['APND'], times.total)
    rep += FMT['HDR_FLT'].format('Stamps Sum' + FMT['APND'], times.stamps_sum)
    rep += FMT['HDR_FLT'].format('Self Time (Agg.)' + FMT['APND'], times.self_agg)
    return rep


def _report_stamps(times, indent=0, par=False):
    FMT = FMTS_RPT['Stamps']
    stamps = times.stamps
    rep = ''
    if indent > 0:
        rep += FMT['TMR'].format(FMT['IDT_SYM'] * indent, times.name)
    for stamp in stamps.order:
        stamp_str = stamp + FMT['SPC']
        stamp_str += FMT['PAR'] if par else ''
        rep += FMT['STMP'].format(FMT['IDT_SYM'] * indent, stamp_str, stamps.cum[stamp])
        if stamp in times.subdvsn:
            rep += _report_sub_times(times.subdvsn[stamp], indent, par=par)
        if stamp in times.par_subdvsn:
            rep += _report_par_sub_times(times.par_subdvsn[stamp], indent)
    if UNASGN in times.subdvsn:
        rep += "\n{}{}".format(FMT['IDT_SYM'] * indent, UNASGN)
        rep += _report_sub_times(times.subdvsn[UNASGN], indent, par=par)
    if UNASGN in times.par_subdvsn:
        rep += "\n{}{}".format(FMT['IDT_SYM'] * indent, UNASGN)

        rep += _report_par_sub_times(times.par_subdvsn[UNASGN], indent)