# Path: gtimer/private/focus.py
# def create_next_timer(*args, **kwargs):
# def remove_last_timer():
# def create_next_loop(*args, **kwargs):
# def remove_last_loop():
# def refresh_shortcuts():
# def hard_reset():
# def get_current_timer():
# 
# Path: gtimer/local/merge.py
# def merge_times(rcvr, new):
# def _merge_stamps(rcvr, new):
# def _merge_dict(rcvr, new, attr):
# def _merge_dict_itr(rcvr, new, attr, itr_func):
# def _stamps_as_itr(rcvr, new):
# def _merge_subdivisions(rcvr, new):
# def _merge_par_subdivisions(rcvr, new):
# 
# Path: gtimer/util.py
# def iteritems(dictionary):
#     return dictionary.items()
# 
# def itervalues(dictionary):
#     return dictionary.values()


from timeit import default_timer as timer
from gtimer.private import focus as f
from gtimer.local import merge
from gtimer.util import iteritems, itervalues
    # time aggregates during subdivision assignment.
    if f.t.is_named_loop:
        f.r.parent.self_agg += f.r.self_agg + merge_t


def assign_subdivisions(position, keep_subdivisions=True):
    # Aggregate the self-time whether subdvisions kept or not.
    for times in itervalues(f.t.subdvsn_awaiting):
        f.r.self_agg += times.self_agg
    for sub_list in itervalues(f.t.par_subdvsn_awaiting):
        sub_with_max_tot = max(sub_list, key=lambda x: x.total)
        f.r.self_agg += sub_with_max_tot.self_agg
    if keep_subdivisions:
        if f.t.subdvsn_awaiting:
            _assign_subdvsn(position)
        if f.t.par_subdvsn_awaiting:
            _assign_par_subdvsn(position)
    f.t.subdvsn_awaiting.clear()
    f.t.par_subdvsn_awaiting.clear()


#
# Private helper functions.
#


def _assign_subdvsn(position):
    new_pos = position not in f.r.subdvsn and f.t.subdvsn_awaiting
    if new_pos:
        f.r.subdvsn[position] = list()

# Path: gtimer/private/focus.py
# def create_next_timer(*args, **kwargs):
# def remove_last_timer():
# def create_next_loop(*args, **kwargs):
# def remove_last_loop():
# def refresh_shortcuts():
# def hard_reset():
# def get_current_timer():
# 
# Path: gtimer/local/merge.py
# def merge_times(rcvr, new):
# def _merge_stamps(rcvr, new):
# def _merge_dict(rcvr, new, attr):
# def _merge_dict_itr(rcvr, new, attr, itr_func):
# def _stamps_as_itr(rcvr, new):
# def _merge_subdivisions(rcvr, new):
# def _merge_par_subdivisions(rcvr, new):
# 
# Path: gtimer/util.py
# def iteritems(dictionary):
#     return dictionary.items()
# 
# def itervalues(dictionary):
#     return dictionary.values()


# Path: gtimer/private/times.py
from timeit import default_timer as timer
from gtimer.private import focus as f
from gtimer.local import merge
from gtimer.util import iteritems, itervalues

    # time aggregates during subdivision assignment.
    if f.t.is_named_loop:
        f.r.parent.self_agg += f.r.self_agg + merge_t


def assign_subdivisions(position, keep_subdivisions=True):
    # Aggregate the self-time whether subdvisions kept or not.
    for times in itervalues(f.t.subdvsn_awaiting):
        f.r.self_agg += times.self_agg
    for sub_list in itervalues(f.t.par_subdvsn_awaiting):
        sub_with_max_tot = max(sub_list, key=lambda x: x.total)
        f.r.self_agg += sub_with_max_tot.self_agg
    if keep_subdivisions:
        if f.t.subdvsn_awaiting:
            _assign_subdvsn(position)
        if f.t.par_subdvsn_awaiting:
            _assign_par_subdvsn(position)
    f.t.subdvsn_awaiting.clear()
    f.t.par_subdvsn_awaiting.clear()


#
# Private helper functions.
#


def _assign_subdvsn(position):
    new_pos = position not in f.r.subdvsn and f.t.subdvsn_awaiting
    if new_pos:
        f.r.subdvsn[position] = list()

        for sub_times in itervalues(f.t.subdvsn_awaiting):