/[mws]/trunk/mbox2plucene.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/mbox2plucene.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (hide annotations)
Thu May 6 07:22:41 2004 UTC (20 years ago) by dpavlin
File MIME type: text/plain
File size: 1204 byte(s)
renamed script to fill index to incicate that it's intended to be used with
Plucene

1 dpavlin 1 #!/usr/bin/perl -w
2    
3 dpavlin 4 use MWS;
4 dpavlin 1 use Data::Dumper;
5    
6 dpavlin 4 my $mws = MWS->new('global.conf');
7 dpavlin 1
8 dpavlin 4 my $debug = 1;
9 dpavlin 1
10 dpavlin 4 foreach my $mbox ($mws->{config}->Parameters('folders')) {
11     my $mbox_path = $mws->{config}->val('folders', $mbox);
12 dpavlin 1
13 dpavlin 4 print STDERR "working on $mbox [$mbox_path]\n" if ($debug);
14 dpavlin 1
15 dpavlin 7 my $folder = $mws->open_folder($mbox);
16    
17 dpavlin 4 foreach my $message ($folder->messages) {
18 dpavlin 1
19 dpavlin 4 my $id = $message->messageId;
20     print "## $id\n";
21 dpavlin 1
22 dpavlin 4 my $document = {
23     id => $id,
24     folder => $mbox,
25     };
26    
27     foreach my $direction (qw(to from cc bcc)) {
28     foreach my $f ($message->$direction) {
29     print "$direction: ";
30     foreach my $part (qw(phrase address comment)) {
31     next if (! $f->$part);
32     print "[$part]",$f->$part," ";
33     $document->{$direction.'_'.$part} .= $f->$part."\n";
34     }
35     print "\n";
36     # push @{$document->$d.'_phrase'}, $f->phrase,
37     # push @{$document->$d.'_address'}, $f->address,
38     ## push @{$document->$d.'_comment'}, $f->comment,
39 dpavlin 1 }
40     }
41    
42 dpavlin 4 $document->{'subject'} = $message->get('Subject') || 'no subject';
43 dpavlin 7 $document->{'body'} = $mws->plain_text_body($message);
44 dpavlin 1
45 dpavlin 4 # print Dumper($document);
46     $mws->{index}->add("$mbox $id" => $document);
47 dpavlin 1
48 dpavlin 4 }
49    
50     $folder->close;
51 dpavlin 1 }
52    
53 dpavlin 4 $mws->{index}->optimize;

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26