added tools directory and scripts
authorPaul Mangan <paul@claws-mail.org>
Sat, 23 Jun 2001 10:44:14 +0000 (10:44 +0000)
committerPaul Mangan <paul@claws-mail.org>
Sat, 23 Jun 2001 10:44:14 +0000 (10:44 +0000)
AUTHORS
ChangeLog.claws
tools/README [new file with mode: 0644]
tools/filter_conv.pl [new file with mode: 0644]
tools/ldif-to-xml.py [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
index 84cc590..84be0f7 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -6,6 +6,7 @@ main-branch (http://sylpheed.good-day.net)
 claws-branch (http://sylpheed-claws.sourceforge.net)
 
        Hoa viet Dinh           <dinh@enseirb.fr>
+        Christoph Hohmann       <reboot@gmx.ch>
        Alfons Hoogervorst      <alfons@proteus.demon.nl>
        Darko Koruga            <darko.koruga@hermes.si>
        Paul Mangan             <claws@thewildbeast.co.uk>
@@ -63,3 +64,4 @@ contributors (beside the above; based on Changelog)
        shigeri
        Tajiri
        Wakai
+        Rodrigo Dias Arruda Senra
index 84f5293..99a1806 100644 (file)
@@ -1,3 +1,14 @@
+2001-06-22 [paul]
+
+        Added tools directory and files.
+
+        * tools/filter_conv.pl
+                converts old filter system to new filtering system
+        * tools/ldif-to-xml.py
+                converts netscape addressbook to sylpheed addressbook
+        * tools/README
+                descriptions/instructions for above two files
+
 2001-06-23 [christoph]
 
        * src/inc.c
diff --git a/tools/README b/tools/README
new file mode 100644 (file)
index 0000000..795a29f
--- /dev/null
@@ -0,0 +1,30 @@
+
+* filter_conv.pl
+
+  WHAT IT DOES
+
+  This perl script provides easy conversion of your filtering rules
+  form sylpheed's old filter system to the new filtering system used
+  in sylpheed-claws. It reads 'filterrc' and outputs 'filteringrc'.
+
+  HOW TO USE IT
+
+  Move 'filter_conv.pl' to the ~/.sylpheed directory.
+  From the ~/.sylpheed directory, issue the command:
+
+        perl filter_conv.pl
+
+  That's it, the new filtering system is now implemented with your
+  previous rules applied.
+
+-----------------------------------------------------------------------
+
+* ldif-to-xml.py
+
+  WHAT IT DOES
+
+  This python script converts the netscape ldif format address book to
+  the sylpheed xml format.
+
+
+
diff --git a/tools/filter_conv.pl b/tools/filter_conv.pl
new file mode 100644 (file)
index 0000000..fa3e6c8
--- /dev/null
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+
+#  * Copyright 2001 Paul Mangan <claws@thewildbeast.co.uk>
+#  *
+#  * This file is free software; you can redistribute it and/or modify it
+#  * under the terms of the GNU General Public License as published by
+#  * the Free Software Foundation; either version 2 of the License, or
+#  * (at your option) any later version.
+#  *
+#  * This program is distributed in the hope that it will be useful, but
+#  * WITHOUT ANY WARRANTY; without even the implied warranty of
+#  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  * General Public License for more details.
+#  *
+#  * You should have received a copy of the GNU General Public License
+#  * along with this program; if not, write to the Free Software
+#  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#  *
+
+
+$INPUT = open (FILTERRC, "<filterrc");
+@input_file = <FILTERRC>;
+$WRITE_THIS = "";
+close FILTERRC;
+
+foreach $input_file (@input_file) {
+@split_lines = split("\t", $input_file);
+if (($split_lines[3]) && ($split_lines[0] eq "To")) {
+$WRITE_THIS .= "to_or_cc match \"$split_lines[1]\"";
+} elsif ($split_lines[0] eq "To") {
+$WRITE_THIS .= "to match \"$split_lines[1]\"";
+} elsif ($split_lines[0] eq "Reply-To") {
+$WRITE_THIS .= "inreplyto match \"$split_lines[1]\"";
+} elsif ($split_lines[0] eq "Subject") {
+$WRITE_THIS .= "subject match \"$split_lines[1]\"";
+} elsif (($split_lines[0] eq "From") || ($split_lines[0] eq "Sender")){
+$WRITE_THIS .= "from match \"$split_lines[1]\"";
+}
+if (!$split_lines[5]) {
+$WRITE_THIS .= " delete";
+} elsif ($split_lines[8] == "m"){
+$WRITE_THIS .= " move \"\#mh/Mailbox/$split_lines[5]\"";
+}
+$WRITE_THIS .= "\n";
+
+@split_lines = "";
+}
+
+open (FILTERINGRC, ">filteringrc");
+
+print FILTERINGRC $WRITE_THIS;
+close FILTERINGRC;
+
+exit;
+
diff --git a/tools/ldif-to-xml.py b/tools/ldif-to-xml.py
new file mode 100644 (file)
index 0000000..bfafdfe
--- /dev/null
@@ -0,0 +1,102 @@
+#!/usr/bin/env python
+
+#  * Copyright 2001 Rod Senra <Rodrigo.Senra@ic.unicamp.br>
+#  *
+#  * This file is free software; you can redistribute it and/or modify it
+#  * under the terms of the GNU General Public License as published by
+#  * the Free Software Foundation; either version 2 of the License, or
+#  * (at your option) any later version.
+#  *
+#  * This program is distributed in the hope that it will be useful, but
+#  * WITHOUT ANY WARRANTY; without even the implied warranty of
+#  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  * General Public License for more details.
+#  *
+#  * You should have received a copy of the GNU General Public License
+#  * along with this program; if not, write to the Free Software
+#  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#  *
+
+import re
+import sys
+
+header = """<?xml version="1.0" encoding="ISO-8859-1"?>
+<addressbook>
+
+<common_address>
+"""
+
+footer = """
+</common_address>
+
+<personal_address>
+</personal_address>
+
+</addressbook>
+"""
+
+def printGroupRec(fd,name,members):
+    """ Print XML group record from r-tuple"""
+    fd.write("    <group name=\"%s\">\n"%(name))
+    for each in members:
+        printRec(fd,each,"        ")
+    fd.write("    </group>\n")
+
+def printRec(fd,r,ident):
+    """ Print XML group record from r-tuple"""
+    fd.write("%s<item>\n"%(ident) )
+    fd.write("%s    <name>%s</name>\n"%(ident,r[0]))
+    fd.write("%s    <address>%s</address>\n"%(ident,r[1]))
+    fd.write("%s    <remarks>%s</remarks>\n"%(ident,r[2]))
+    fd.write("%s</item>\n"%(ident))
+    
+outfd = open('addressbook.xml','w')
+
+
+outfd.write(header)
+try:
+    rec = {}
+    for line in  open(sys.argv[1]).readlines():
+        line = line[:-1].strip() # clean string
+        if line=='':
+            try:
+                if rec.has_key('description'):
+                    str = rec['description']
+                elif rec.has_key('xmozillanickname'):
+                    str = rec['xmozillanickname']
+                elif rec.has_key('sn'):
+                    str = rec['sn']
+                else:
+                    str = ''
+                try:
+                    if rec.has_key('member'):
+                        printGroupRec(outfd,rec['cn'].strip(),rec['member'])
+                    elif rec.has_key('mail'):
+                        printRec(outfd,(rec['cn'].strip(),rec['mail'].strip(),str.strip()),"    ")
+
+                except KeyError:
+                    pass
+            finally:
+                del rec
+                rec = {}
+            continue
+
+        try: # parse line
+            key,value = line.split(':')
+        except:
+            continue
+        if key=='member':
+            name,addr = value.split(',')
+            name = name.split('=')[1].strip()
+            addr = addr.split('=')[1].strip()
+            value = (name,addr,'')
+            if rec.has_key('member'):
+                rec['member'].append(value)
+            else :
+                rec['member'] = [value]
+        else:
+            rec[key]=value
+    
+finally:
+    outfd.write(footer)
+    outfd.close()