MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / rule_exists

Function rule_exists

src/licensedcode/models.py:2987–3004  ·  view source on GitHub ↗

Return the matched rule if the text is an existing rule matched exactly, False otherwise.

(text)

Source from the content-addressed store, hash-verified

2985
2986
2987def rule_exists(text):
2988 """
2989 Return the matched rule if the text is an existing rule matched
2990 exactly, False otherwise.
2991 """
2992 from licensedcode.match_hash import MATCH_HASH
2993 from licensedcode import cache
2994
2995 idx = cache.get_index()
2996
2997 matches = idx.match(query_string=text)
2998 if not matches:
2999 return False
3000 if len(matches) > 1:
3001 return False
3002 match = matches[0]
3003 if match.matcher == MATCH_HASH and match.coverage() == 100:
3004 return match.rule
3005
3006
3007def get_rule_id_for_text(text):

Callers 2

get_rule_id_for_textFunction · 0.85

Calls 2

matchMethod · 0.80
coverageMethod · 0.45

Tested by

no test coverage detected