X-Git-Url: https://piware.de/gitweb/?a=blobdiff_plain;f=vcard2gnokii;h=f3cef82ccf258d50f1a8d1b111b44c636278d083;hb=73f39f614bd2ef7c96785b37b75c3e9a5ae15c21;hp=7928cb9ad760a766491f3eee2e29dd824af64095;hpb=e265327e113b1295960b07f7e4092c525ccfa806;p=bin.git diff --git a/vcard2gnokii b/vcard2gnokii index 7928cb9..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].startswith('TYPE=HOME'): + if 'TYPE=HOME' in k: type = 2 - elif kf[1].startswith('TYPE=CELL'): + elif 'TYPE=CELL' in k: type = 3 - elif kf[1].startswith('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()