# Path: gtimer/private/loop.py
# def enter_loop(name=None,
#                rgstr_stamps=None,
#                save_itrs=True,
#                keep_subdivisions=True):
# def loop_start():
# def loop_end(loop_end_stamp=None,
#              end_stamp_unique=True,
#              keep_subdivisions=True,
#              quick_print=False):
# def exit_loop():
# def _subdivide_named_loop(name, rgstr_stamps, save_itrs):
# def _end_subdivision_named_loop():
# 
# Path: gtimer/private/focus.py
# def get_current_timer():
#     global t
#     return t
# 
# Path: gtimer/local/util.py
# def sanitize_rgstr_stamps(rgstr_stamps=None):
#     if rgstr_stamps is not None:
#         if not isinstance(rgstr_stamps, (list, tuple)):
#             raise TypeError("Expected list or tuple for param 'rgstr_stamps' (elements passed through str()).")
#         rgstr_stamps = list(set(rgstr_stamps))
#         for s in rgstr_stamps:
#             s = str(s)
#     else:
#         rgstr_stamps = list()
#     return rgstr_stamps
# 
# Path: gtimer/local/exceptions.py
# class LoopError(GTimerError):
#     pass


from gtimer.private import loop
from gtimer.private.focus import get_current_timer
from gtimer.local.util import sanitize_rgstr_stamps
from gtimer.local.exceptions import LoopError

    def __enter__(self):
        if self._exited:
            raise LoopError("Loop used as context manager previously exited (make a new one).")
        return self

    def __exit__(self, *args):
        if not self._exited:
            if self._started:
                loop.loop_end(self._loop_end_stamp,
                              self._end_stamp_unique,
                              self._keep_end_subdivisions,
                              self._quick_print)
            loop.exit_loop()
        self._exited = True

    def exit(self):
        self.__exit__()


class TimedLoop(TimedLoopBase):

    def __init__(self, *args, **kwargs):
        self._first = True
        super(TimedLoop, self).__init__(*args, **kwargs)

    def next(self):
        if self._exited:
            raise LoopError("Attempted loop iteration on already exited loop (need a new loop object).")
        if self._first:

# Path: gtimer/private/loop.py
# def enter_loop(name=None,
#                rgstr_stamps=None,
#                save_itrs=True,
#                keep_subdivisions=True):
# def loop_start():
# def loop_end(loop_end_stamp=None,
#              end_stamp_unique=True,
#              keep_subdivisions=True,
#              quick_print=False):
# def exit_loop():
# def _subdivide_named_loop(name, rgstr_stamps, save_itrs):
# def _end_subdivision_named_loop():
# 
# Path: gtimer/private/focus.py
# def get_current_timer():
#     global t
#     return t
# 
# Path: gtimer/local/util.py
# def sanitize_rgstr_stamps(rgstr_stamps=None):
#     if rgstr_stamps is not None:
#         if not isinstance(rgstr_stamps, (list, tuple)):
#             raise TypeError("Expected list or tuple for param 'rgstr_stamps' (elements passed through str()).")
#         rgstr_stamps = list(set(rgstr_stamps))
#         for s in rgstr_stamps:
#             s = str(s)
#     else:
#         rgstr_stamps = list()
#     return rgstr_stamps
# 
# Path: gtimer/local/exceptions.py
# class LoopError(GTimerError):
#     pass


# Path: gtimer/private/timedloop.py
from gtimer.private import loop
from gtimer.private.focus import get_current_timer
from gtimer.local.util import sanitize_rgstr_stamps
from gtimer.local.exceptions import LoopError


    def __enter__(self):
        if self._exited:
            raise LoopError("Loop used as context manager previously exited (make a new one).")
        return self

    def __exit__(self, *args):
        if not self._exited:
            if self._started:
                loop.loop_end(self._loop_end_stamp,
                              self._end_stamp_unique,
                              self._keep_end_subdivisions,
                              self._quick_print)
            loop.exit_loop()
        self._exited = True

    def exit(self):
        self.__exit__()


class TimedLoop(TimedLoopBase):

    def __init__(self, *args, **kwargs):
        self._first = True
        super(TimedLoop, self).__init__(*args, **kwargs)

    def next(self):
        if self._exited:
            raise LoopError("Attempted loop iteration on already exited loop (need a new loop object).")
        if self._first:

            loop.enter_loop(self._name,