Changeset 2318

Show
Ignore:
Timestamp:
07/12/07 08:07:53 (1 year ago)
Author:
abaumann
Message:

tweaks to XML parsing/generation to avoid conflicts:

  • generate name nodes in LastName?, FirstName? order to match vformat converters
  • process both Location and Type attributes of Telephone nodes for
    determining contact type, and do so case-insensitively
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/moto-sync/motosync.py

    r2255 r2318  
    105105# reverse of the above (almost): mapping from vcard to phone's contact type 
    106106VCARD_CONTACT_TYPES = { 
    107     'Work':     0, 
    108     'Home':     1, 
    109     'Voice':    2, 
    110     'Cellular': 3, 
    111     'Car':      3, 
    112     'Message':  5, 
    113     'Fax':      4, 
    114     'Pager':    5, 
     107    'work':     0, 
     108    'home':     1, 
     109    'voice':    2, 
     110    'cellular': 3, 
     111    'car':      3, 
     112    'message':  5, 
     113    'fax':      4, 
     114    'pager':    5, 
    115115} 
    116116 
     
    118118# can also have dom/intl/postal/parcel... these don't really make sense here 
    119119VCARD_ADDRESS_TYPES = { 
    120     'Work':  0, 
    121     'Home':  1, 
     120    'work':  0, 
     121    'home':  1, 
    122122} 
    123123 
     
    17131713            last = self.name[self.firstlast_index:].strip() 
    17141714            if self.firstlast_enabled: 
     1715                appendXMLTag(doc, e, 'LastName', first) 
    17151716                appendXMLTag(doc, e, 'FirstName', last) 
    1716                 appendXMLTag(doc, e, 'LastName', first) 
    17171717            else: 
     1718                appendXMLTag(doc, e, 'LastName', last) 
    17181719                appendXMLTag(doc, e, 'FirstName', first) 
    1719                 appendXMLTag(doc, e, 'LastName', last) 
    17201720        top.appendChild(e) 
    17211721 
     
    18211821                # filter out any illegal characters from the phone number 
    18221822                content = filter(lambda c: c in TEL_NUM_DIGITS, content) 
    1823                 ical_types = elt.getAttribute('Type').split(';') 
     1823                ical_types = elt.getAttribute('Location').split(';') 
     1824                ical_types.extend(elt.getAttribute('Type').split(';')) 
    18241825                is_pref = elt.hasAttribute('Preferred') and elt.getAttribute('Preferred') in ['1', 'true'] 
    18251826                moto_type = MOTO_CONTACT_DEFAULT 
    18261827                for t in ical_types: 
     1828                    t = t.lower() 
    18271829                    if VCARD_CONTACT_TYPES.has_key(t): 
    18281830                        moto_type = VCARD_CONTACT_TYPES[t] 
     
    18541856            ical_types = adr.getAttribute('Location').split(';') 
    18551857            for t in ical_types: 
     1858                t = t.lower() 
    18561859                if VCARD_ADDRESS_TYPES.has_key(t): 
    18571860                    moto_type = VCARD_ADDRESS_TYPES[t] 
     
    19641967        else: 
    19651968            e = doc.createElement('Telephone') 
    1966             if MOTO_PHONE_CONTACT_TYPES.has_key(self.contacttype): 
     1969            if MOTO_PHONE_CONTACT_LOCATIONS.has_key(self.contacttype): 
     1970                e.setAttribute('Location', MOTO_PHONE_CONTACT_LOCATIONS[self.contacttype]) 
     1971            elif MOTO_PHONE_CONTACT_TYPES.has_key(self.contacttype): 
    19671972                e.setAttribute('Type', MOTO_PHONE_CONTACT_TYPES[self.contacttype]) 
    1968             elif MOTO_PHONE_CONTACT_LOCATIONS.has_key(self.contacttype): 
    1969                 e.setAttribute('Location', MOTO_PHONE_CONTACT_LOCATIONS[self.contacttype]) 
    19701973            if self.primaryflag: 
    19711974                e.setAttribute('Preferred', 'true')