Changeset 309 for trunk/email2trac.py.in
- Timestamp:
- 02/02/10 16:39:19 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/email2trac.py.in
r305 r309 227 227 self.STRIP_QUOTES = 0 228 228 229 self.properties = dict() 230 if parameters.has_key('inline_properties'): 231 self.INLINE_PROPERTIES = int(parameters['inline_properties']) 232 else: 233 self.INLINE_PROPERTIES = 0 234 229 235 if parameters.has_key('use_textwrap'): 230 236 self.USE_TEXTWRAP = int(parameters['use_textwrap']) … … 529 535 530 536 def save_email_for_debug(self, message, tempfile=False): 537 531 538 if tempfile: 532 539 import tempfile … … 544 551 except OSError: 545 552 pass 553 554 message_parts = self.get_message_parts(message) 555 message_parts = self.unique_attachment_names(message_parts) 556 body_text = self.body_text(message_parts) 557 self.debug_body(body_text, True) 558 self.debug_attachments(message_parts) 546 559 547 560 def str_to_dict(self, s): … … 725 738 tkt['resolution'] = '' 726 739 727 # Must we update some ticket fields properties 740 # Must we update some ticket fields properties via subjectline 728 741 # 729 742 if update_fields: … … 733 746 message_parts = self.unique_attachment_names(message_parts) 734 747 748 # Must we update some ticket fields properties via body_text 749 # 750 if self.properties: 751 self.update_ticket_fields(tkt, self.properties) 752 735 753 if self.EMAIL_HEADER: 736 754 message_parts.insert(0, self.email_header_txt(m)) … … 738 756 body_text = self.body_text(message_parts) 739 757 740 if body_text.strip() or update_fields :758 if body_text.strip() or update_fields or self.properties: 741 759 if self.DRY_RUN: 742 760 print 'DRY_RUN: tkt.save_changes(self.author, body_text, ticket_change_number) ', self.author, cnum … … 845 863 head = self.email_header_txt(msg) 846 864 847 848 865 message_parts = self.get_message_parts(msg) 866 867 # Must we update some ticket fields properties via body_text 868 # 869 if self.properties: 870 self.update_ticket_fields(tkt, self.properties) 871 849 872 if self.DEBUG: 850 873 print 'TD: self.get_message_parts ', … … 947 970 blog.create_post(req, post, self.author, u'Created by email2trac', False) 948 971 972 def save_message_for_debug(self): 973 """ 974 Save the messages. So we can use it for debug purposes 975 """ 976 949 977 950 978 def parse(self, fp): … … 962 990 963 991 if self.DEBUG > 1: # save the entire e-mail message text 964 message_parts = self.get_message_parts(m)965 message_parts = self.unique_attachment_names(message_parts)966 992 self.save_email_for_debug(m, True) 967 body_text = self.body_text(message_parts)968 self.debug_body(body_text, True)969 self.debug_attachments(message_parts)970 993 971 994 self.db = self.env.get_db_cnx() … … 1030 1053 1031 1054 if result: 1032 if result.group('blog') and blog_enabled: 1033 self.blog(result.group('blog_id')) 1055 if result.group('blog'): 1056 if blog_enabled: 1057 self.blog(result.group('blog_id')) 1058 else: 1059 if self.DEBUG: 1060 print "Fullblog plugin is not installed" 1061 return 1034 1062 1035 1063 # update ticket + fields … … 1114 1142 return ('\n'.join(body)) 1115 1143 1144 def inline_properties(self, text): 1145 """ 1146 Parse text if we use inline keywords to set ticket fields 1147 """ 1148 if self.DEBUG: 1149 print 'TD: inline_properties function' 1150 1151 properties = dict() 1152 body = list() 1153 1154 INLINE_EXP = re.compile('\s*[@]\s*([a-zA-Z]+)\s*:(.*)$') 1155 1156 for line in text.splitlines(): 1157 match = INLINE_EXP.match(line) 1158 if match: 1159 print match.groups() 1160 keyword, value = match.groups() 1161 self.properties[keyword] = value.strip() 1162 else: 1163 body.append(line) 1164 1165 return '\n'.join(body) 1166 1167 1116 1168 def wrap_text(self, text, replace_whitespace = False): 1117 1169 """ … … 1144 1196 body parts are returned as strings, attachments are returned as tuples of (filename, Message object) 1145 1197 """ 1146 message_parts = []1198 message_parts = list() 1147 1199 1148 1200 ALTERNATIVE_MULTIPART = False … … 1212 1264 if self.STRIP_QUOTES: 1213 1265 body_text = self.strip_quotes(body_text) 1266 1267 if self.INLINE_PROPERTIES: 1268 body_text = self.inline_properties(body_text) 1214 1269 1215 1270 if self.USE_TEXTWRAP:
Note: See TracChangeset
for help on using the changeset viewer.