add eudora-2-vCard convertor
authorPaul Mangan <paul@claws-mail.org>
Sun, 30 Sep 2001 10:54:42 +0000 (10:54 +0000)
committerPaul Mangan <paul@claws-mail.org>
Sun, 30 Sep 2001 10:54:42 +0000 (10:54 +0000)
AUTHORS
tools/Makefile.am
tools/README
tools/eud2gc.py [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
index b8a597d..97d61e7 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -82,3 +82,4 @@ contributors (beside the above; based on Changelog)
        Eric Limpens
        Paul Evans
        wwp
+       Jeroen Versteeg
index a01c278..6252346 100644 (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
 
index b7c93b7..22e4b49 100644 (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
 
   Any problems, contact Rod Senra <rodrigo.senra@ic.unicamp.br>
 
 -----------------------------------------------------------------------
+
+
diff --git a/tools/eud2gc.py b/tools/eud2gc.py
new file mode 100644 (file)
index 0000000..3e5927b
--- /dev/null
@@ -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])