# Path: robot_designer_plugin/core/logfile.py
# def LogFunction(func):
#     def func_logger(self, context):
# def log_callstack(back_trace=False):
# def log_callstack_last(back_trace=False):
# 
# Path: robot_designer_plugin/core/config.py
# EXCEPTION_MESSAGE = "\tException:\t%s\n\tMessages:\n\t\t%s\n%s\n%s"


from .logfile import operator_logger as logger, log_callstack
from .config import EXCEPTION_MESSAGE
    Classes should implement a ``check()`` method which returns a tuple of (bool,str) stating whether
    the condition's are met and an (potentially) empty error message.

    Using the :meth:`.operators.RDOperator.Preconditions` decorator, the conditions that should be met
    when executing an operator (i.e., a subclass of :class:`.operators.RDOperator`) are added to the classes'
    list of preconditions and :meth:`check_conditions` is called when Blender executes the
    :meth:`.operators.RDOperator.poll` method.

    .. note::

        Instances of this type should never be created.

    For examples see :class:`robot_designer_plugin.operators.helpers.ModelSelected`.
    """

    @staticmethod
    def check_conditions(*conditions):
        """
        Checks whether the arguments are met.

        :param conditions: A an arbitrary number of conditions
        :type conditions: :class:`Condition` sub classes.
        :return: Tuple(bool, str), True and empty string if all conditions are met. False and sting with message of
        unmet conditions.
        """
        try:
            check = [i.check() for i in conditions]
            return all([i[0] for i in check]), "\n".join([i[1] for i in check if not i[0]])

        except Exception as e:

# Path: robot_designer_plugin/core/logfile.py
# def LogFunction(func):
#     def func_logger(self, context):
# def log_callstack(back_trace=False):
# def log_callstack_last(back_trace=False):
# 
# Path: robot_designer_plugin/core/config.py
# EXCEPTION_MESSAGE = "\tException:\t%s\n\tMessages:\n\t\t%s\n%s\n%s"


# Path: robot_designer_plugin/core/conditions.py
from .logfile import operator_logger as logger, log_callstack
from .config import EXCEPTION_MESSAGE

    Classes should implement a ``check()`` method which returns a tuple of (bool,str) stating whether
    the condition's are met and an (potentially) empty error message.

    Using the :meth:`.operators.RDOperator.Preconditions` decorator, the conditions that should be met
    when executing an operator (i.e., a subclass of :class:`.operators.RDOperator`) are added to the classes'
    list of preconditions and :meth:`check_conditions` is called when Blender executes the
    :meth:`.operators.RDOperator.poll` method.

    .. note::

        Instances of this type should never be created.

    For examples see :class:`robot_designer_plugin.operators.helpers.ModelSelected`.
    """

    @staticmethod
    def check_conditions(*conditions):
        """
        Checks whether the arguments are met.

        :param conditions: A an arbitrary number of conditions
        :type conditions: :class:`Condition` sub classes.
        :return: Tuple(bool, str), True and empty string if all conditions are met. False and sting with message of
        unmet conditions.
        """
        try:
            check = [i.check() for i in conditions]
            return all([i[0] for i in check]), "\n".join([i[1] for i in check if not i[0]])

        except Exception as e:

            logger.error("Exception in check precondition!\n {} \nConditions: {}  {} {}".format(EXCEPTION_MESSAGE,