Changeset 191 for trunk


Ignore:
Timestamp:
10/11/07 12:01:11 (17 years ago)
Author:
bas
Message:

email2trac.py.in, ChangeLog?, email2trac.conf:

  • Added strip_quotes function. Author: nicolasm at opera dot com
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r190 r191  
    88          disable the syslog functionality.
    99          Author     : michael.th add gmx dot net
    10          
     10
     11        * Added strip_quotes function, default settings:
     12                strip_quotes: <int> (default: 0)
     13                mail_quote: <quote chars> (default: "> ")
     14          Author     : nicolasm @ opera dot com
    1115
    12162007-07-18
  • trunk/email2trac.conf

    r181 r191  
    77mailto_link: 0
    88umask: 022
    9 email_comment: >
    109email_header: 0
    1110trac_version: 0.10
     
    1514verbatim_format: 1
    1615strip_signature: 0
     16email_quote: >
     17strip_quotes: 0
    1718
    1819
  • trunk/email2trac.py.in

    r190 r191  
    170170                        self.SPAM_LEVEL = 0
    171171
    172                 if parameters.has_key('email_comment'):
    173                         self.comment = str(parameters['email_comment'])
     172                if parameters.has_key('email_quote'):
     173                        self.EMAIL_QUOTE = str(parameters['email_quote'])
     174                else:   
     175                        self.EMAIL_QUOTE = '> '
    174176
    175177                if parameters.has_key('email_header'):
     
    207209                else:
    208210                        self.STRIP_SIGNATURE = 0
     211
     212                if parameters.has_key('strip_quotes'):
     213                        self.STRIP_QUOTES = int(parameters['strip_quotes'])
     214                else:
     215                        self.STRIP_QUOTES = 0
    209216
    210217                if parameters.has_key('use_textwrap'):
     
    223230                        self.TMPDIR = os.path.normcase(str(parameters['tmpdir']))
    224231
    225         # X-Spam-Score: *** (3.255) BAYES_50,DNS_FROM_AHBL_RHSBL,HTML_
    226         # Note if Spam_level then '*' are included
     232
    227233        def spam(self, message):
     234                """
     235                # X-Spam-Score: *** (3.255) BAYES_50,DNS_FROM_AHBL_RHSBL,HTML_
     236                # Note if Spam_level then '*' are included
     237                """
    228238                if message.has_key('X-Spam-Score'):
    229239                        spam_l = string.split(message['X-Spam-Score'])
     
    233243                                return 'Spam'
    234244
    235                 elif message.has_key('X-Virus-found'):                  # treat virus mails as spam
     245                # treat virus mails as spam
     246                #
     247                elif message.has_key('X-Virus-found'):                 
    236248                        return 'Spam'
    237249
    238250                return self.get_config('ticket', 'default_component')
     251
    239252
    240253        def blacklisted_from(self):
     
    695708                return ('\n'.join(body))
    696709
     710        def strip_quotes(self, text):
     711        """
     712        Strip quotes from message by Nicolas Mendoza
     713        """
     714        body = []
     715        for line in text.splitlines():
     716                if line.startswith(self.EMAIL_QUOTE):
     717                        continue
     718                body.append(line)
     719
     720        return ('\n'.join(body))
     721
    697722
    698723        def wrap_text(self, text, replace_whitespace = False):
    699724                """
    700                 Will break a lines longer then given length into several small lines of size
    701                 given length
     725                Will break a lines longer then given length into several small
     726                lines of size given length
    702727                """
    703728                import textwrap
     
    746771                                        body_text = self.strip_signature(body_text)
    747772
     773                                if self.STRIP_QUOTES:
     774                                        body_text = self.strip_quotes(body_text)
     775
    748776                                if self.USE_TEXTWRAP:
    749777                                        body_text = self.wrap_text(body_text)
     
    815843                except Exception, e:
    816844                        print 'TD: Failure sending notification on creation of ticket #%s: %s' %(tkt['id'], e)
    817 
    818         def mail_line(self, str):
    819                 return '%s %s' % (self.comment, str)
    820 
    821845
    822846        def html_mailto_link(self, subject, id, body):
Note: See TracChangeset for help on using the changeset viewer.