# Path: awsshell/fuzzy.py
# def fuzzy_search(user_input, corpus):
# def calculate_score(search_string, word):


import os
import logging
import botocore.session
from prompt_toolkit.completion import Completer, Completion
from awsshell import fuzzy
        from awsshell.resource import index
                len(self._completer.cmd_path) == 3):
            # If we couldn't complete anything from the JSON model
            # completer and we're on a cli option (e.g --foo), we
            # can ask the server side completer if it knows anything
            # about this resource.
            LOG.debug("No local autocompletions found, trying "
                      "server side completion.")
            command = self._completer.cmd_path
            service = command[1]
            if service == 's3api':
                # TODO: we need a more generic way to capture renames
                # of commands.  This currently lives in the CLI
                # customization code.
                service = 's3'
            operation = command[2]
            param = self._completer.arg_metadata.get(
                self._completer.last_option, {}).get('api_name')
            if param is not None:
                LOG.debug("Trying to retrieve autcompletion for: "
                          "%s, %s, %s", service, operation, param)
                results = self._server_side_completer\
                    .retrieve_candidate_values(service, operation, param)
                LOG.debug("Results for %s, %s, %s: %s",
                          service, operation, param, results)
                word_before_cursor = text_before_cursor.strip().split()[-1]
                location = 0
                if text_before_cursor[-1] != ' ' and \
                        word_before_cursor and results:
                    # Filter the results down by fuzzy searching what
                    # the user has provided.

# Path: awsshell/fuzzy.py
# def fuzzy_search(user_input, corpus):
# def calculate_score(search_string, word):


# Path: awsshell/shellcomplete.py
import os
import logging
import botocore.session
from prompt_toolkit.completion import Completer, Completion
from awsshell import fuzzy
        from awsshell.resource import index

                len(self._completer.cmd_path) == 3):
            # If we couldn't complete anything from the JSON model
            # completer and we're on a cli option (e.g --foo), we
            # can ask the server side completer if it knows anything
            # about this resource.
            LOG.debug("No local autocompletions found, trying "
                      "server side completion.")
            command = self._completer.cmd_path
            service = command[1]
            if service == 's3api':
                # TODO: we need a more generic way to capture renames
                # of commands.  This currently lives in the CLI
                # customization code.
                service = 's3'
            operation = command[2]
            param = self._completer.arg_metadata.get(
                self._completer.last_option, {}).get('api_name')
            if param is not None:
                LOG.debug("Trying to retrieve autcompletion for: "
                          "%s, %s, %s", service, operation, param)
                results = self._server_side_completer\
                    .retrieve_candidate_values(service, operation, param)
                LOG.debug("Results for %s, %s, %s: %s",
                          service, operation, param, results)
                word_before_cursor = text_before_cursor.strip().split()[-1]
                location = 0
                if text_before_cursor[-1] != ' ' and \
                        word_before_cursor and results:
                    # Filter the results down by fuzzy searching what
                    # the user has provided.

                    results = fuzzy.fuzzy_search(word_before_cursor, results)