/[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 251 by dpavlin, Thu Dec 15 14:12:00 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');  my $total_rows = 0;
28    
29    while (my ($database, $db_config) = each %{ $config->{databases} }) {
30    
31  my $abs_path = abs_path($0);          my $abs_path = abs_path($0);
32  $abs_path =~ s#/[^/]*$#/#;          $abs_path =~ s#/[^/]*$#/#;
33    
34  my $lookup = new WebPAC::Lookup(          my $db_path = $config->{webpac}->{db_path} . '/' . $database;
         lookup_file => $config->{input}->{lookup},  
 );  
35    
36            my $db = new WebPAC::Store(
37                    path => $db_path,
38                    database => $database,
39                    debug => 1,
40            );
41    
42            my $log = $db->_get_logger;
43            $log->info("working on $database in $db_path");
44    
45  my $isis = new WebPAC::Input::ISIS(          my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration");
46          code_page => $config->{webpac}->{webpac_encoding},          $est_config->{database} = $database;
         limit_mfn => $config->{input}->{limit},  
 );  
47    
48  my $maxmfn = $isis->open(          $log->info("using HyperEstraier URL $est_config->{masterurl}");
         filename => $config->{input}->{path},  
         code_page => $config->{input}->{encoding},      # database encoding  
 );  
49    
50  my $path = './db/';          my $est = new WebPAC::Output::Estraier(
51                    %{ $est_config },
52            );
53    
54  my $db = new WebPAC::Store(          #
55          path => $config->{webpac}->{db_path},          # now, iterate through input formats
56  );          #
57    
58  my $n = new WebPAC::Normalize::XML(          my @inputs;
59  #       filter => { 'foo' => sub { shift } },          if (ref($db_config->{input}) eq 'ARRAY') {
60          db => $db,                  @inputs = @{ $db_config->{input} };
61          lookup_regex => $lookup->regex,          } else {
62          lookup => $lookup,                  push @inputs, $db_config->{input};
63  );          }
64    
65  $n->open(          foreach my $input (@inputs) {
         tag => $config->{normalize}->{tag},  
         xml_file => $config->{normalize}->{path},  
 );  
66    
67  my $out = new WebPAC::Output::TT(                  my $type = lc($input->{type});
         include_path => $config->{webpac}->{template_path},  
         filters => { foo => sub { shift } },  
 );  
68    
69  my $est = new WebPAC::Output::Estraier(                  die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis');
         %{ $config->{hyperestraier} }  
 );  
70    
71  my $total_rows = 0;                  my $lookup = new WebPAC::Lookup(
72                            lookup_file => $input->{lookup},
73                    );
74    
75  for ( 0 ... $isis->size ) {                  $log->info("working on input $input->{path} [$input->{type}]");
76    
77          my $row = $isis->fetch || next;                  my $isis = new WebPAC::Input::ISIS(
78                            code_page => $config->{webpac}->{webpac_encoding},
79                            limit_mfn => $input->{limit},
80                            lookup => $lookup,
81                    );
82    
83          my $mfn = $row->{'000'}->[0] || die "can't find MFN";                  my $maxmfn = $isis->open(
84                            filename => $input->{path},
85                            code_page => $input->{encoding},        # database encoding
86                    );
87    
88          my $ds = $n->data_structure($row);  $log->info( Dumper($lookup->{_lookup_data}) );
89    
90  #       print STDERR Dumper($row, $ds);                  my $n = new WebPAC::Normalize::XML(
91                    #       filter => { 'foo' => sub { shift } },
92  #       my $html = $out->apply(                          db => $db,
93  #               template => 'html_ffzg.tt',                          lookup_regex => $lookup->regex,
94  #               data => $ds,                          lookup => $lookup,
95  #       );                          prefix => $input->{name},
96  #                  );
97  #       # create test output  
98  #                  $n->open(
99  #       my $file = sprintf('out/%02d.html', $mfn );                          tag => $input->{normalize}->{tag},
100  #       open(my $fh, '>', $file) or die "can't open $file: $!";                          xml_file => $input->{normalize}->{path},
101  #       print $fh $html;                  );
102  #       close($fh);  
103  #                  for ( 0 ... $isis->size ) {
104  #       $html =~ s#\s*[\n\r]+\s*##gs;  
105  #                          my $row = $isis->fetch || next;
106  #       print STDERR $html;  
107                            my $mfn = $row->{'000'}->[0] || die "can't find MFN";
108          $est->add(  
109                  id => $mfn,                          my $ds = $n->data_structure($row);
110                  ds => $ds,  
111                  type => $config->{hyperestraier}->{type},                          $est->add(
112          );                                  id => $input->{name} . "#" . $mfn,
113                                    ds => $ds,
114                                    type => $config->{hyperestraier}->{type},
115                            );
116    
117          $total_rows++;                          $total_rows++;
118                    }
119    
120  };          };
121    
122  my $log = $lookup->_get_logger;          $log->info("$total_rows records indexed");
123    }
124    
 $log->info("$total_rows records indexed");  

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

  ViewVC Help
Powered by ViewVC 1.1.26