Exemple #1
0
    def matches(self, message):
        if message.contact.fields:
            contact_value = normalize(message.contact.fields.get(self.key, ""))

            for value in self.values:
                if value == contact_value:
                    return True
        return False
Exemple #2
0
    def matches(self, message):
        if message.contact.fields:
            contact_value = normalize(message.contact.fields.get(self.key, ""))

            for value in self.values:
                if value == contact_value:
                    return True
        return False
Exemple #3
0
    def matches(self, message):
        text = normalize(message.text)

        def keyword_check(w):
            return lambda: bool(regex.search(r'\b' + w + r'\b', text, flags=regex.UNICODE | regex.V0))

        checks = [keyword_check(keyword) for keyword in self.keywords]

        return self.quantifier.evaluate(checks)
Exemple #4
0
    def matches(self, message):
        text = normalize(message.text)

        def keyword_check(w):
            return lambda: bool(regex.search(r"\b" + w + r"\b", text, flags=regex.UNICODE | regex.V0))

        checks = [keyword_check(keyword) for keyword in self.keywords]

        return self.quantifier.evaluate(checks)
Exemple #5
0
    def clean_keywords(self):
        keywords = parse_csv(self.cleaned_data['keywords'])
        clean_keywords = []
        for keyword in keywords:
            clean_keyword = normalize(keyword)

            if not ContainsTest.is_valid_keyword(keyword):
                raise forms.ValidationError(_("Invalid keyword: %s") % keyword)

            clean_keywords.append(clean_keyword)

        return ', '.join(clean_keywords)
Exemple #6
0
    def clean_keywords(self):
        keywords = parse_csv(self.cleaned_data['keywords'])
        clean_keywords = []
        for keyword in keywords:
            clean_keyword = normalize(keyword)

            if not ContainsTest.is_valid_keyword(keyword):
                raise forms.ValidationError(_("Invalid keyword: %s") % keyword)

            clean_keywords.append(clean_keyword)

        return ', '.join(clean_keywords)
Exemple #7
0
    def clean_keywords(self):
        keywords = parse_csv(self.cleaned_data['keywords'])
        clean_keywords = []
        for keyword in keywords:
            clean_keyword = normalize(keyword)

            if len(keyword) < Label.KEYWORD_MIN_LENGTH:
                raise forms.ValidationError(_("Keywords must be at least %d characters long")
                                            % Label.KEYWORD_MIN_LENGTH)

            if not Label.is_valid_keyword(keyword):
                raise forms.ValidationError(_("Invalid keyword: %s") % keyword)

            clean_keywords.append(clean_keyword)

        return ','.join(clean_keywords)
Exemple #8
0
 def __init__(self, key, values):
     self.key = key
     self.values = [normalize(v) for v in values]
Exemple #9
0
 def __init__(self, keywords, quantifier):
     self.keywords = [normalize(word) for word in keywords]
     self.quantifier = quantifier
Exemple #10
0
 def __init__(self, key, values):
     self.key = key
     self.values = [normalize(v) for v in values]
Exemple #11
0
 def __init__(self, keywords, quantifier):
     self.keywords = [normalize(word) for word in keywords]
     self.quantifier = quantifier