Index: trunk/email2trac.py.in
===================================================================
--- trunk/email2trac.py.in	(revision 551)
+++ trunk/email2trac.py.in	(revision 553)
@@ -350,5 +350,5 @@
 
         ## Only use name or email adress
-        #ticket['reporter'] = self.email_from
+        #
         ticket['reporter'] = self.author
 
@@ -372,5 +372,5 @@
             #   to_list.append(e)
                 
-            # Always Remove reporter email address from cc-list 
+            ## Always Remove reporter email address from cc-list 
             #
             try:
@@ -383,6 +383,4 @@
                 ## Prevent mail loop
                 #
-                #if addr in to_list:
-
                 if addr == self.trac_smtp_from:
                     self.logger.debug("Skipping %s mail address for CC-field" %(addr))
@@ -419,5 +417,4 @@
 
         message_body = message_body.encode('utf-8')
-        #message_body = unicode(message_body, 'iso-8859-15')
 
         fx.write(message_body)
@@ -435,5 +432,7 @@
         n = 0
         for item in message_parts:
-            # Skip inline text parts
+
+            ## Skip inline text parts
+            #
             if not isinstance(item, tuple):
                 continue
@@ -461,4 +460,5 @@
                 continue
 
+            # trac error with long filenames support
             #part_file = util.text.unicode_quote(part_file)
             #part_file = repr(part_file)
@@ -488,5 +488,4 @@
             fx = os.fdopen(fd, 'wb')
         else:
-            #msg_file = '/var/tmp/msg.txt' 
             msg_file = os.path.join(self.parameters.tmpdir, 'msg.%s.email2trac' %project_name)
             fx = open(msg_file, 'wb')
@@ -546,5 +545,4 @@
                 s = '%s' %temp
 
-        #s = s.encode('utf-8')
         return s
 
@@ -696,7 +694,6 @@
 
         except KeyError: 
-            ## 
-            # fallback for compability (Will be deprecated)
-            # workflow can be none.
+            ## fallback for compability (Will be deprecated)
+            #  workflow can be none.
             #
             workflow = None
@@ -870,8 +867,5 @@
 
             else:
-                ## Only set if we have a value
-                #
-                #if value:
-                #   ticket[field] = value
+
                 ticket[field] = value
 
@@ -937,5 +931,4 @@
         ## How many changes has this ticket
         #
-        # cnum = len(tkt.get_changelog())
         grouped = TicketModule(self.env).grouped_changelog_entries(tkt, self.db)
         cnum = sum(1 for e in grouped) + 1
@@ -1125,5 +1118,5 @@
                         return (found_id, orig_subject)
                    
-                    # obesolete !??
+                    # obsolete !?? 12 Aug 2011
                     #subject = orig_subject
 
@@ -1241,5 +1234,4 @@
             else:
                 tkt.save_changes(tkt['reporter'], comment)
-                #print tkt.get_changelog(self.db, when)
 
         if not spam:
@@ -1301,6 +1293,5 @@
             fd = open(path, 'rb')
             if self.system == 'discussion':
-                att = attachment.Attachment(self.env, 'discussion', 'topic/%s'
-                  % (self.id,))
+                att = attachment.Attachment(self.env, 'discussion', 'topic/%s' % (self.id,))
             else:
                 s = 'Attach %s to ticket %d' %(filename, self.id)
@@ -1315,11 +1306,11 @@
                 att.description = self.email_to_unicode('Added by email2trac')
 
-            ## Pseudo code to determine max filename lenght
-            # os.pathconf('/', os.pathconf_name['PC_NAME_MAX'])
-
             try:
+
                 self.logger.debug('Insert atachment')
                 att.insert(filename, fd, file_size)
+
             except OSError, detail:
+
                 self.logger.info('%s\nFilename %s could not be saved, problem: %s' %(status, filename, detail))
                 status = '%s\nFilename %s could not be saved, problem: %s' %(status, filename, detail)
@@ -1735,9 +1726,13 @@
 
         else:
+
             self.system = 'ticket'
             (matched_id, subject) = self.ticket_update_by_subject(subject)
+
             if matched_id:
+
                 if not self.ticket_update(m, matched_id, spam_msg):
                     self.new_ticket(m, subject, spam_msg)
+
             else:
                 ## No update by subject, so just create a new ticket
@@ -1932,4 +1927,5 @@
             #
             if ALTERNATIVE_MULTIPART and self.parameters.drop_alternative_html_version:
+
                 if content_type == 'text/html':
                     self.logger.debug('\t Skipping alternative HTML message')
@@ -2065,5 +2061,4 @@
             ## Discard relative paths for windows/unix in attachment names
             #
-            #filename = filename.replace('\\', '/').replace(':', '/') 
             filename = filename.replace('\\', '_')
             filename = filename.replace('/', '_') 
@@ -2111,5 +2106,5 @@
         self.print_unicode(s)
 
-        ## We have no valid ticket id
+        ## Do we have a valid ticket id
         #
         if not self.id:
@@ -2118,11 +2113,15 @@
         try:
             if self.system == 'discussion':
-                att = attachment.Attachment(self.env, 'discussion', 'ticket/%s'
-                  % (self.id,), filename)
+
+                att = attachment.Attachment(self.env, 'discussion', 'ticket/%s' % (self.id,), filename)
+
             else:
-                att = attachment.Attachment(self.env, 'ticket', self.id,
-                  filename)
+
+                att = attachment.Attachment(self.env, 'ticket', self.id, filename)
+
             return True
+
         except attachment.ResourceNotFound:
+
             return False
 
@@ -2156,14 +2155,20 @@
             
             if part.get_content_maintype() == 'image' and inline:
+
                 if self.system != 'discussion':
                     s = 'wiki image link for: %s' %(filename)
                     self.print_unicode(s)
                     body_text.append('[[Image(%s)]]' % filename)
+
                 body_text.append("")
+
             else:
+
                 if self.system != 'discussion':
+
                     s = 'wiki attachment link for: %s' %(filename)
                     self.print_unicode(s)
                     body_text.append('[attachment:"%s"]' % filename)
+
                 body_text.append("")
 
