(self)
return proc
Do the spamassassin procesing.

        It creates a instance of :py:class:`~isbg.spamproc.SpamAssassin`
        every time that this method is called. The ``SpamAssasssin`` object
        would contact to the IMAP server to get the emails and to
        ``SpamAssassin`` command line to process them.
Do the spamassassin procesing.
Do the spamassassin procesing .
def do_spamassassin(self):
        """Do the spamassassin procesing.

        It creates a instance of :py:class:`~isbg.spamproc.SpamAssassin`
        every time that this method is called. The ``SpamAssasssin`` object
        would contact to the IMAP server to get the emails and to
        ``SpamAssassin`` command line to process them.

        """
        sa = spamproc.SpamAssassin.create_from_isbg(self)
        proc = None

        # SpamAssassin training: Learn spam
        s_learned = spamproc.Sa_Learn()
        if self.imapsets.learnspambox:
            uidvalidity = self.imap.get_uidvalidity(self.imapsets.learnspambox)
            origpastuids = self.pastuid_read(uidvalidity, 'spam')
            s_learned = sa.learn(self.imapsets.learnspambox, 'spam', None,
                                 origpastuids)
            self.pastuid_write(uidvalidity, s_learned.newpastuids,
                               s_learned.uids, 'spam')

        # SpamAssassin training: Learn ham
        h_learned = spamproc.Sa_Learn()
        if self.imapsets.learnhambox:
            uidvalidity = self.imap.get_uidvalidity(self.imapsets.learnhambox)
            origpastuids = self.pastuid_read(uidvalidity, 'ham')
            h_learned = sa.learn(self.imapsets.learnhambox, 'ham',
                                 self.movehamto, origpastuids)
            self.pastuid_write(uidvalidity, h_learned.newpastuids,
                               h_learned.uids, 'ham')

        if not self.teachonly:
            # check spaminbox exists by examining it
            self.imap.select(self.imapsets.spaminbox, 1)

            uidvalidity = self.imap.get_uidvalidity(self.imapsets.inbox)
            origpastuids = self.pastuid_read(uidvalidity)
            proc = sa.process_inbox(origpastuids)
            self.pastuid_write(uidvalidity, proc.newpastuids, proc.uids)

        if self.nostats is False:
            if self.imapsets.learnspambox is not None:
                self.logger.info(__(
                    "{}/{} spams learned".format(s_learned.learned,
                                                 s_learned.tolearn)))
            if self.imapsets.learnhambox:
                self.logger.info(__(
                    "{}/{} hams learned".format(h_learned.learned,
                                                h_learned.tolearn)))
            if not self.teachonly:
                self.logger.info(__(
                    "{} spams found in {} messages".format(proc.numspam,
                                                           proc.nummsg)))
                self.logger.info(__("{}/{} was automatically deleted".format(
                    proc.spamdeleted, proc.numspam)))

        return proc
def do_spamassassin ( self ) : sa = spamproc . SpamAssassin . create_from_isbg ( self ) proc = None # SpamAssassin training: Learn spam s_learned = spamproc . Sa_Learn ( ) if self . imapsets . learnspambox : uidvalidity = self . imap . get_uidvalidity ( self . imapsets . learnspambox ) origpastuids = self . pastuid_read ( uidvalidity , 'spam' ) s_learned = sa . learn ( self . imapsets . learnspambox , 'spam' , None , origpastuids ) self . pastuid_write ( uidvalidity , s_learned . newpastuids , s_learned . uids , 'spam' ) # SpamAssassin training: Learn ham h_learned = spamproc . Sa_Learn ( ) if self . imapsets . learnhambox : uidvalidity = self . imap . get_uidvalidity ( self . imapsets . learnhambox ) origpastuids = self . pastuid_read ( uidvalidity , 'ham' ) h_learned = sa . learn ( self . imapsets . learnhambox , 'ham' , self . movehamto , origpastuids ) self . pastuid_write ( uidvalidity , h_learned . newpastuids , h_learned . uids , 'ham' ) if not self . teachonly : # check spaminbox exists by examining it self . imap . select ( self . imapsets . spaminbox , 1 ) uidvalidity = self . imap . get_uidvalidity ( self . imapsets . inbox ) origpastuids = self . pastuid_read ( uidvalidity ) proc = sa . process_inbox ( origpastuids ) self . pastuid_write ( uidvalidity , proc . newpastuids , proc . uids ) if self . nostats is False : if self . imapsets . learnspambox is not None : self . logger . info ( __ ( "{}/{} spams learned" . format ( s_learned . learned , s_learned . tolearn ) ) ) if self . imapsets . learnhambox : self . logger . info ( __ ( "{}/{} hams learned" . format ( h_learned . learned , h_learned . tolearn ) ) ) if not self . teachonly : self . logger . info ( __ ( "{} spams found in {} messages" . format ( proc . numspam , proc . nummsg ) ) ) self . logger . info ( __ ( "{}/{} was automatically deleted" . format ( proc . spamdeleted , proc . numspam ) ) ) return proc