X-Git-Url: https://piware.de/gitweb/?a=blobdiff_plain;f=vcard2gnokii;h=f3cef82ccf258d50f1a8d1b111b44c636278d083;hb=1a473459cc1097ae568d5dc32bce05e16d2a38bb;hp=9b40a87b0624c8d96f1ee77ff0186b8dc9a61973;hpb=c262576eb63fd1932151d677fbfb8da43cb81ede;p=bin.git diff --git a/vcard2gnokii b/vcard2gnokii index 9b40a87..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,30 +12,38 @@ def output_info(info): print >> sys.stderr, 'No suitable name for', info return - result += ';;ME;;5' + result += ';;ME;%i;5' % pos + + id = 0 for k, v in info.iteritems(): 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;9;%s' % (type, '\\n'.join([f for f in v.split(';') if f])) - if kf[0] == 'EMAIL': - result += ';8;%i;8;%s' % (type, v) - if kf[0] == 'TEL': - result += ';11;%i;11;%s' % (type, v) - if kf[0] == 'BDAY': - result += ';10;0;10;BDAY: ' + v + # 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': + result += ';11;%i;%i;%s' % (type, id, v) + elif kf[0] == 'BDAY': + result += (';10;0;%i;BDAY: ' %id) + v + else: + continue + + id += 1 print result +pos = 1 info = {} for line in open(sys.argv[1]): if not line or line[0] == ' ': @@ -53,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()