/[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 4 - (hide annotations)
Tue May 4 15:47:14 2004 UTC (20 years ago) by dpavlin
Original Path: trunk/mbox2index.pl
File MIME type: text/plain
File size: 1172 byte(s)
added CGI interface (slow), global configuration, templates

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 4 my $folder = $mws->{mgr}->open($mbox_path, extract => 'LAZY');
16     foreach my $message ($folder->messages) {
17 dpavlin 1
18 dpavlin 4 my $id = $message->messageId;
19     print "## $id\n";
20 dpavlin 1
21 dpavlin 4 my $document = {
22     id => $id,
23     folder => $mbox,
24     };
25    
26    
27    
28     foreach my $direction (qw(to from cc bcc)) {
29     foreach my $f ($message->$direction) {
30     print "$direction: ";
31     foreach my $part (qw(phrase address comment)) {
32     next if (! $f->$part);
33     print "[$part]",$f->$part," ";
34     $document->{$direction.'_'.$part} .= $f->$part."\n";
35     }
36     print "\n";
37     # push @{$document->$d.'_phrase'}, $f->phrase,
38     # push @{$document->$d.'_address'}, $f->address,
39     ## push @{$document->$d.'_comment'}, $f->comment,
40 dpavlin 1 }
41     }
42    
43 dpavlin 4 $document->{'subject'} = $message->get('Subject') || 'no subject';
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