pywinauto.fuzzydict¶
Match items in a dictionary using fuzzy matching
Implemented for pywinauto.
This class uses difflib to match strings. This class uses a linear search to find the items as it HAS to iterate over every item in the dictionary (otherwise it would not be possible to know which is the ‘best’ match).
If the exact item is in the dictionary (no fuzzy matching needed - then it doesn’t do the linear search and speed should be similar to standard Python dictionaries.
>>> fuzzywuzzy = FuzzyDict({"hello" : "World", "Hiya" : 2, "Here you are" : 3}) >>> fuzzywuzzy['Me again'] = [1,2,3] >>> >>> fuzzywuzzy['Hi'] 2 >>> >>> >>> # next one doesn't match well enough - so a key error is raised ... >>> fuzzywuzzy['There'] Traceback (most recent call last): File "<stdin>", line 1, in ? File "pywinauto uzzydict.py", line 125, in __getitem__ raise KeyError( KeyError: "'There'. closest match: 'hello' with ratio 0.400" >>> >>> fuzzywuzzy['you are'] 3 >>> fuzzywuzzy['again'] [1, 2, 3] >>>
- class
pywinauto.fuzzydict.
FuzzyDict
(items=None, cutoff=0.6)¶Provides a dictionary that performs fuzzy lookup