Ejemplo n.º 1
0
 def recommend_similar_keywords(self, name):
     """Return keyword names similar to `name`."""
     candidates = self._get_candidates('.' in name)
     normalizer = lambda name: candidates.get(name, name).lower().replace(
         '_', ' ')
     finder = RecommendationFinder(normalizer)
     return finder.find_recommendations(name, candidates)
Ejemplo n.º 2
0
 def recommend_similar_keywords(self, name):
     """Return keyword names similar to `name`."""
     candidates = self._get_candidates('.' in name)
     normalizer = lambda name: candidates.get(name, name).lower().replace(
         '_', ' ')
     finder = RecommendationFinder(normalizer)
     return finder.find_recommendations(name, candidates)
Ejemplo n.º 3
0
 def recommend_similar_keywords(self, name, message):
     """Return keyword names similar to `name`."""
     candidates = self._get_candidates('.' 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)
Ejemplo n.º 4
0
def variable_not_found(name, candidates, msg=None, deco_braces=True):
    """Raise DataError for missing variable name.

    Return recommendations for similar variable names if any are found.
    """
    if msg is None:
        msg = "Variable '%s' not found." % name
    candidates = _decorate_candidates(name[0], candidates, deco_braces)
    normalizer = partial(normalize, ignore="$@%&*{}_", caseless=True, spaceless=True)
    finder = RecommendationFinder(normalizer)
    recommendations = finder.find_recommendations(name, candidates)
    msg = finder.format_recommendations(msg, recommendations)
    raise DataError(msg)
Ejemplo n.º 5
0
def raise_not_found(name, candidates, msg=None):
    """Raise DataError for missing variable name.

    Return recommendations for similar variable names if any are found.
    """
    if msg is None:
        msg = "Variable '%s' not found." % name
    candidates = _decorate_candidates(name[0], candidates)
    normalizer = partial(normalize, ignore='$@%&*{}_', caseless=True,
                         spaceless=True)
    finder = RecommendationFinder(normalizer)
    recommendations = finder.find_recommendations(name, candidates)
    msg = finder.format_recommendations(msg, recommendations)
    raise DataError(msg)
Ejemplo n.º 6
0
def raise_not_found(name, candidates, msg=None, env_vars=False):
    """Raise DataError for missing variable name.

    Return recommendations for similar variable names if any are found.
    """
    if msg is None:
        msg = "Variable '%s' not found." % name
    if env_vars:
        candidates = list(candidates) + ['%%{%s}' % ev for ev in get_env_vars()]
    normalizer = partial(normalize, ignore='$@%&*{}_', caseless=True,
                         spaceless=True)
    finder = RecommendationFinder(normalizer)
    recommendations = finder.find_recommendations(name, candidates)
    msg = finder.format_recommendations(msg, recommendations)
    raise DataError(msg)
Ejemplo n.º 7
0
 def _get_non_existing_setting_message(self, name, normalized):
     if normalized in TestCaseFileSettings.names:
         is_resource = isinstance(self, ResourceFileSettings)
         return "Setting '%s' is not allowed in %s file." % (
             name, 'resource' if is_resource else 'suite initialization')
     return RecommendationFinder(normalize).find_and_format(
         name=normalized,
         candidates=tuple(self.settings) + tuple(self.aliases),
         message="Non-existing setting '%s'." % name)
Ejemplo n.º 8
0
def variable_not_found(name, candidates, message=None, deco_braces=True):
    """Raise DataError for missing variable name.

    Return recommendations for similar variable names if any are found.
    """
    candidates = _decorate_candidates(name[0], candidates, deco_braces)
    normalizer = partial(normalize, ignore='$@&%{}_')
    message = RecommendationFinder(normalizer).find_and_format(
        name, candidates, message=message or "Variable '%s' not found." % name)
    raise VariableError(message)
Ejemplo n.º 9
0
 def format_recommendations(msg, recommendations):
     return RecommendationFinder.format_recommendations(
         msg, recommendations)
Ejemplo n.º 10
0
 def format_recommendations(message, recommendations):
     return RecommendationFinder().format(message, recommendations)
Ejemplo n.º 11
0
 def recommend_similar_keywords(self, name):
     """Return keyword names similar to `name`."""
     candidates = self._get_candidates('.' in name)
     finder = RecommendationFinder(
         lambda name: normalize(candidates.get(name, name), ignore='_'))
     return finder.find(name, candidates)
Ejemplo n.º 12
0
 def format_recommendations(msg, recommendations):
     return RecommendationFinder.format_recommendations(
         msg, recommendations)