/[webpac2]/trunk/run.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

Diff of /trunk/run.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 209 by dpavlin, Mon Dec 5 17:46:57 2005 UTC revision 210 by dpavlin, Mon Dec 5 17:47:04 2005 UTC
# Line 12  use WebPAC::Input::ISIS; Line 12  use WebPAC::Input::ISIS;
12  use WebPAC::Store 0.03;  use WebPAC::Store 0.03;
13  use WebPAC::Normalize::XML;  use WebPAC::Normalize::XML;
14  use WebPAC::Output::TT;  use WebPAC::Output::TT;
15  use WebPAC::Output::Estraier;  use WebPAC::Output::Estraier 0.02;
16  use YAML qw/LoadFile/;  use YAML qw/LoadFile/;
17    use LWP::Simple;
18    
19  my $limit = shift @ARGV;  my $limit = shift @ARGV;
20    
# Line 21  my $config = LoadFile('conf/config.yml') Line 22  my $config = LoadFile('conf/config.yml')
22    
23  print "config = ",Dumper($config);  print "config = ",Dumper($config);
24    
25  my $type = lc($config->{input}->{type});  die "no databases in config file!\n" unless ($config->{databases});
26    
27  die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis');  while (my ($database, $db_config) = each %{ $config->{databases} }) {
28    
29  my $abs_path = abs_path($0);          my $type = lc($db_config->{input}->{type});
 $abs_path =~ s#/[^/]*$#/#;  
30    
31  my $lookup = new WebPAC::Lookup(          die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis');
         lookup_file => $config->{input}->{lookup},  
 );  
32    
33            my $abs_path = abs_path($0);
34            $abs_path =~ s#/[^/]*$#/#;
35    
36            my $lookup = new WebPAC::Lookup(
37                    lookup_file => $db_config->{input}->{lookup},
38            );
39    
40  my $isis = new WebPAC::Input::ISIS(          my $db_path = $config->{webpac}->{db_path} . '/' . $database;
         code_page => $config->{webpac}->{webpac_encoding},  
         limit_mfn => $config->{input}->{limit},  
 );  
41    
 my $maxmfn = $isis->open(  
         filename => $config->{input}->{path},  
         code_page => $config->{input}->{encoding},      # database encoding  
 );  
42    
43  my $path = './db/';          my $log = $lookup->_get_logger;
44            $log->info("working on $database in $db_path");
45    
46  my $db = new WebPAC::Store(          my $isis = new WebPAC::Input::ISIS(
47          path => $config->{webpac}->{db_path},                  code_page => $config->{webpac}->{webpac_encoding},
48  );                  limit_mfn => $db_config->{input}->{limit},
49            );
50    
51  my $n = new WebPAC::Normalize::XML(          my $maxmfn = $isis->open(
52  #       filter => { 'foo' => sub { shift } },                  filename => $db_config->{input}->{path},
53          db => $db,                  code_page => $db_config->{input}->{encoding},   # database encoding
54          lookup_regex => $lookup->regex,          );
         lookup => $lookup,  
 );  
55    
56  $n->open(          my $path = './db/';
         tag => $config->{normalize}->{tag},  
         xml_file => $config->{normalize}->{path},  
 );  
57    
58  my $out = new WebPAC::Output::TT(          my $db = new WebPAC::Store(
59          include_path => $config->{webpac}->{template_path},                  path => $db_path,
60          filters => { foo => sub { shift } },          );
 );  
61    
62  my $est = new WebPAC::Output::Estraier(          my $n = new WebPAC::Normalize::XML(
63          %{ $config->{hyperestraier} }          #       filter => { 'foo' => sub { shift } },
64  );                  db => $db,
65                    lookup_regex => $lookup->regex,
66                    lookup => $lookup,
67            );
68    
69  my $total_rows = 0;          $n->open(
70                    tag => $db_config->{normalize}->{tag},
71                    xml_file => $db_config->{normalize}->{path},
72            );
73    
74  for ( 0 ... $isis->size ) {          my $out = new WebPAC::Output::TT(
75                    include_path => $config->{webpac}->{template_path},
76                    filters => { foo => sub { shift } },
77            );
78    
79          my $row = $isis->fetch || next;          my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration");
80            $est_config->{database} = $database;
81    
82          my $mfn = $row->{'000'}->[0] || die "can't find MFN";          $log->info("using HyperEstraier URL $est_config->{url}");
83    
84          my $ds = $n->data_structure($row);          my $est = new WebPAC::Output::Estraier(
85                    %{ $est_config },
86            );
87    
88  #       print STDERR Dumper($row, $ds);          my $total_rows = 0;
89    
90  #       my $html = $out->apply(          for ( 0 ... $isis->size ) {
 #               template => 'html_ffzg.tt',  
 #               data => $ds,  
 #       );  
 #  
 #       # create test output  
 #  
 #       my $file = sprintf('out/%02d.html', $mfn );  
 #       open(my $fh, '>', $file) or die "can't open $file: $!";  
 #       print $fh $html;  
 #       close($fh);  
 #  
 #       $html =~ s#\s*[\n\r]+\s*##gs;  
 #  
 #       print STDERR $html;  
91    
92          $est->add(                  my $row = $isis->fetch || next;
93                  id => $mfn,  
94                  ds => $ds,                  my $mfn = $row->{'000'}->[0] || die "can't find MFN";
95                  type => $config->{hyperestraier}->{type},  
96          );                  my $ds = $n->data_structure($row);
97    
98            #       print STDERR Dumper($row, $ds);
99    
100            #       my $html = $out->apply(
101            #               template => 'html_ffzg.tt',
102            #               data => $ds,
103            #       );
104            #
105            #       # create test output
106            #
107            #       my $file = sprintf('out/%02d.html', $mfn );
108            #       open(my $fh, '>', $file) or die "can't open $file: $!";
109            #       print $fh $html;
110            #       close($fh);
111            #
112            #       $html =~ s#\s*[\n\r]+\s*##gs;
113            #
114            #       print STDERR $html;
115    
116                    $est->add(
117                            id => $mfn,
118                            ds => $ds,
119                            type => $config->{hyperestraier}->{type},
120                    );
121    
122          $total_rows++;                  $total_rows++;
123    
124  };          };
125    
126  my $log = $lookup->_get_logger;          $log->info("$total_rows records indexed");
127    }
128    
 $log->info("$total_rows records indexed");  

Legend:
Removed from v.209  
changed lines
  Added in v.210

  ViewVC Help
Powered by ViewVC 1.1.26