# Path: airy/utils/functional.py
# def curry(_curried_func, *args, **kwargs):
#     def _curried(*moreargs, **morekwargs):
#         return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
#     return _curried
# 
# class Promise(object):
#     """
#     This is just a base class for the proxy class created in
#     the closure of the lazy function. It can be used to recognize
#     promises in code.
#     """
#     pass


from airy.utils.functional import curry, Promise
    decode = curry(_proxy_method, method = str.decode)

class SafeUnicode(unicode, SafeData):
    """
    A unicode subclass that has been specifically marked as "safe" for HTML
    output purposes.
    """
    def __add__(self, rhs):
        """
        Concatenating a safe unicode object with another safe string or safe
        unicode object is safe. Otherwise, the result is no longer safe.
        """
        t = super(SafeUnicode, self).__add__(rhs)
        if isinstance(rhs, SafeData):
            return SafeUnicode(t)
        return t
    
    def _proxy_method(self, *args, **kwargs):
        """
        Wrap a call to a normal unicode method up so that we return safe
        results. The method that is being wrapped is passed in the 'method'
        argument.
        """
        method = kwargs.pop('method')
        data = method(self, *args, **kwargs)
        if isinstance(data, str):
            return SafeString(data)
        else:
            return SafeUnicode(data)


# Path: airy/utils/functional.py
# def curry(_curried_func, *args, **kwargs):
#     def _curried(*moreargs, **morekwargs):
#         return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
#     return _curried
# 
# class Promise(object):
#     """
#     This is just a base class for the proxy class created in
#     the closure of the lazy function. It can be used to recognize
#     promises in code.
#     """
#     pass


# Path: airy/utils/safestring.py
from airy.utils.functional import curry, Promise

    decode = curry(_proxy_method, method = str.decode)

class SafeUnicode(unicode, SafeData):
    """
    A unicode subclass that has been specifically marked as "safe" for HTML
    output purposes.
    """
    def __add__(self, rhs):
        """
        Concatenating a safe unicode object with another safe string or safe
        unicode object is safe. Otherwise, the result is no longer safe.
        """
        t = super(SafeUnicode, self).__add__(rhs)
        if isinstance(rhs, SafeData):
            return SafeUnicode(t)
        return t
    
    def _proxy_method(self, *args, **kwargs):
        """
        Wrap a call to a normal unicode method up so that we return safe
        results. The method that is being wrapped is passed in the 'method'
        argument.
        """
        method = kwargs.pop('method')
        data = method(self, *args, **kwargs)
        if isinstance(data, str):
            return SafeString(data)
        else:
            return SafeUnicode(data)


    encode = curry(_proxy_method, method = unicode.encode)