# Path: configman/memoize.py
# def memoize(max_cache_size=1000):
#     """Python 2.4 compatible memoize decorator.
#     It creates a cache that has a maximum size.  If the cache exceeds the max,
#     it is thrown out and a new one made.  With such behavior, it is wise to set
#     the cache just a little larger that the maximum expected need.
# 
#     Parameters:
#       max_cache_size - the size to which a cache can grow
#     """
#     def wrapper(f):
#         @wraps(f)
#         def fn(*args, **kwargs):
#             if kwargs:
#                 key = (args, tuple(kwargs.items()))
#             else:
#                 key = args
#             try:
#                 return fn.cache[key]
#             except KeyError:
#                 if fn.count >= max_cache_size:
#                     fn.cache = {}
#                     fn.count = 0
#                 result = f(*args, **kwargs)
#                 fn.cache[key] = result
#                 fn.count += 1
#                 return result
#             except TypeError:
#                 return f(*args, **kwargs)
#         fn.cache = {}
#         fn.count = 0
#         return fn
#     return wrapper


import collections
import weakref
import six
from configman.orderedset import OrderedSet
from configman.memoize import memoize
                raise
            raise KeyError(key)


#------------------------------------------------------------------------------
def create_key_translating_dot_dict(
    new_class_name,
    translation_tuples,
    base_class=DotDict
):
    """this function will generate a DotDict derivative class that has key
    translation built in.  If the key is not found, translations (as specified
    by the translation_tuples) are performed on the key and the lookup is
    tried again.  Only on failure of this second lookup will the KeyError
    exception be raised.

    parameters:
        new_class_name - the name of the returned class
        translation_tuples - a sequence of 2-tuples of the form:
                             (original_substring, substitution_string)
        base_class - the baseclass on which this new class is to be based
    """
    #==========================================================================
    class DotDictWithKeyTranslations(base_class):

        def __init__(self, *args, **kwargs):
            self.__dict__['_translation_tuples'] = translation_tuples
            super(DotDictWithKeyTranslations, self).__init__(*args, **kwargs)

        #----------------------------------------------------------------------

# Path: configman/memoize.py
# def memoize(max_cache_size=1000):
#     """Python 2.4 compatible memoize decorator.
#     It creates a cache that has a maximum size.  If the cache exceeds the max,
#     it is thrown out and a new one made.  With such behavior, it is wise to set
#     the cache just a little larger that the maximum expected need.
# 
#     Parameters:
#       max_cache_size - the size to which a cache can grow
#     """
#     def wrapper(f):
#         @wraps(f)
#         def fn(*args, **kwargs):
#             if kwargs:
#                 key = (args, tuple(kwargs.items()))
#             else:
#                 key = args
#             try:
#                 return fn.cache[key]
#             except KeyError:
#                 if fn.count >= max_cache_size:
#                     fn.cache = {}
#                     fn.count = 0
#                 result = f(*args, **kwargs)
#                 fn.cache[key] = result
#                 fn.count += 1
#                 return result
#             except TypeError:
#                 return f(*args, **kwargs)
#         fn.cache = {}
#         fn.count = 0
#         return fn
#     return wrapper


# Path: configman/dotdict.py
import collections
import weakref
import six
from configman.orderedset import OrderedSet
from configman.memoize import memoize

                raise
            raise KeyError(key)


#------------------------------------------------------------------------------
def create_key_translating_dot_dict(
    new_class_name,
    translation_tuples,
    base_class=DotDict
):
    """this function will generate a DotDict derivative class that has key
    translation built in.  If the key is not found, translations (as specified
    by the translation_tuples) are performed on the key and the lookup is
    tried again.  Only on failure of this second lookup will the KeyError
    exception be raised.

    parameters:
        new_class_name - the name of the returned class
        translation_tuples - a sequence of 2-tuples of the form:
                             (original_substring, substitution_string)
        base_class - the baseclass on which this new class is to be based
    """
    #==========================================================================
    class DotDictWithKeyTranslations(base_class):

        def __init__(self, *args, **kwargs):
            self.__dict__['_translation_tuples'] = translation_tuples
            super(DotDictWithKeyTranslations, self).__init__(*args, **kwargs)

        #----------------------------------------------------------------------

        @memoize()