--- trunk/mbox2index.pl 2004/05/04 14:00:03 3 +++ trunk/mbox2index.pl 2004/05/04 15:47:14 4 @@ -1,47 +1,53 @@ #!/usr/bin/perl -w -use Mail::Box::Manager; -use Plucene::Simple; +use MWS; use Data::Dumper; -my $mbox="test"; -my $index = Plucene::Simple->open( "index" ) || die "can't open index: $!"; +my $mws = MWS->new('global.conf'); -my $mgr = Mail::Box::Manager->new; -my $folder = $mgr->open($mbox, extract => 'LAZY'); -foreach my $message ($folder->messages) { - - my $id = $message->messageId; - print "## $id\n"; - - my $document = { - id => $id, - folder => $mbox, - }; +my $debug = 1; +foreach my $mbox ($mws->{config}->Parameters('folders')) { + my $mbox_path = $mws->{config}->val('folders', $mbox); + print STDERR "working on $mbox [$mbox_path]\n" if ($debug); - foreach my $direction (qw(to from cc bcc)) { - foreach my $f ($message->$direction) { - print "$direction: "; - foreach my $part (qw(phrase address comment)) { - next if (! $f->$part); - print "[$part]",$f->$part," "; - $document->{$direction.'_'.$part} .= $f->$part."\n"; + my $folder = $mws->{mgr}->open($mbox_path, extract => 'LAZY'); + foreach my $message ($folder->messages) { + + my $id = $message->messageId; + print "## $id\n"; + + my $document = { + id => $id, + folder => $mbox, + }; + + + + foreach my $direction (qw(to from cc bcc)) { + foreach my $f ($message->$direction) { + print "$direction: "; + foreach my $part (qw(phrase address comment)) { + next if (! $f->$part); + print "[$part]",$f->$part," "; + $document->{$direction.'_'.$part} .= $f->$part."\n"; + } + print "\n"; + # push @{$document->$d.'_phrase'}, $f->phrase, + # push @{$document->$d.'_address'}, $f->address, + ## push @{$document->$d.'_comment'}, $f->comment, } - print "\n"; -# push @{$document->$d.'_phrase'}, $f->phrase, -# push @{$document->$d.'_address'}, $f->address, -## push @{$document->$d.'_comment'}, $f->comment, } - } - $document->{'subject'} = $message->get('Subject') || 'no subject'; + $document->{'subject'} = $message->get('Subject') || 'no subject'; - print Dumper($document); - $index->add("$mbox $id" => $document); +# print Dumper($document); + $mws->{index}->add("$mbox $id" => $document); + + } + $folder->close; } -$folder->close; -$index->optimize; +$mws->{index}->optimize;