From 3488068810307387117626066240761195266659 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Sun, 30 Jun 2024 18:14:39 -0400 Subject: Add fuzzy completion to the python console Co-Authored-By: Rusty Wagner Co-Authored-By: Kyle Miles --- python/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'python/__init__.py') 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 -- cgit v1.3.1