11
22import fuzzysearch
3+ from robot .api import logger
34
45def fuzzy_find (buffer , expected , percent_match = None , max_errors = None , max_insertions :int = None , max_deletions :int = None , ignore_case = False ):
56 found = fuzzy_find_all (buffer , expected , percent_match , max_errors , max_insertions , max_deletions , ignore_case )
@@ -25,12 +26,17 @@ def fuzzy_find_all(buffer, expected, percent_match:float=None, max_errors:int=No
2526 else :
2627 max_l_dist = None
2728
28-
29- if ignore_case :
30- matches = fuzzysearch .find_near_matches (expected .lower (), buffer .lower (), max_l_dist = max_l_dist , max_insertions = max_insertions , max_deletions = max_deletions )
31- # change matched to contain original, possibly uppercase, input
32- for match in matches :
33- match .matched = buffer [match .start :match .end ]
34- else :
35- matches = fuzzysearch .find_near_matches (expected , buffer , max_l_dist = max_l_dist , max_insertions = max_insertions , max_deletions = max_deletions )
29+ try :
30+ if ignore_case :
31+ matches = fuzzysearch .find_near_matches (expected .lower (), buffer .lower (), max_l_dist = max_l_dist , max_insertions = max_insertions , max_deletions = max_deletions )
32+ # change matched to contain original, possibly uppercase, input
33+ for match in matches :
34+ match .matched = buffer [match .start :match .end ]
35+ else :
36+ matches = fuzzysearch .find_near_matches (expected , buffer , max_l_dist = max_l_dist , max_insertions = max_insertions , max_deletions = max_deletions )
37+ except Exception as e :
38+ logger .error (e )
39+ logger .error ("\n \n \n buffer:" )
40+ logger .error (buffer )
41+ logger .error ("\n \n \n expected:" )
3642 return matches
0 commit comments