From: Paul Mangan Date: Sat, 23 Jun 2001 10:44:14 +0000 (+0000) Subject: added tools directory and scripts X-Git-Tag: VERSION_0_5_0~60 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=eec0c04f790ab101fe4e54eb7f13bd04401da549 added tools directory and scripts --- diff --git a/AUTHORS b/AUTHORS index 84cc5908a..84be0f75b 100644 --- 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 + Christoph Hohmann Alfons Hoogervorst Darko Koruga Paul Mangan @@ -63,3 +64,4 @@ contributors (beside the above; based on Changelog) shigeri Tajiri Wakai + Rodrigo Dias Arruda Senra diff --git a/ChangeLog.claws b/ChangeLog.claws index 84f5293df..99a18067d 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -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 index 000000000..795a29f9c --- /dev/null +++ b/tools/README @@ -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 index 000000000..fa3e6c8a3 --- /dev/null +++ b/tools/filter_conv.pl @@ -0,0 +1,55 @@ +#!/usr/bin/perl + +# * Copyright 2001 Paul Mangan +# * +# * 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, "; +$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 index 000000000..bfafdfe16 --- /dev/null +++ b/tools/ldif-to-xml.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python + +# * Copyright 2001 Rod Senra +# * +# * 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 = """ + + + +""" + +footer = """ + + + + + + +""" + +def printGroupRec(fd,name,members): + """ Print XML group record from r-tuple""" + fd.write(" \n"%(name)) + for each in members: + printRec(fd,each," ") + fd.write(" \n") + +def printRec(fd,r,ident): + """ Print XML group record from r-tuple""" + fd.write("%s\n"%(ident) ) + fd.write("%s %s\n"%(ident,r[0])) + fd.write("%s
%s
\n"%(ident,r[1])) + fd.write("%s %s\n"%(ident,r[2])) + fd.write("%s
\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()