瀏覽代碼

ffpb_findnode: don't fuzzymatch names enclosed in quotes

Helge Jung 9 年之前
父節點
當前提交
33b4e665df
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      modules/ffpb.py

+ 8 - 2
modules/ffpb.py

@@ -347,7 +347,7 @@ def ffpb_ensurenodeid(nodedata):
 
     return result
 
-def ffpb_findnode(name, alfred_data=None):
+def ffpb_findnode(name, alfred_data=None, allow_fuzzymatching=True):
     """helper: try to identify the node the user meant by the given name"""
 
     # no name, no node
@@ -356,6 +356,12 @@ def ffpb_findnode(name, alfred_data=None):
 
     name = str(name).strip()
 
+    # disable fuzzy matching if name is enclosed in quotes
+    if name.startswith('\'') and name.endswith('\'') or \
+        name.startswith('"') and name.endswith('"'):
+        name = name[1:-1]
+        allow_fuzzymatching = False
+
     names = {}
 
     if not alfred_data is None:
@@ -433,7 +439,7 @@ def ffpb_findnode(name, alfred_data=None):
             }
 
     # do a similar name lookup in the ALFRED data
-    if not alfred_data is None:
+    if allow_fuzzymatching and not alfred_data is None:
         allnames = [x for x in names]
         possibilities = difflib.get_close_matches(name, allnames, cutoff=0.75)
         print('findnode: Fuzzy matching \'{0}\' got {1} entries: {2}'.format(