#NEWLINE# def suggestAll( name , possibleSuggestions = None , threshold = 2 , includeIdenticalName = False ) : #NEWLINE# #INDENT# "Returns all suggestions in possibleSuggestions that are within the\n  levenshtein edit distance of name, sorted by distance. If there are multiple\n  names with the same edit distance, they will be returned in an undefined\n  order.\n\n  Args:\n      name (str) - The typo'd name the user supplied.\n      possibleSuggestions (sequence of str, optional) - A sequence of strings\n        for all possible suggestions that the name could match to. This\n        function will pull suggestions from this list.\n      threshold (int, optional) - A levenshtein edit distance above this\n        threshold will exclude a name from being suggested. Default is 2.\n      includeIdenticalName (bool, optional) - If True, a name identical to\n        the name arg will be included in the suggestions. Default is False." #NEWLINE# if ( possibleSuggestions is None ) : #NEWLINE# #INDENT# possibleSuggestions = [ ] #NEWLINE# #UNINDENT# sugsAndDistances = [ ( n , levenshtein ( name , n ) ) for n in possibleSuggestions if ( includeIdenticalName or ( sugsAndDistances != name ) ) ] #NEWLINE# sugsAndDistances = [ x for x in sugsAndDistances if ( x [ 1 ] <= threshold ) ] #NEWLINE# sugsAndDistances . sort ( key = ( lambda x : x [ 1 ] ) ) #NEWLINE# for sd in sugsAndDistances : #NEWLINE# #INDENT# ( yield sd [ 0 ] )