Return the matched rule if the text is an existing rule matched exactly, False otherwise.
(text)
| 2985 | |
| 2986 | |
| 2987 | def 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 | |
| 3007 | def get_rule_id_for_text(text): |
no test coverage detected