Ignore:
Timestamp:
04/24/07 10:28:14 (17 years ago)
Author:
bas
Message:

EmailToTracScript?
EmailtoTracScript?:

email2trac.py.in:

  • Fixed bugs in the text_wrap function and reformat it so we do not have to use python2.4
File:
1 edited

Legend:

Unmodified
Added
Removed
  • emailtotracscript/trunk/email2trac.py.in

    r153 r154  
    554554
    555555
    556         def wrap_text(str='', replace_whitespace = False):
     556        def wrap_text(self, text, replace_whitespace = False):
    557557                """
    558558                Will break a lines longer then given length into several small lines of size
     
    560560                """
    561561                import textwrap
     562
    562563                LINESEPARATOR = '\n'
    563564                reformat = ''
    564565
    565                 for s in str.split(LINESEPARATOR):
    566                         reformat = '%s%s' %(reformat, LINESEPARATOR.join(textwrap.fill(s,self.USE_TEXTWRAP)))
     566                for s in text.split(LINESEPARATOR):
     567                        tmp = textwrap.fill(s,self.USE_TEXTWRAP)
     568                        if tmp:
     569                                reformat = '%s\n%s' %(reformat,tmp)
     570                        else:
     571                                reformat = '%s\n' %reformat
    567572
    568573                return reformat
     574
     575                # Python2.4 and higher
     576                #
     577                #return LINESEPARATOR.join(textwrap.fill(s,width) for s in str.split(LINESEPARATOR))
     578                #
     579
    569580
    570581        def get_body_text(self, msg):
     
    589600                                if not body_text:                       
    590601                                        body_text = part.get_payload(decode=0)
    591                
     602       
    592603                                if self.STRIP_SIGNATURE:
    593604                                        body_text = self.strip_signature(body_text)
Note: See TracChangeset for help on using the changeset viewer.