Skip to content

namespace

KeywordRecommendationFinder

Source code in src/robot/running/namespace.py
class KeywordRecommendationFinder:

    def __init__(self, *owners):
        self.owners = owners

    def recommend_similar_keywords(self, name, message):
        """Return keyword names similar to `name`."""
        candidates = self._get_candidates(use_full_name='.' in name)
        finder = RecommendationFinder(
            lambda name: normalize(candidates.get(name, name), ignore='_')
        )
        return finder.find_and_format(name, candidates, message,
                                      check_missing_argument_separator=True)

    @staticmethod
    def format_recommendations(message, recommendations):
        return RecommendationFinder().format(message, recommendations)

    def _get_candidates(self, use_full_name=False):
        candidates = {}
        names = sorted((owner.name or '', kw.name)
                       for owner in self.owners for kw in owner.keywords)
        for owner, name in names:
            full_name = f'{owner}.{name}' if owner else name
            candidates[full_name] = full_name if use_full_name else name
        return candidates

recommend_similar_keywords(name, message)

Return keyword names similar to name.

Source code in src/robot/running/namespace.py
def recommend_similar_keywords(self, name, message):
    """Return keyword names similar to `name`."""
    candidates = self._get_candidates(use_full_name='.' in name)
    finder = RecommendationFinder(
        lambda name: normalize(candidates.get(name, name), ignore='_')
    )
    return finder.find_and_format(name, candidates, message,
                                  check_missing_argument_separator=True)