/[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 535 by dpavlin, Mon May 22 19:34:45 2006 UTC revision 536 by dpavlin, Mon Jun 26 16:39:51 2006 UTC
# Line 11  use WebPAC::Common 0.02; Line 11  use WebPAC::Common 0.02;
11  use WebPAC::Lookup;  use WebPAC::Lookup;
12  use WebPAC::Input 0.03;  use WebPAC::Input 0.03;
13  use WebPAC::Store 0.03;  use WebPAC::Store 0.03;
14  use WebPAC::Normalize::XML;  use WebPAC::Normalize;
 use WebPAC::Normalize::Set;  
15  use WebPAC::Output::TT;  use WebPAC::Output::TT;
16  use WebPAC::Validate;  use WebPAC::Validate;
17  use YAML qw/LoadFile/;  use YAML qw/LoadFile/;
# Line 54  or C<type> from input Line 53  or C<type> from input
53    
54  path to YAML configuration file  path to YAML configuration file
55    
 =item --force-set  
   
 force conversion C<< normalize->path >> in C<config.yml> from  
 C<.xml> to C<.pl>  
   
56  =item --stats  =item --stats
57    
58  disable indexing and dump statistics about field and subfield  disable indexing and dump statistics about field and subfield
# Line 79  my $clean = 0; Line 73  my $clean = 0;
73  my $config = 'conf/config.yml';  my $config = 'conf/config.yml';
74  my $debug = 0;  my $debug = 0;
75  my $only_filter;  my $only_filter;
 my $force_set = 0;  
76  my $stats = 0;  my $stats = 0;
77  my $validate_path;  my $validate_path;
78    
# Line 91  GetOptions( Line 84  GetOptions(
84          "only=s" => \$only_filter,          "only=s" => \$only_filter,
85          "config" => \$config,          "config" => \$config,
86          "debug" => \$debug,          "debug" => \$debug,
         "force-set" => \$force_set,  
87          "stats" => \$stats,          "stats" => \$stats,
88          "validate=s" => \$validate_path,          "validate=s" => \$validate_path,
89  );  );
# Line 228  while (my ($database, $db_config) = each Line 220  while (my ($database, $db_config) = each
220                          %{ $input },                          %{ $input },
221                  );                  );
222    
                 my $n = new WebPAC::Normalize::XML(  
                 #       filter => { 'foo' => sub { shift } },  
                         db => $db,  
                         lookup_regex => $lookup ? $lookup->regex : undef,  
                         lookup => $lookup,  
                         prefix => $input->{name},  
                 );  
   
223                  my $rules;                  my $rules;
224                  my $normalize_path = $input->{normalize}->{path};                  my $normalize_path = $input->{normalize}->{path};
225    
226                  if ($force_set) {                  $log->logdie("Found '$normalize_path' as normalization file which isn't supported any more!") unless ( $normalize_path =~ m!\.pl$!i );
                         my $new_norm_path = $normalize_path;  
                         $new_norm_path =~ s/\.xml$/.pl/;  
                         if (-e $new_norm_path) {  
                                 $log->debug("--force-set replaced $normalize_path with $new_norm_path");  
                                 $normalize_path = $new_norm_path;  
                         } else {  
                                 $log->debug("--force-set failed on $new_norm_path, fallback to $normalize_path");  
                         }  
                 }  
227    
228                  if ($normalize_path =~ m/\.xml$/i) {                  my $rules = read_file( $normalize_path ) or die "can't open $normalize_path: $!";
                         $n->open(  
                                 tag => $input->{normalize}->{tag},  
                                 xml_file => $normalize_path,  
                         );  
                 } elsif ($normalize_path =~ m/\.(?:yml|yaml)$/i) {  
                         $n->open_yaml(  
                                 path => $normalize_path,  
                                 tag => $input->{normalize}->{tag},  
                         );  
                 } elsif ($normalize_path =~ m/\.(?:pl)$/i) {  
                         $n = undef;  
                         $log->info("using WebPAC::Normalize::Set to process $normalize_path");  
                         $rules = read_file( $normalize_path ) or die "can't open $normalize_path: $!";  
                 }  
229    
230                  foreach my $pos ( 0 ... $input_db->size ) {                  foreach my $pos ( 0 ... $input_db->size ) {
231    
# Line 285  while (my ($database, $db_config) = each Line 246  while (my ($database, $db_config) = each
246                          }                          }
247    
248                                                                    
249                          my $ds;                          my $ds = WebPAC::Normalize::data_structure(
250                          if ($n) {                                  row => $row,
251                                  $ds = $n->data_structure($row);                                  rules => $rules,
252                          } else {                                  lookup => $lookup ? $lookup->lookup_hash : undef,
253                                  $ds = WebPAC::Normalize::Set::data_structure(                          );
254                                          row => $row,  
255                                          rules => $rules,                          $db->save_ds(
256                                          lookup => $lookup ? $lookup->lookup_hash : undef,                                  id => $mfn,
257                                  );                                  ds => $ds,
258                                    prefix => $input->{name},
259                                  $db->save_ds(                          ) if ($ds && !$stats);
                                         id => $mfn,  
                                         ds => $ds,  
                                         prefix => $input->{name},  
                                 ) if ($ds && !$stats);  
                         }  
260    
261                          $indexer->add(                          $indexer->add(
262                                  id => $input->{name} . "/" . $mfn,                                  id => $input->{name} . "/" . $mfn,

Legend:
Removed from v.535  
changed lines
  Added in v.536

  ViewVC Help
Powered by ViewVC 1.1.26