(text, mandatory_words_list, level=0)
| 103 | |
| 104 | # Evaluate a mandatory words list against a text |
| 105 | def evaluate_mandatory_words(text, mandatory_words_list, level=0): |
| 106 | if level % 2 == 0: |
| 107 | # this is an "or" level so at least one of the words of compound sub-conditions should match |
| 108 | for word in mandatory_words_list: |
| 109 | if isinstance(word, list): |
| 110 | res = evaluate_mandatory_words(text, word, level + 1) |
| 111 | if res: |
| 112 | return True |
| 113 | elif word.lower() in text: |
| 114 | return True |
| 115 | return False |
| 116 | else: |
| 117 | # this is an "and" level so all of the words and compound sub-conditions must match |
| 118 | for word in mandatory_words_list: |
| 119 | if isinstance(word, list): |
| 120 | res = evaluate_mandatory_words(text, word, level + 1) |
| 121 | if not res: |
| 122 | return False |
| 123 | elif word.lower() not in text: |
| 124 | return False |
| 125 | return True |
| 126 | |
| 127 | |
| 128 | def validate_username( |
no outgoing calls