Changeset 164


Ignore:
Timestamp:
07/05/07 13:33:24 (17 years ago)
Author:
bas
Message:

email2trac.py.in:

  • Starting implementing to update ticket fields with mail, ticket #7
  • Added the regex expressions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/email2trac.py.in

    r163 r164  
    378378                        pass
    379379
     380        def keywords_to_dict(self, str)
     381                """
     382                Transfrom a str of the form [<key>=<value>]+ to dict[<key>] = <value>
     383                """
     384                # Skip the last ':' character
     385                #
     386                fields = string.split(str[:-1], ',')
     387
     388                result = dict()
     389                for field in fields:
     390                        try:
     391                                index, value = string.split(field,'=')
     392                                if value:
     393                                        result[index] = value
     394                        except ValueError:
     395                                pass
     396
     397                return results
     398                               
    380399        def ticket_update(self, m):
    381400                """
     
    391410                TICKET_RE = re.compile(r"""
    392411                                        (?P<ticketnr>[#][0-9]+:)
     412                                        |(?P<ticketnr_fields>[#][\d]+\?.*:)
    393413                                        """, re.VERBOSE)
    394414
     
    399419                body_text = self.get_body_text(m)
    400420
     421                # Must we update ticket fields
     422                #
     423                if result.group('ticketnr_keywords'):
     424                        nr, keywords = string.split(result.group('ticketnr_fields'), '?')
     425                        tkt_fields = self.keywords_to_dict(keywords)
     426                else:
     427                        nr = result.group('ticketnr')
     428
    401429                # Strip '#' and ':' from ticket_id
    402430                #
    403                 ticket_id = result.group('ticketnr')
    404                 ticket_id = int(ticket_id[1:-1])
     431                ticket_id = int(nr[1:-1])
    405432
    406433                # Get current time
Note: See TracChangeset for help on using the changeset viewer.