add eudora-2-vCard convertor

This commit is contained in:
Paul Mangan 2001-09-30 10:54:42 +00:00
parent 63559b17bc
commit 2300da497d
4 changed files with 95 additions and 1 deletions

View file

@ -82,3 +82,4 @@ contributors (beside the above; based on Changelog)
Eric Limpens
Paul Evans
wwp
Jeroen Versteeg

View file

@ -1,2 +1,2 @@
EXTRA_DIST= README filter_conv.pl gif2xface.pl ldif-to-xml.py
EXTRA_DIST= README eud2gc.py filter_conv.pl gif2xface.pl ldif-to-xml.py

View file

@ -1,3 +1,25 @@
* eud2gc.py
WHAT IT DOES
This python-script is a quick hack to convert an Eudora (v.3?) addressbook
to vCard (GnomeCard) format.
HOW TO USE IT
You may do whatever you want with it! (Also regarding copying)
However, the script is intended to use like this:
eud2gc.py <Eudora-addressbook-file> <Gnomecard-file>
Be carefull not to overwrite your original GnomeCard.gcrd!
(But of course you might want to add the converted stuff to it)
Copyleft some time long ago (around 1999?) by Jeroen Versteeg
(j.m.versteeg@student.utwente.nl)
-----------------------------------------------------------------------
* filter_conv.pl
@ -83,3 +105,5 @@
Any problems, contact Rod Senra <rodrigo.senra@ic.unicamp.br>
-----------------------------------------------------------------------

69
tools/eud2gc.py Normal file
View file

@ -0,0 +1,69 @@
#!/usr/bin/python
import string, sys
def lReadEfile(sFileName):
try:
sLines = open(sFileName).read()
except:
print ('Error opening %s' %sFileName)
lLines = []
lLines = string.splitfields(sLines, '\n')
return lLines
def dElines2Dict(lElines):
dAliases = {}
for sEntry in lElines:
if '"' in sEntry:
lChunks = string.splitfields(sEntry, '"')
else:
lChunks = string.splitfields(sEntry, ' ')
if lChunks[0] <> 'alias':
print ('ignoring invalid line: %s' %sEntry)
else:
sAdresses = string.joinfields(lChunks[2:], ',')
print ('Entry added: %s %s' %(lChunks[1],sEntry))
dAliases[lChunks[1]]=sAdresses
return dAliases
def vWriteGfile(dAliases, sFileName):
try:
oFile = open(sFileName, 'w')
except:
print ('Error opening %s' %sFileName)
return 0
for sKey in dAliases.keys():
#print ('BEGIN:VCARD')
#print ('N:;%s' %sKey)
#print ('BDAY:')
#print ('ADR;HOME:;;;;;;')
#print ('TEL:;')
#print ('EMAIL;INTERNET:%s' %dAliases[sKey])
#print ('END:VCARD')
oFile.write ('BEGIN:VCARD\n')
oFile.write ('FN:%s\n' %sKey)
oFile.write ('N:;%s\n' %sKey)
oFile.write ('BDAY:\n')
oFile.write ('ADR;HOME:;;;;;;;\n')
oFile.write ('TEL:;\n')
oFile.write ('EMAIL;INTERNET:%s\n' %dAliases[sKey])
oFile.write ('END:VCARD\n')
oFile.close()
return 1
if __name__ == '__main__':
if len(sys.argv) >= 3:
sEfileName = sys.argv[1]
sGfileName = sys.argv[2]
lAliases = lReadEfile(sEfileName)
dAliases = dElines2Dict(lAliases)
if vWriteGfile(dAliases, sGfileName) == 1:
print ('Done!')
else:
print ('Error saving output-file')
else:
print ('Usage:\n %s <Eudora addressbook> <Gnomecard file>' %sys.argv[0])