X-Git-Url: https://piware.de/gitweb/?a=blobdiff_plain;f=vcard2gnokii;h=f3cef82ccf258d50f1a8d1b111b44c636278d083;hb=e42af4898dd9694c9af39002b7655f686fa459a5;hp=e585488f82b3aac9d65a36b163e23b228233a2d7;hpb=c6d59c5e4ea9ae44664ace79ecdb5ab8873baf30;p=bin.git diff --git a/vcard2gnokii b/vcard2gnokii index e585488..f3cef82 100755 --- a/vcard2gnokii +++ b/vcard2gnokii @@ -2,7 +2,7 @@ import sys -def output_info(info): +def output_info(info, pos): if info.has_key('X-EVOLUTION-FILE-AS'): result = info['X-EVOLUTION-FILE-AS'] elif info.has_key('N'): @@ -12,7 +12,7 @@ def output_info(info): print >> sys.stderr, 'No suitable name for', info return - result += ';;ME;;5' + result += ';;ME;%i;5' % pos id = 0 @@ -20,15 +20,16 @@ def output_info(info): kf = k.split(';') type = 0 if len(kf) > 1: - if kf[1] == 'TYPE=HOME': + if 'TYPE=HOME' in k: type = 2 - elif kf[1] == 'TYPE=CELL': + elif 'TYPE=CELL' in k: type = 3 - elif kf[1] == 'TYPE=WORK': + elif 'TYPE=WORK' in k: type = 6 if kf[0] == 'ADR': - result += ';9;%i;%i;%s' % (type, id, '\\n'.join([f for f in v.split(';') if f])) + # current gnokii does not swallow type "9" (postal address) + result += ';10;0;%i;%s' % (id, '\\n'.join([f for f in v.split(';') if f])) elif kf[0] == 'EMAIL': result += ';8;%i;%i;%s' % (type, id, v) elif kf[0] == 'TEL': @@ -42,6 +43,7 @@ def output_info(info): print result +pos = 1 info = {} for line in open(sys.argv[1]): if not line or line[0] == ' ': @@ -59,6 +61,7 @@ for line in open(sys.argv[1]): if key == 'BEGIN': info = {} elif key == 'END': - output_info(info) + output_info(info, pos) + pos += 1 if value: info[key] = value.strip()