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

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

  ViewVC Help
Powered by ViewVC 1.1.26