Changeset 153
- Timestamp:
- 04/24/07 08:51:51 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
emailtotracscript/trunk/email2trac.py.in
r152 r153 554 554 555 555 556 def wrap_text(str='', width = self.USE_TEXTWRAP,replace_whitespace = False):556 def wrap_text(str='', replace_whitespace = False): 557 557 """ 558 558 Will break a lines longer then given length into several small lines of size … … 561 561 import textwrap 562 562 LINESEPARATOR = '\n' 563 return LINESEPARATOR.join(textwrap.fill(s,width) for s in str.split(LINESEPARATOR)) 563 reformat = '' 564 565 for s in str.split(LINESEPARATOR): 566 reformat = '%s%s' %(reformat, LINESEPARATOR.join(textwrap.fill(s,self.USE_TEXTWRAP))) 567 568 return reformat 564 569 565 570 def get_body_text(self, msg): … … 697 702 # 698 703 max_size = int(self.get_config('attachment', 'max_size')) 699 message= ''704 status = '' 700 705 701 706 for part in message.walk(): … … 752 757 fd.close() 753 758 754 # get the file size759 # get the file_size 755 760 # 756 761 stats = os.lstat(path) 757 file size = stats[stat.ST_SIZE]762 file_size = stats[stat.ST_SIZE] 758 763 759 764 # Check if the attachment size is allowed 760 765 # 761 if file_size > max_size:762 message = '%s\n%sFile %s is larger then allowed attachment size (%d > %d)'763 %( message, filename, file_size, max_size)766 if (max_size != -1) and (file_size > max_size): 767 status = '%s\nFile %s is larger then allowed attachment size (%d > %d)\n\n' \ 768 %(status, filename, file_size, max_size) 764 769 765 770 os.unlink(path) … … 774 779 try: 775 780 cursor.execute('INSERT INTO attachment VALUES("%s","%s","%s",%d,%d,"%s","%s","%s")' 776 %('ticket', urllib.quote(str(ticket['id'])), filename + '?format=raw', file size,781 %('ticket', urllib.quote(str(ticket['id'])), filename + '?format=raw', file_size, 777 782 int(time.time()),'', self.author, 'e-mail') ) 778 783 … … 796 801 att.description = self.email_to_unicode('Added by email2trac') 797 802 798 att.insert(url_filename, fd, file size)803 att.insert(url_filename, fd, file_size) 799 804 800 805 #except util.TracError, detail: … … 809 814 # Return how many attachments 810 815 # 811 message = 'This message has %d attachment(s)\n%s' %(count, message)812 return message816 status = 'This message has %d attachment(s)\n%s' %(count, status) 817 return status 813 818 814 819
Note: See TracChangeset
for help on using the changeset viewer.