/[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 213 by dpavlin, Mon Dec 5 17:47:23 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    my $total_rows = 0;
28    
29  while (my ($database, $db_config) = each %{ $config->{databases} }) {  while (my ($database, $db_config) = each %{ $config->{databases} }) {
30    
31          my $type = lc($db_config->{input}->{type});          my $type = lc($db_config->{input}->{type});
# Line 43  while (my ($database, $db_config) = each Line 45  while (my ($database, $db_config) = each
45          my $log = $lookup->_get_logger;          my $log = $lookup->_get_logger;
46          $log->info("working on $database in $db_path");          $log->info("working on $database in $db_path");
47    
         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  
         );  
   
48          my $path = './db/';          my $path = './db/';
49    
50          my $db = new WebPAC::Store(          my $db = new WebPAC::Store(
51                  path => $db_path,                  path => $db_path,
52          );          );
53    
         my $n = new WebPAC::Normalize::XML(  
         #       filter => { 'foo' => sub { shift } },  
                 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 } },  
         );  
   
54          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");
55          $est_config->{database} = $database;          $est_config->{database} = $database;
56    
57          $log->info("using HyperEstraier URL $est_config->{url}");          $log->info("using HyperEstraier URL $est_config->{masterurl}");
58    
59          my $est = new WebPAC::Output::Estraier(          my $est = new WebPAC::Output::Estraier(
60                  %{ $est_config },                  %{ $est_config },
61          );          );
62    
63          my $total_rows = 0;          #
64            # now, iterate through input formats
65            #
66    
67            my @inputs;
68            if (ref($db_config->{input}) eq 'ARRAY') {
69                    @inputs = @{ $db_config->{input} };
70            } else {
71                    push @inputs, $db_config->{input};
72            }
73    
74            foreach my $input (@inputs) {
75                    $log->info("working on input $input->{path} [$input->{type}]");
76    
77                    my $isis = new WebPAC::Input::ISIS(
78                            code_page => $config->{webpac}->{webpac_encoding},
79                            limit_mfn => $input->{limit},
80                    );
81    
82                    my $maxmfn = $isis->open(
83                            filename => $input->{path},
84                            code_page => $input->{encoding},        # database encoding
85                    );
86    
87          for ( 0 ... $isis->size ) {                  my $n = new WebPAC::Normalize::XML(
88                    #       filter => { 'foo' => sub { shift } },
89                            db => $db,
90                            lookup_regex => $lookup->regex,
91                            lookup => $lookup,
92                    );
93    
94                  my $row = $isis->fetch || next;                  $n->open(
95                            tag => $input->{normalize}->{tag},
96                            xml_file => $input->{normalize}->{path},
97                    );
98    
99                  my $mfn = $row->{'000'}->[0] || die "can't find MFN";                  for ( 0 ... $isis->size ) {
100    
101                  my $ds = $n->data_structure($row);                          my $row = $isis->fetch || next;
102    
103          #       print STDERR Dumper($row, $ds);                          my $mfn = $row->{'000'}->[0] || die "can't find MFN";
104    
105          #       my $html = $out->apply(                          my $ds = $n->data_structure($row);
         #               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;  
106    
107                  $est->add(                          $est->add(
108                          id => $mfn,                                  id => $input->{name} . "#" . $mfn,
109                          ds => $ds,                                  ds => $ds,
110                          type => $config->{hyperestraier}->{type},                                  type => $config->{hyperestraier}->{type},
111                  );                          );
112    
113                  $total_rows++;                          $total_rows++;
114                    }
115    
116          };          };
117    

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

  ViewVC Help
Powered by ViewVC 1.1.26