/[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 268 by dpavlin, Fri Dec 16 21:09:42 2005 UTC revision 291 by dpavlin, Sun Dec 18 23:34:24 2005 UTC
# Line 9  use lib './lib'; Line 9  use lib './lib';
9    
10  use WebPAC::Common 0.02;  use WebPAC::Common 0.02;
11  use WebPAC::Lookup;  use WebPAC::Lookup;
12  use WebPAC::Input::ISIS;  use WebPAC::Input 0.03;
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;
# Line 74  while (my ($database, $db_config) = each Line 74  while (my ($database, $db_config) = each
74                  $log->info("database $database doesn't have inputs defined");                  $log->info("database $database doesn't have inputs defined");
75          }          }
76    
77            my @supported_inputs = keys %{ $config->{webpac}->{inputs} };
78    
79          foreach my $input (@inputs) {          foreach my $input (@inputs) {
80    
81                  my $type = lc($input->{type});                  my $type = lc($input->{type});
82    
83                  die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis');                  die "I know only how to handle input types ", join(",", @supported_inputs), " not '$type'!\n" unless (grep(/$type/, @supported_inputs));
84    
85                  my $lookup = new WebPAC::Lookup(                  my $lookup = new WebPAC::Lookup(
86                          lookup_file => $input->{lookup},                          lookup_file => $input->{lookup},
87                  );                  );
88    
89                  $log->info("working on input $input->{path} [$input->{type}]");                  my $input_module = $config->{webpac}->{inputs}->{$type};
90    
91                    $log->info("working on input $input->{path} [$input->{type}] using $input_module");
92    
93                  my $isis = new WebPAC::Input::ISIS(                  my $input_db = new WebPAC::Input(
94                            module => $input_module,
95                          code_page => $config->{webpac}->{webpac_encoding},                          code_page => $config->{webpac}->{webpac_encoding},
96                          limit_mfn => $input->{limit},                          limit => $input->{limit},
97                          lookup => $lookup,                          lookup => $lookup,
98                  );                  );
99                    $log->logdie("can't create input using $input_module") unless ($input);
100    
101                  my $maxmfn = $isis->open(                  my $maxmfn = $input_db->open(
102                          filename => $input->{path},                          path => $input->{path},
103                          code_page => $input->{encoding},        # database encoding                          code_page => $input->{encoding},        # database encoding
104                  );                  );
105    
# Line 105  while (my ($database, $db_config) = each Line 111  while (my ($database, $db_config) = each
111                          prefix => $input->{name},                          prefix => $input->{name},
112                  );                  );
113    
114                  $n->open(                  my $normalize_path = $input->{normalize}->{path};
115                          tag => $input->{normalize}->{tag},  
116                          xml_file => $input->{normalize}->{path},                  if ($normalize_path =~ m/\.xml$/i) {
117                  );                          $n->open(
118                                    tag => $input->{normalize}->{tag},
119                                    xml_file => $input->{normalize}->{path},
120                            );
121                    } elsif ($normalize_path =~ m/\.(?:yml|yaml)$/i) {
122                            $n->open_yaml(
123                                    path => $normalize_path,
124                                    tag => $input->{normalize}->{tag},
125                            );
126                    }
127    
128                    foreach my $pos ( 0 ... $input_db->size ) {
129    
130                  for ( 0 ... $isis->size ) {                          my $row = $input_db->fetch || next;
131    
132                          my $row = $isis->fetch || next;                          my $mfn = $row->{'000'}->[0];
133    
134                          my $mfn = $row->{'000'}->[0] || die "can't find MFN";                          if (! $mfn || $mfn !~ m#^\d+$#) {
135                                    $log->warn("record $pos doesn't have valid MFN but '$mfn', using $pos");
136                                    $mfn = $pos;
137                                    push @{ $row->{'000'} }, $pos;
138                            }
139    
140                          my $ds = $n->data_structure($row);                          my $ds = $n->data_structure($row);
141    
142                          $est->add(                          $est->add(
143                                  id => $input->{name} . "#" . $mfn,                                  id => $input->{name} . "/" . $mfn,
144                                  ds => $ds,                                  ds => $ds,
145                                  type => $config->{hyperestraier}->{type},                                  type => $config->{hyperestraier}->{type},
146                          );                          );

Legend:
Removed from v.268  
changed lines
  Added in v.291

  ViewVC Help
Powered by ViewVC 1.1.26