# Path: percept/utils/input.py
# def import_from_string(import_string):
#     """
#     Import a class from a string
#     import_string - string path to module to import using dot notation (foo.bar)
#     """
#     import_split = import_string.split(".")
#     import_class = import_split[-1]
#     module_path = ".".join(import_split[:-1])
#     mod = __import__(module_path, fromlist=[import_class])
#     klass = getattr(mod, import_class)
#     return klass
# 
# Path: percept/conf/base.py
# class Settings(object):
#     def _initialize(self, settings_module):
#     def _setup(self):
#     def __getattr__(self, name):
#     def _configure_logging(self):
#     def configured(self):


import json
import logging
import pickle
from percept.utils.input import import_from_string
from percept.conf.base import settings
Define fields for tasks and formatters
"""


log = logging.getLogger(__name__)

class Field(object):
    """
    A field that is used as a descriptor on classes.
    Caches the value in one of several ways
    """
    #Type of caching is defined in settings
    value_cls = import_from_string(settings.CACHE)
    default = None

    def __init__(self, required_input = False):
        #Initialize the storage class
        self.value = self.value_cls()
        self.required_input = required_input
        if self.default is not None:
            self.__set__(None, self.default)

    def __get__(self, obj, obj_type):
        """
        As a descriptor, override __get__
        """
        #This ensures that the field is retrieved when needed
        if obj is None:
            return self
        #Whether or not to convert values to/from json

# Path: percept/utils/input.py
# def import_from_string(import_string):
#     """
#     Import a class from a string
#     import_string - string path to module to import using dot notation (foo.bar)
#     """
#     import_split = import_string.split(".")
#     import_class = import_split[-1]
#     module_path = ".".join(import_split[:-1])
#     mod = __import__(module_path, fromlist=[import_class])
#     klass = getattr(mod, import_class)
#     return klass
# 
# Path: percept/conf/base.py
# class Settings(object):
#     def _initialize(self, settings_module):
#     def _setup(self):
#     def __getattr__(self, name):
#     def _configure_logging(self):
#     def configured(self):


# Path: percept/fields/base.py
import json
import logging
import pickle
from percept.utils.input import import_from_string
from percept.conf.base import settings

Define fields for tasks and formatters
"""


log = logging.getLogger(__name__)

class Field(object):
    """
    A field that is used as a descriptor on classes.
    Caches the value in one of several ways
    """
    #Type of caching is defined in settings
    value_cls = import_from_string(settings.CACHE)
    default = None

    def __init__(self, required_input = False):
        #Initialize the storage class
        self.value = self.value_cls()
        self.required_input = required_input
        if self.default is not None:
            self.__set__(None, self.default)

    def __get__(self, obj, obj_type):
        """
        As a descriptor, override __get__
        """
        #This ensures that the field is retrieved when needed
        if obj is None:
            return self
        #Whether or not to convert values to/from json

        if settings.SERIALIZE_CACHE_VALUES: