Changeset 294 for trunk/email2trac.py.in
- Timestamp:
- 01/06/10 13:18:48 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/email2trac.py.in
r292 r294 132 132 self.author = None 133 133 self.id = None 134 135 self.STRIP_CONTENT_TYPES = list() 134 136 135 137 self.VERSION = version … … 236 238 237 239 if parameters.has_key('binhex'): 238 self.BINHEX = parameters['binhex'] 239 else: 240 self.BINHEX = 'warn' 240 self.STRIP_CONTENT_TYPES.append('application/mac-binhex40') 241 241 242 242 if parameters.has_key('applesingle'): 243 self.APPLESINGLE = parameters['applesingle'] 244 else: 245 self.APPLESINGLE = 'warn' 243 self.STRIP_CONTENT_TYPES.append('application/applefile') 246 244 247 245 if parameters.has_key('appledouble'): 248 self.APPLEDOUBLE = parameters['appledouble'] 249 else: 250 self.APPLEDOUBLE = 'warn' 246 self.STRIP_CONTENT_TYPES.append('application/applefile') 247 248 if parameters.has_key('strip_content_types'): 249 items = parameters['strip_content_types'].split(',') 250 for item in items: 251 self.STRIP_CONTENT_TYPES.append(item.strip()) 251 252 252 253 self.WORKFLOW = None … … 1088 1089 """ 1089 1090 message_parts = [] 1090 1091 # This is used to figure out when we are inside an AppleDouble container 1092 # AppleDouble containers consists of two parts: Mac-specific file data, and platform-independent data 1093 # We strip away Mac-specific stuff 1094 appledouble_parts = [] 1095 1091 1096 1092 ALTERNATIVE_MULTIPART = False 1097 1093 … … 1101 1097 print 'TD: Message part: Content-Type: %s' % part.get_content_type() 1102 1098 1103 1104 # Check whether we just finished processing an AppleDouble container1105 if part not in appledouble_parts:1106 appledouble_parts = []1107 1108 1099 ## Check content type 1109 # 1110 if part.get_content_type() == 'application/mac-binhex40': 1111 # 1112 # Special handling for BinHex attachments. Options are drop (leave out with no warning), warn (and leave out), and keep 1113 # 1114 if self.BINHEX == 'warn': 1115 message_parts.append("'''A BinHex attachment named '%s' was ignored (use MIME encoding instead).'''" % part.get_filename()) 1116 continue 1117 elif self.BINHEX == 'drop': 1118 continue 1119 1120 elif part.get_content_type() == 'application/applefile': 1121 # 1122 # Special handling for the Mac-specific part of AppleDouble/AppleSingle attachments. Options are strip (leave out with no warning), warn (and leave out), and keep 1123 # 1124 1125 if part in appledouble_parts: 1126 if self.APPLEDOUBLE == 'warn': 1127 message_parts.append("'''The resource fork of an attachment named '%s' was removed.'''" % part.get_filename()) 1128 continue 1129 elif self.APPLEDOUBLE == 'strip': 1130 continue 1131 else: 1132 if self.APPLESINGLE == 'warn': 1133 message_parts.append("'''An AppleSingle attachment named '%s' was ignored (use MIME encoding instead).'''" % part.get_filename()) 1134 continue 1135 elif self.APPLESINGLE == 'drop': 1136 continue 1137 1138 elif part.get_content_type() == 'multipart/appledouble': 1139 # 1140 # If we entering an AppleDouble container, set up appledouble_parts so that we know what to do with its subparts 1141 # 1142 appledouble_parts = part.get_payload() 1100 # 1101 if part.get_content_type() in self.STRIP_CONTENT_TYPES: 1102 1103 if self.DEBUG: 1104 print "TD: A %s attachment named '%s' was skipped" %(part.get_content_type(), part.get_filename()) 1105 1143 1106 continue 1144 1107 1145 elif part.get_content_type() == 'multipart/alternative': 1108 ## Catch some mulitpart execptions 1109 # 1110 if part.get_content_type() == 'multipart/alternative': 1146 1111 ALTERNATIVE_MULTIPART = True 1147 1112 continue 1148 1113 1149 # Skip multipart containers1114 ## Skip multipart containers 1150 1115 # 1151 1116 if part.get_content_maintype() == 'multipart': … … 1154 1119 continue 1155 1120 1156 # Check if this is an inline part. It's inline if there is co Cont-Disp header, or if there is one and it says "inline" 1121 ## Check if this is an inline part. It's inline if there is co Cont-Disp header, or if there is one and it says "inline" 1122 # 1157 1123 inline = self.inline_part(part) 1158 1124 1159 # Drop HTML message 1125 ## Drop HTML message 1126 # 1160 1127 if ALTERNATIVE_MULTIPART and self.DROP_ALTERNATIVE_HTML_VERSION: 1161 1128 if part.get_content_type() == 'text/html': … … 1166 1133 continue 1167 1134 1168 # Inline text parts are where the body is 1135 ## Inline text parts are where the body is 1136 # 1169 1137 if part.get_content_type() == 'text/plain' and inline: 1170 1138 if self.DEBUG: … … 1192 1160 body_text = self.wrap_text(body_text) 1193 1161 1194 # Get contents charset (iso-8859-15 if not defined in mail headers)1162 ## Get contents charset (iso-8859-15 if not defined in mail headers) 1195 1163 # 1196 1164 charset = part.get_content_charset()
Note: See TracChangeset
for help on using the changeset viewer.