/[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 251 by dpavlin, Thu Dec 15 14:12:00 2005 UTC revision 269 by dpavlin, Fri Dec 16 21:09:48 2005 UTC
# Line 7  use File::Temp qw/tempdir/; Line 7  use File::Temp qw/tempdir/;
7  use Data::Dumper;  use Data::Dumper;
8  use lib './lib';  use lib './lib';
9    
10    use WebPAC::Common 0.02;
11  use WebPAC::Lookup;  use WebPAC::Lookup;
12  use WebPAC::Input::ISIS;  use WebPAC::Input::ISIS;
13  use WebPAC::Store 0.03;  use WebPAC::Store 0.03;
14  use WebPAC::Normalize::XML;  use WebPAC::Normalize::XML;
15  use WebPAC::Output::TT;  use WebPAC::Output::TT;
16  use WebPAC::Output::Estraier 0.02;  use WebPAC::Output::Estraier 0.05;
17  use YAML qw/LoadFile/;  use YAML qw/LoadFile/;
18  use LWP::Simple;  use LWP::Simple;
19    
# Line 28  my $total_rows = 0; Line 29  my $total_rows = 0;
29    
30  while (my ($database, $db_config) = each %{ $config->{databases} }) {  while (my ($database, $db_config) = each %{ $config->{databases} }) {
31    
32            my $log = _new WebPAC::Common()->_get_logger();
33    
34            #
35            # open Hyper Estraier database
36            #
37    
38            my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration");
39            $est_config->{database} = $database;
40    
41            $log->info("using HyperEstraier URL $est_config->{masterurl}");
42    
43            my $est = new WebPAC::Output::Estraier(
44                    %{ $est_config },
45            );
46    
47            #
48            # now WebPAC::Store
49            #
50          my $abs_path = abs_path($0);          my $abs_path = abs_path($0);
51          $abs_path =~ s#/[^/]*$#/#;          $abs_path =~ s#/[^/]*$#/#;
52    
53          my $db_path = $config->{webpac}->{db_path} . '/' . $database;          my $db_path = $config->{webpac}->{db_path} . '/' . $database;
54    
55            $log->info("working on $database in $db_path");
56    
57          my $db = new WebPAC::Store(          my $db = new WebPAC::Store(
58                  path => $db_path,                  path => $db_path,
59                  database => $database,                  database => $database,
60                  debug => 1,                  debug => 1,
61          );          );
62    
         my $log = $db->_get_logger;  
         $log->info("working on $database in $db_path");  
   
         my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration");  
         $est_config->{database} = $database;  
   
         $log->info("using HyperEstraier URL $est_config->{masterurl}");  
   
         my $est = new WebPAC::Output::Estraier(  
                 %{ $est_config },  
         );  
63    
64          #          #
65          # now, iterate through input formats          # now, iterate through input formats
# Line 58  while (my ($database, $db_config) = each Line 68  while (my ($database, $db_config) = each
68          my @inputs;          my @inputs;
69          if (ref($db_config->{input}) eq 'ARRAY') {          if (ref($db_config->{input}) eq 'ARRAY') {
70                  @inputs = @{ $db_config->{input} };                  @inputs = @{ $db_config->{input} };
71          } else {          } elsif ($db_config->{input}) {
72                  push @inputs, $db_config->{input};                  push @inputs, $db_config->{input};
73            } else {
74                    $log->info("database $database doesn't have inputs defined");
75          }          }
76    
77          foreach my $input (@inputs) {          foreach my $input (@inputs) {
# Line 85  while (my ($database, $db_config) = each Line 97  while (my ($database, $db_config) = each
97                          code_page => $input->{encoding},        # database encoding                          code_page => $input->{encoding},        # database encoding
98                  );                  );
99    
 $log->info( Dumper($lookup->{_lookup_data}) );  
   
100                  my $n = new WebPAC::Normalize::XML(                  my $n = new WebPAC::Normalize::XML(
101                  #       filter => { 'foo' => sub { shift } },                  #       filter => { 'foo' => sub { shift } },
102                          db => $db,                          db => $db,
# Line 95  $log->info( Dumper($lookup->{_lookup_dat Line 105  $log->info( Dumper($lookup->{_lookup_dat
105                          prefix => $input->{name},                          prefix => $input->{name},
106                  );                  );
107    
108                  $n->open(                  my $normalize_path = $input->{normalize}->{path};
109                          tag => $input->{normalize}->{tag},  
110                          xml_file => $input->{normalize}->{path},                  if ($normalize_path =~ m/\.xml$/i) {
111                  );                          $n->open(
112                                    tag => $input->{normalize}->{tag},
113                                    xml_file => $input->{normalize}->{path},
114                            );
115                    } elsif ($normalize_path =~ m/\.(?:yml|yaml)$/i) {
116                            $n->open_yaml(
117                                    path => $normalize_path,
118                                    tag => $input->{normalize}->{tag},
119                            );
120                    }
121    
122                  for ( 0 ... $isis->size ) {                  for ( 0 ... $isis->size ) {
123    
# Line 120  $log->info( Dumper($lookup->{_lookup_dat Line 139  $log->info( Dumper($lookup->{_lookup_dat
139          };          };
140    
141          $log->info("$total_rows records indexed");          $log->info("$total_rows records indexed");
142    
143            #
144            # add Hyper Estraier links to other databases
145            #
146            if (ref($db_config->{links}) eq 'ARRAY') {
147                    foreach my $link (@{ $db_config->{links} }) {
148                            $log->info("adding link $database -> $link->{to} [$link->{credit}]");
149                            $est->add_link(
150                                    from => $database,
151                                    to => $link->{to},
152                                    credit => $link->{credit},
153                            );
154                    }
155            }
156    
157  }  }
158    

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

  ViewVC Help
Powered by ViewVC 1.1.26