Changeset 553 for trunk/email2trac.py.in


Ignore:
Timestamp:
08/12/11 12:38:06 (13 years ago)
Author:
bas
Message:

removed some obsolete code and some layout changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/email2trac.py.in

    r551 r553  
    350350
    351351        ## Only use name or email adress
    352         #ticket['reporter'] = self.email_from
     352        #
    353353        ticket['reporter'] = self.author
    354354
     
    372372            #   to_list.append(e)
    373373               
    374             # Always Remove reporter email address from cc-list
     374            ## Always Remove reporter email address from cc-list
    375375            #
    376376            try:
     
    383383                ## Prevent mail loop
    384384                #
    385                 #if addr in to_list:
    386 
    387385                if addr == self.trac_smtp_from:
    388386                    self.logger.debug("Skipping %s mail address for CC-field" %(addr))
     
    419417
    420418        message_body = message_body.encode('utf-8')
    421         #message_body = unicode(message_body, 'iso-8859-15')
    422419
    423420        fx.write(message_body)
     
    435432        n = 0
    436433        for item in message_parts:
    437             # Skip inline text parts
     434
     435            ## Skip inline text parts
     436            #
    438437            if not isinstance(item, tuple):
    439438                continue
     
    461460                continue
    462461
     462            # trac error with long filenames support
    463463            #part_file = util.text.unicode_quote(part_file)
    464464            #part_file = repr(part_file)
     
    488488            fx = os.fdopen(fd, 'wb')
    489489        else:
    490             #msg_file = '/var/tmp/msg.txt'
    491490            msg_file = os.path.join(self.parameters.tmpdir, 'msg.%s.email2trac' %project_name)
    492491            fx = open(msg_file, 'wb')
     
    546545                s = '%s' %temp
    547546
    548         #s = s.encode('utf-8')
    549547        return s
    550548
     
    696694
    697695        except KeyError:
    698             ##
    699             # fallback for compability (Will be deprecated)
    700             # workflow can be none.
     696            ## fallback for compability (Will be deprecated)
     697            #  workflow can be none.
    701698            #
    702699            workflow = None
     
    870867
    871868            else:
    872                 ## Only set if we have a value
    873                 #
    874                 #if value:
    875                 #   ticket[field] = value
     869
    876870                ticket[field] = value
    877871
     
    937931        ## How many changes has this ticket
    938932        #
    939         # cnum = len(tkt.get_changelog())
    940933        grouped = TicketModule(self.env).grouped_changelog_entries(tkt, self.db)
    941934        cnum = sum(1 for e in grouped) + 1
     
    11251118                        return (found_id, orig_subject)
    11261119                   
    1127                     # obesolete !??
     1120                    # obsolete !?? 12 Aug 2011
    11281121                    #subject = orig_subject
    11291122
     
    12411234            else:
    12421235                tkt.save_changes(tkt['reporter'], comment)
    1243                 #print tkt.get_changelog(self.db, when)
    12441236
    12451237        if not spam:
     
    13011293            fd = open(path, 'rb')
    13021294            if self.system == 'discussion':
    1303                 att = attachment.Attachment(self.env, 'discussion', 'topic/%s'
    1304                   % (self.id,))
     1295                att = attachment.Attachment(self.env, 'discussion', 'topic/%s' % (self.id,))
    13051296            else:
    13061297                s = 'Attach %s to ticket %d' %(filename, self.id)
     
    13151306                att.description = self.email_to_unicode('Added by email2trac')
    13161307
    1317             ## Pseudo code to determine max filename lenght
    1318             # os.pathconf('/', os.pathconf_name['PC_NAME_MAX'])
    1319 
    13201308            try:
     1309
    13211310                self.logger.debug('Insert atachment')
    13221311                att.insert(filename, fd, file_size)
     1312
    13231313            except OSError, detail:
     1314
    13241315                self.logger.info('%s\nFilename %s could not be saved, problem: %s' %(status, filename, detail))
    13251316                status = '%s\nFilename %s could not be saved, problem: %s' %(status, filename, detail)
     
    17351726
    17361727        else:
     1728
    17371729            self.system = 'ticket'
    17381730            (matched_id, subject) = self.ticket_update_by_subject(subject)
     1731
    17391732            if matched_id:
     1733
    17401734                if not self.ticket_update(m, matched_id, spam_msg):
    17411735                    self.new_ticket(m, subject, spam_msg)
     1736
    17421737            else:
    17431738                ## No update by subject, so just create a new ticket
     
    19321927            #
    19331928            if ALTERNATIVE_MULTIPART and self.parameters.drop_alternative_html_version:
     1929
    19341930                if content_type == 'text/html':
    19351931                    self.logger.debug('\t Skipping alternative HTML message')
     
    20652061            ## Discard relative paths for windows/unix in attachment names
    20662062            #
    2067             #filename = filename.replace('\\', '/').replace(':', '/')
    20682063            filename = filename.replace('\\', '_')
    20692064            filename = filename.replace('/', '_')
     
    21112106        self.print_unicode(s)
    21122107
    2113         ## We have no valid ticket id
     2108        ## Do we have a valid ticket id
    21142109        #
    21152110        if not self.id:
     
    21182113        try:
    21192114            if self.system == 'discussion':
    2120                 att = attachment.Attachment(self.env, 'discussion', 'ticket/%s'
    2121                   % (self.id,), filename)
     2115
     2116                att = attachment.Attachment(self.env, 'discussion', 'ticket/%s' % (self.id,), filename)
     2117
    21222118            else:
    2123                 att = attachment.Attachment(self.env, 'ticket', self.id,
    2124                   filename)
     2119
     2120                att = attachment.Attachment(self.env, 'ticket', self.id, filename)
     2121
    21252122            return True
     2123
    21262124        except attachment.ResourceNotFound:
     2125
    21272126            return False
    21282127
     
    21562155           
    21572156            if part.get_content_maintype() == 'image' and inline:
     2157
    21582158                if self.system != 'discussion':
    21592159                    s = 'wiki image link for: %s' %(filename)
    21602160                    self.print_unicode(s)
    21612161                    body_text.append('[[Image(%s)]]' % filename)
     2162
    21622163                body_text.append("")
     2164
    21632165            else:
     2166
    21642167                if self.system != 'discussion':
     2168
    21652169                    s = 'wiki attachment link for: %s' %(filename)
    21662170                    self.print_unicode(s)
    21672171                    body_text.append('[attachment:"%s"]' % filename)
     2172
    21682173                body_text.append("")
    21692174
Note: See TracChangeset for help on using the changeset viewer.