# Path: infi/pyutils/decorators.py
# def wraps(wrapped):
#     """ a convenience function on top of functools.wraps:
# 
#     - adds the original function to the wrapped function as __wrapped__ attribute."""
#     def new_decorator(f):
#         returned = functools.wraps(wrapped)(f)
#         returned.__wrapped__ = wrapped
#         return returned
#     return new_decorator
# 
# Path: infi/pyutils/python_compat.py
# _PYTHON_VERSION = platform.python_version()
# _IS_PYTHON_3 = _PYTHON_VERSION >= '3'
# _IS_BELOW_PYTHON_2_7 = _PYTHON_VERSION < '2.7'
# def get_underlying_function(f):
# def _get_underlying_classmethod_function(f):
#     def create_bound_method(func, self):
#     class TemporaryClass(object):


import itertools
import time
from .decorators import wraps
from .python_compat import iteritems
from logging import getLogger
from types import MethodType, FunctionType
    from inspect import getmembers

    def _create_value(self, key):
        raise NotImplementedError()

class CacheData(dict):
    def __init__(self):
        super(CacheData, self).__init__()
        self._is_valid = set()
    def __getitem__(self, key):
        if key not in self._is_valid:
            logger.debug("cache found invalidate., updating cache for {0}".format(key))
            raise KeyError
        return dict.__getitem__(self, key)
    def __setitem__(self, key, value):
        ret_val = dict.__setitem__(self, key, value)
        self._is_valid.add(key)
        return ret_val
    def invalidate(self):
        logger.debug("Invalidate cache")
        self._is_valid = set()

class TimerCacheData(CacheData):
    def __init__(self, poll_time):
        super(TimerCacheData, self).__init__()
        self.poll_time = poll_time

    def __getitem__(self, key):
        next_poll_time, value = CacheData.__getitem__(self, key)
        if time.time() > next_poll_time:
            raise KeyError

# Path: infi/pyutils/decorators.py
# def wraps(wrapped):
#     """ a convenience function on top of functools.wraps:
# 
#     - adds the original function to the wrapped function as __wrapped__ attribute."""
#     def new_decorator(f):
#         returned = functools.wraps(wrapped)(f)
#         returned.__wrapped__ = wrapped
#         return returned
#     return new_decorator
# 
# Path: infi/pyutils/python_compat.py
# _PYTHON_VERSION = platform.python_version()
# _IS_PYTHON_3 = _PYTHON_VERSION >= '3'
# _IS_BELOW_PYTHON_2_7 = _PYTHON_VERSION < '2.7'
# def get_underlying_function(f):
# def _get_underlying_classmethod_function(f):
#     def create_bound_method(func, self):
#     class TemporaryClass(object):


# Path: infi/pyutils/lazy.py
import itertools
import time
from .decorators import wraps
from .python_compat import iteritems
from logging import getLogger
from types import MethodType, FunctionType
    from inspect import getmembers


    def _create_value(self, key):
        raise NotImplementedError()

class CacheData(dict):
    def __init__(self):
        super(CacheData, self).__init__()
        self._is_valid = set()
    def __getitem__(self, key):
        if key not in self._is_valid:
            logger.debug("cache found invalidate., updating cache for {0}".format(key))
            raise KeyError
        return dict.__getitem__(self, key)
    def __setitem__(self, key, value):
        ret_val = dict.__setitem__(self, key, value)
        self._is_valid.add(key)
        return ret_val
    def invalidate(self):
        logger.debug("Invalidate cache")
        self._is_valid = set()

class TimerCacheData(CacheData):
    def __init__(self, poll_time):
        super(TimerCacheData, self).__init__()
        self.poll_time = poll_time

    def __getitem__(self, key):
        next_poll_time, value = CacheData.__getitem__(self, key)
        if time.time() > next_poll_time:
            raise KeyError

        return value