# Path: databot/expressions/utils.py
# class StopEval(Exception):
# 
#     def __init__(self, value):
#         self.value = value
# 
# Path: databot/expressions/utils.py
# HANDLERS = defaultdict(list)


import inspect
import logging
import pprintpp
import textwrap
from collections import namedtuple
from databot.expressions.utils import StopEval
from databot.expressions.utils import HANDLERS
        value : object
            Value used to evaluate this expression.
        base : object
            Base value used as value for expressions passed as arguments. If not given, base will be equal to value.

        """
        self._evals += 1
        base = value if base is None else base

        try:
            for i, item in enumerate(self._stack):
                if isinstance(item, Func):
                    for handler in HANDLERS[item.name]:
                        conditions = (
                            (handler.items is None or 'func' in handler.items) and
                            (handler.types is None or isinstance(value, handler.types))
                        )
                        if conditions:
                            args, kwargs = self._eval_args(base, item, handler.eval_args)
                            logger.debug('eval: %s', _HandlerRepr(handler.handler, (value,) + args, kwargs))
                            try:
                                value = handler.handler(self, i, value, *args, **kwargs)
                            except StopEval as e:
                                logger.debug('eval: StopEval')
                                return e.value
                            break
                    else:
                        raise ExpressionError("Unknown function %r for value %r." % (item.name, value))

                elif isinstance(item, Method):

# Path: databot/expressions/utils.py
# class StopEval(Exception):
# 
#     def __init__(self, value):
#         self.value = value
# 
# Path: databot/expressions/utils.py
# HANDLERS = defaultdict(list)


# Path: databot/expressions/base.py
import inspect
import logging
import pprintpp
import textwrap
from collections import namedtuple
from databot.expressions.utils import StopEval
from databot.expressions.utils import HANDLERS

        value : object
            Value used to evaluate this expression.
        base : object
            Base value used as value for expressions passed as arguments. If not given, base will be equal to value.

        """
        self._evals += 1
        base = value if base is None else base

        try:
            for i, item in enumerate(self._stack):
                if isinstance(item, Func):
                    for handler in HANDLERS[item.name]:
                        conditions = (
                            (handler.items is None or 'func' in handler.items) and
                            (handler.types is None or isinstance(value, handler.types))
                        )
                        if conditions:
                            args, kwargs = self._eval_args(base, item, handler.eval_args)
                            logger.debug('eval: %s', _HandlerRepr(handler.handler, (value,) + args, kwargs))
                            try:
                                value = handler.handler(self, i, value, *args, **kwargs)
                            except StopEval as e:
                                logger.debug('eval: StopEval')
                                return e.value
                            break
                    else:
                        raise ExpressionError("Unknown function %r for value %r." % (item.name, value))

                elif isinstance(item, Method):

                    for handler in HANDLERS[item.name]: