Ignore:
Timestamp:
11/27/06 16:29:32 (17 years ago)
Author:
bas
Message:

EmailtoTracScript?:

email2trac.py.in,email2trac.conf:

  • Added strip_signature option, inspired by Mailman software
Location:
emailtotracscript/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • emailtotracscript/trunk/ChangeLog

    r135 r136  
    33       
    44          - Added verbatim_format option default is: 1
     5          - Added strip_signature option default is: 0
    56
    672006-10-27
  • emailtotracscript/trunk/email2trac.conf

    r134 r136  
    1414drop_spam : 0
    1515verbatim_format: 1
     16strip_signatures: 1
    1617
    1718
  • emailtotracscript/trunk/email2trac.py.in

    r134 r136  
    8181import time
    8282import email
     83import email.Iterators
     84import email.Header
    8385import re
    8486import urllib
    8587import unicodedata
    8688import ConfigParser
    87 from email import Header
    8889from stat import *
    8990import mimetypes
     
    176177                        self.VERBATIM_FORMAT = 1
    177178
     179                if parameters.has_key('strip_signature'):
     180                        self.STRIP_SIGNATURE = int(parameters['strip_signature'])
     181                else:
     182                        self.STRIP_SIGNATURE = 0
     183
    178184
    179185        # X-Spam-Score: *** (3.255) BAYES_50,DNS_FROM_AHBL_RHSBL,HTML_
     
    198204                understands it.
    199205                """
    200                 results =  Header.decode_header(str)
     206                results =  email.Header.decode_header(str)
    201207                str = None
    202208                for text,format in results:
     
    506512                self.new_ticket(m)
    507513
     514        def strip_signature(self, text):
     515                """
     516                Strip signature from message, inspired by Mailman software
     517                """
     518                body = []
     519                for line in text.splitlines():
     520                        if line == '-- ':
     521                                break
     522                        body.append(line)
     523
     524                return ('\n'.join(body))
     525
    508526        def get_body_text(self, msg):
    509527                """
     
    527545                                if not body_text:                       
    528546                                        body_text = part.get_payload(decode=0)
     547               
     548                                if self.STRIP_SIGNATURE:
     549                                        body_text = self.strip_signature(body_text)
    529550
    530551                                # Get contents charset (iso-8859-15 if not defined in mail headers)
Note: See TracChangeset for help on using the changeset viewer.