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

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

  ViewVC Help
Powered by ViewVC 1.1.26