# Path: chamber/utils/decorators.py
# def singleton(klass):
#     """
#     Create singleton from class
#     """
#     instances = {}
# 
#     def getinstance(*args, **kwargs):
#         if klass not in instances:
#             instances[klass] = klass(*args, **kwargs)
#         return instances[klass]
#     return wraps(klass)(getinstance)


import collections
import copy
from chamber.utils.decorators import singleton




def _should_exclude_field(field, fields, exclude):
    return (fields and field.name not in fields) or (exclude and field.name in exclude)


def field_value_from_instance(field, instance):
    """
    Converts a model field to a dictionary
    """
    value = field.value_from_object(instance)
    if isinstance(value, (dict, list)):
        return copy.deepcopy(value)
    else:
        return value



# Path: chamber/utils/decorators.py
# def singleton(klass):
#     """
#     Create singleton from class
#     """
#     instances = {}
# 
#     def getinstance(*args, **kwargs):
#         if klass not in instances:
#             instances[klass] = klass(*args, **kwargs)
#         return instances[klass]
#     return wraps(klass)(getinstance)


# Path: chamber/models/changed_fields.py
import collections
import copy
from chamber.utils.decorators import singleton





def _should_exclude_field(field, fields, exclude):
    return (fields and field.name not in fields) or (exclude and field.name in exclude)


def field_value_from_instance(field, instance):
    """
    Converts a model field to a dictionary
    """
    value = field.value_from_object(instance)
    if isinstance(value, (dict, list)):
        return copy.deepcopy(value)
    else:
        return value



@singleton