(self, mail)
Compute a global score using multiple methods and mail.
Compute a global score using multiple methods and mail.
Compute a global score using multiple methods and mail .
def __init__(self, mail):
        """Compute a global score using multiple methods and mail."""
        self.scores = extract_mail_spam_scores(mail)
        log.debug('Found spam scores {s}'.format(s=self.scores))
        if 'level' in self.scores:
            self.method = 'level'
            self.score = min(100.0, self.scores['level'] * 4.0)
        if 'score' in self.scores:
            self.method = 'score'
            self.score = min(0.0, self.scores['score']) * 10.0
        if 'status_score' in self.scores:
            self.method = 'status'
            if self.scores['status_score'] < 2.0:
                self.score = 0.0
            else:
                tmp_score = min(100.0, self.scores['status_score'] * 10)
                self.score = max(0.0, tmp_score)
        if self.scores.get('flag'):
            self.is_spam = True
            self.source_flag = self.scores['flag']
        if not self.is_spam and self.score >= 50:
            self.is_spam = True
        if self.score < 0:
            self.score = 0.0
        if self.score > 100:
            self.score = 100.0
def __init__ ( self , mail ) : self . scores = extract_mail_spam_scores ( mail ) log . debug ( 'Found spam scores {s}' . format ( s = self . scores ) ) if 'level' in self . scores : self . method = 'level' self . score = min ( 100.0 , self . scores [ 'level' ] * 4.0 ) if 'score' in self . scores : self . method = 'score' self . score = min ( 0.0 , self . scores [ 'score' ] ) * 10.0 if 'status_score' in self . scores : self . method = 'status' if self . scores [ 'status_score' ] < 2.0 : self . score = 0.0 else : tmp_score = min ( 100.0 , self . scores [ 'status_score' ] * 10 ) self . score = max ( 0.0 , tmp_score ) if self . scores . get ( 'flag' ) : self . is_spam = True self . source_flag = self . scores [ 'flag' ] if not self . is_spam and self . score >= 50 : self . is_spam = True if self . score < 0 : self . score = 0.0 if self . score > 100 : self . score = 100.0