6 def lReadEfile(sFileName
):
8 sLines
= open(sFileName
).read()
10 print ('Error opening %s' %sFileName
)
12 lLines
= sLines
.split('\n')
16 def dElines2Dict(lElines
):
18 for sEntry
in lElines
:
20 lChunks
= sEntry
.split('"')
22 lChunks
= sEntry
.split(' ')
23 if lChunks
[0] != 'alias':
24 print ('ignoring invalid line: %s' %sEntry
)
26 sAdresses
= lChunks
[2:].join(',')
27 print ('Entry added: %s %s' %(lChunks
[1],sEntry
))
28 dAliases
[lChunks
[1]]=sAdresses
32 def vWriteGfile(dAliases
, sFileName
):
34 oFile
= open(sFileName
, 'w')
36 print ('Error opening %s' %sFileName
)
38 for sKey
in dAliases
.keys():
39 #print ('BEGIN:VCARD')
40 #print ('N:;%s' %sKey)
42 #print ('ADR;HOME:;;;;;;')
44 #print ('EMAIL;INTERNET:%s' %dAliases[sKey])
46 oFile
.write ('BEGIN:VCARD\n')
47 oFile
.write ('FN:%s\n' %sKey
)
48 oFile
.write ('N:;%s\n' %sKey
)
49 oFile
.write ('BDAY:\n')
50 oFile
.write ('ADR;HOME:;;;;;;;\n')
51 oFile
.write ('TEL:;\n')
52 oFile
.write ('EMAIL;INTERNET:%s\n' %dAliases
[sKey
])
53 oFile
.write ('END:VCARD\n')
58 if __name__
== '__main__':
59 if len(sys
.argv
) >= 3:
60 sEfileName
= sys
.argv
[1]
61 sGfileName
= sys
.argv
[2]
62 lAliases
= lReadEfile(sEfileName
)
63 dAliases
= dElines2Dict(lAliases
)
64 if vWriteGfile(dAliases
, sGfileName
) == 1:
67 print ('Error saving output-file')
69 print ('Usage:\n %s <Eudora addressbook> <Gnomecard file>' %sys
.argv
[0])