summaryrefslogtreecommitdiff
path: root/python/__init__.py
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2024-06-30 18:14:39 -0400
committerGlenn Smith <glenn@vector35.com>2024-07-18 16:18:01 -0400
commit3488068810307387117626066240761195266659 (patch)
tree8307a7cd9b5ced9f249f8a349fa3dbb38aa2252c /python/__init__.py
parent6a496b01b3e8a85c8231c949a306933e7ad58bfc (diff)
Add fuzzy completion to the python console
Co-Authored-By: Rusty Wagner <rusty@vector35.com> Co-Authored-By: Kyle Miles <kyle@vector35.com>
Diffstat (limited to 'python/__init__.py')
-rw-r--r--python/__init__.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/python/__init__.py b/python/__init__.py
index ec218d38..144e2643 100644
--- a/python/__init__.py
+++ b/python/__init__.py
@@ -461,6 +461,21 @@ class UIPluginInHeadlessError(Exception):
Exception.__init__(self, *args, **kwargs)
+def fuzzy_match_single(target, query) -> Optional[int]:
+ """
+ Fuzzy match a string against a query string. Returns a score that is higher for
+ a more confident match, or None if the query does not match the target string.
+
+ :param target: Target (larger) string
+ :param query: Query (smaller) string
+ :return: Confidence of match, or None if the string doesn't match
+ """
+ result = core.BNFuzzyMatchSingle(target, query)
+ if result == 0:
+ return None
+ return result
+
+
# Load Collaboration scripts from Enterprise (they are bundled in shipping builds)
try:
from . import collaboration