# Path: lib/robot/running/keywords.py
# class Keywords(object):
# 
#     def __init__(self, steps, template=None):
#         self._keywords = []
#         self._templated = bool(template)
#         if self._templated:
#             steps = [s.apply_template(template) for s in steps]
#         for s in steps:
#             self._add_step(s, template)
# 
#     def _add_step(self, step, template):
#         if step.is_comment():
#             return
#         if step.is_for_loop():
#             keyword = ForLoop(step, template)
#         else:
#             keyword = Keyword(step.keyword, step.args, step.assign)
#         self.add_keyword(keyword)
# 
#     def add_keyword(self, keyword):
#         self._keywords.append(keyword)
# 
#     def run(self, context):
#         errors = []
#         for kw in self._keywords:
#             try:
#                 kw.run(context)
#             except ExecutionFailed, err:
#                 errors.extend(err.get_errors())
#                 if not err.can_continue(context.teardown, self._templated,
#                                         context.dry_run):
#                     break
#         if errors:
#             raise ExecutionFailures(errors)
# 
#     def __nonzero__(self):
#         return bool(self._keywords)
# 
#     def __iter__(self):
#         return iter(self._keywords)


import os
import re
from robot.common import BaseLibrary, UserErrorHandler
from robot.errors import DataError, ExecutionFailed, UserKeywordExecutionFailed
from robot.variables import is_list_var, VariableSplitter
from robot.output import LOGGER
from robot import utils
from .keywords import Keywords
from .fixture import Teardown
from .timeouts import KeywordTimeout
from .arguments import UserKeywordArguments
            if not found:
                raise error
            if len(found) == 1:
                return found[0]
            self._raise_multiple_matching_keywords_found(name, found)

    def _get_embedded_arg_handlers(self, name):
        found = []
        for template in self.embedded_arg_handlers:
            try:
                found.append(EmbeddedArgs(name, template))
            except TypeError:
                pass
        return found

    def _raise_multiple_matching_keywords_found(self, name, found):
        names = utils.seq2str([f.orig_name for f in found])
        if self.name is None:
            where = "Test case file"
        else:
            where = "Resource file '%s'" % self.name
        raise DataError("%s contains multiple keywords matching name '%s'\n"
                        "Found: %s" % (where, name, names))


class UserKeywordHandler(object):
    type = 'user'

    def __init__(self, keyword, libname):
        self.name = keyword.name

# Path: lib/robot/running/keywords.py
# class Keywords(object):
# 
#     def __init__(self, steps, template=None):
#         self._keywords = []
#         self._templated = bool(template)
#         if self._templated:
#             steps = [s.apply_template(template) for s in steps]
#         for s in steps:
#             self._add_step(s, template)
# 
#     def _add_step(self, step, template):
#         if step.is_comment():
#             return
#         if step.is_for_loop():
#             keyword = ForLoop(step, template)
#         else:
#             keyword = Keyword(step.keyword, step.args, step.assign)
#         self.add_keyword(keyword)
# 
#     def add_keyword(self, keyword):
#         self._keywords.append(keyword)
# 
#     def run(self, context):
#         errors = []
#         for kw in self._keywords:
#             try:
#                 kw.run(context)
#             except ExecutionFailed, err:
#                 errors.extend(err.get_errors())
#                 if not err.can_continue(context.teardown, self._templated,
#                                         context.dry_run):
#                     break
#         if errors:
#             raise ExecutionFailures(errors)
# 
#     def __nonzero__(self):
#         return bool(self._keywords)
# 
#     def __iter__(self):
#         return iter(self._keywords)


# Path: lib/robot/running/userkeyword.py
import os
import re
from robot.common import BaseLibrary, UserErrorHandler
from robot.errors import DataError, ExecutionFailed, UserKeywordExecutionFailed
from robot.variables import is_list_var, VariableSplitter
from robot.output import LOGGER
from robot import utils
from .keywords import Keywords
from .fixture import Teardown
from .timeouts import KeywordTimeout
from .arguments import UserKeywordArguments

            if not found:
                raise error
            if len(found) == 1:
                return found[0]
            self._raise_multiple_matching_keywords_found(name, found)

    def _get_embedded_arg_handlers(self, name):
        found = []
        for template in self.embedded_arg_handlers:
            try:
                found.append(EmbeddedArgs(name, template))
            except TypeError:
                pass
        return found

    def _raise_multiple_matching_keywords_found(self, name, found):
        names = utils.seq2str([f.orig_name for f in found])
        if self.name is None:
            where = "Test case file"
        else:
            where = "Resource file '%s'" % self.name
        raise DataError("%s contains multiple keywords matching name '%s'\n"
                        "Found: %s" % (where, name, names))


class UserKeywordHandler(object):
    type = 'user'

    def __init__(self, keyword, libname):
        self.name = keyword.name

        self.keywords = Keywords(keyword.steps)