/[webpac]/trunk2/all2all.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 /trunk2/all2all.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 197 by dpavlin, Sun Dec 21 03:27:02 2003 UTC revision 263 by dpavlin, Fri Mar 12 15:06:58 2004 UTC
# Line 228  sub data2xml { Line 228  sub data2xml {
228                                          if (($#data+1) == $nr) {                                          if (($#data+1) == $nr) {
229                                                  return sprintf($fmt,@data);                                                  return sprintf($fmt,@data);
230                                          } else {                                          } else {
231                                                  print STDERR "mkformat: [$data] can't be split on [$format_delimiter] to $nr fields!\n";                                                  #print STDERR "mkformat: [$data] can't be split on [$format_delimiter] to $nr fields!\n";
232                                                  return $data;                                                  return $data;
233                                          }                                          }
234                                  } else {                                  } else {
# Line 257  sub data2xml { Line 257  sub data2xml {
257                                                                  $display = $new_display;                                                                  $display = $new_display;
258                                                                  $cache->{lhash}->{$display} = $new_display;                                                                  $cache->{lhash}->{$display} = $new_display;
259                                                          } else {                                                          } else {
260                                                                  print STDERR "WARNING: lookup for '$display' didn't find anything.\n";  #                                                               print STDERR "WARNING: lookup for '$display' didn't find anything.\n";
261                                                                  $display = "";                                                                  $display = "";
262                                                                  $cache->{lhash}->{$display} = $null;                                                                  $cache->{lhash}->{$display} = $null;
263                                                          }                                                          }
# Line 278  sub data2xml { Line 278  sub data2xml {
278                                  }                                  }
279                                  # type="swish" ; field for swish                                  # type="swish" ; field for swish
280                                  if ($swish) {                                  if ($swish) {
281                                            my $tmp = $swish;
282                                          if ($filter && ($s || $se)) {                                          if ($filter && ($s || $se)) {
283                                                  no strict 'refs';                                                  no strict 'refs';
284                                                  my $tmp = join(" ",&$filter($swish)) if ($s || $se);                                                  $tmp = join(" ",&$filter($tmp)) if ($s || $se);
                                                 $swish_data .= $tmp if ($s);  
                                                 $swish_exact_data .= "xxbxx $tmp xxexx " if ($se && $tmp ne "");  
   
                                         } else {  
                                                 $swish_data .= $swish if ($s);  
                                                 $swish_exact_data .= "xxbxx $swish xxexx " if ($se && $swish ne "");  
285                                          }                                          }
286    
287                                            $swish_data .= $tmp if ($s && $tmp);
288                                            $swish_exact_data .= "xxbxx $tmp xxexx " if ($tmp && $tmp ne "" && $se);
289                                  }                                  }
290    
291                                  # type="display" ; field for display                                  # type="display" ; field for display
292                                  if ($d && $display) {                                  if ($d && $display) {
293                                            my $ldel = $delimiter;
294                                          if ($line_delimiter && $display_data) {                                          if ($line_delimiter && $display_data) {
295                                                  $display_data .= $line_delimiter;                                                  $ldel = $line_delimiter;
296                                          }                                          }
297                                          if ($filter) {                                          if ($filter) {
298                                                  no strict 'refs';                                                  no strict 'refs';
299                                                  if ($display_data) {                                                  my @arr;
300                                                          $display_data .= $delimiter.join($delimiter,mkformat($x,&$filter($display)));                                                  foreach my $tmp (&$filter($display)) {
301                                                  } else {                                                          my $tmp2 = mkformat($x,$tmp);
302                                                          $display_data = join($delimiter,mkformat($x,&$filter($display)));                                                          push @arr,$tmp2 if ($tmp2);
303                                                  }                                                  }
304                                                    $display_data .= $ldel if ($display_data && @arr);
305                                                    $display_data .= join($delimiter,@arr);
306                                          } else {                                          } else {
307                                                  if ($display_data) {                                                  $display_data .= $ldel if ($display_data);
308                                                          $display_data .= $delimiter.mkformat($x,$display);                                                  my $tmp = mkformat($x,$display);
309                                                  } else {                                                  $display_data .= $tmp if ($tmp);
                                                         $display_data = mkformat($x,$display);  
                                                 }  
310                                          }                                          }
311                                  }                                  }
312                                                                                                    
# Line 319  sub data2xml { Line 318  sub data2xml {
318                                                  no strict 'refs';                                                  no strict 'refs';
319                                                  $idisplay = &$filter($idisplay);                                                  $idisplay = &$filter($idisplay);
320                                          }                                          }
321                                          push @index_data, $idisplay if (! $iterate_by_page);                                          push @index_data, $idisplay if ($idisplay && !$iterate_by_page);
322                                  }                                  }
323    
324                                  # store fields in lookup                                  # store fields in lookup
# Line 328  sub data2xml { Line 327  sub data2xml {
327                                                  if ($lookup_key) {                                                  if ($lookup_key) {
328                                                          print STDERR "WARNING: try to redefine lookup_key (keys shouldn't be repeatable fields!)";                                                          print STDERR "WARNING: try to redefine lookup_key (keys shouldn't be repeatable fields!)";
329                                                  } else {                                                  } else {
330                                                          $lookup_key = $display;                                                          if ($filter) {
331                                                                    no strict 'refs';
332                                                                    $lookup_key = &$filter($display);
333                                                            } else {
334                                                                    $lookup_key = $display;
335                                                            }
336                                                  }                                                  }
337                                          } elsif (lc($x->{type}) eq "lookup_val") {                                          } elsif (lc($x->{type}) eq "lookup_val") {
338                                                  if ($lookup_key) {                                                  if ($lookup_key) {
339                                                          $lhash{$lookup_key} = $display;                                                          if ($filter) {
340                                                                    no strict 'refs';
341                                                                    $lhash{$lookup_key} = &$filter($display);
342                                                            } else {
343                                                                    $lhash{$lookup_key} = $display;
344                                                            }
345                                                  } else {                                                  } else {
346                                                          print STDERR "WARNING: no lookup_key defined for  '$display'?";                                                          print STDERR "WARNING: no lookup_key defined for  '$display'?";
347                                                  }                                                  }
# Line 451  sub data2xml { Line 460  sub data2xml {
460                          for (my $page=0; $page <= $nr_pages; $page++) {                          for (my $page=0; $page <= $nr_pages; $page++) {
461                                  my $display_data;                                  my $display_data;
462                                  if ($cache->{format}->{$field}) {                                  if ($cache->{format}->{$field}) {
463                                          $display_data=mkformat($cache->{format}->{$field},$cache->{display_data}->{$field}->[$page]);                                          my $tmp = mkformat($cache->{format}->{$field},$cache->{display_data}->{$field}->[$page]);
464                                            $display_data=$tmp if ($tmp);
465                                  } else {                                  } else {
466                                          $display_data = $cache->{display_data}->{$field}->[$page];                                          $display_data = $cache->{display_data}->{$field}->[$page];
467                                  }                                  }
# Line 577  foreach my $database ($cfg->Sections) { Line 587  foreach my $database ($cfg->Sections) {
587                  #tie %lhash, 'GDBM_File', $lookup_file, &GDBM_NEWDB, 0644;                  #tie %lhash, 'GDBM_File', $lookup_file, &GDBM_NEWDB, 0644;
588                  tie %lhash, 'TDB_File', $lookup_file, TDB_CLEAR_IF_FIRST, O_RDWR, 0644;                  tie %lhash, 'TDB_File', $lookup_file, TDB_CLEAR_IF_FIRST, O_RDWR, 0644;
589                  print STDERR "creating lookup file '$lookup_file'\n";                  print STDERR "creating lookup file '$lookup_file'\n";
590                    # delete memory cache for lookup file
591                    delete $cache->{lhash};
592          }          }
593    
594          # open existing lookup file          # open existing lookup file
# Line 713  print STDERR "using: $type...\n"; Line 725  print STDERR "using: $type...\n";
725                  print STDERR "\n";                  print STDERR "\n";
726    
727          } elsif ($type_base eq "excel") {          } elsif ($type_base eq "excel") {
728                  use Spreadsheet::ParseExcel;                  require Spreadsheet::ParseExcel;
729                  use Spreadsheet::ParseExcel::Utility qw(int2col);                  require Spreadsheet::ParseExcel::Utility;
730                    import Spreadsheet::ParseExcel::Utility qw(int2col);
731                                    
732                  $import2cp = Text::Iconv->new($config->{excel_codepage},$codepage);                  $import2cp = Text::Iconv->new($config->{excel_codepage},$codepage);
733                  my $excel_file = $cfg -> val($database, 'excel_file') || die "$database doesn't have 'excel_file' defined!";                  my $excel_file = $cfg -> val($database, 'excel_file') || die "$database doesn't have 'excel_file' defined!";
# Line 768  print STDERR "using: $type...\n"; Line 781  print STDERR "using: $type...\n";
781                  }                  }
782          } elsif ($type_base eq "marc") {          } elsif ($type_base eq "marc") {
783    
784                  use MARC;                  require MARC;
785                                    
786                  $import2cp = Text::Iconv->new($config->{marc_codepage},$codepage);                  $import2cp = Text::Iconv->new($config->{marc_codepage},$codepage);
787                  my $marc_file = $cfg -> val($database, 'marc_file') || die "$database doesn't have 'marc_file' defined!";                  my $marc_file = $cfg -> val($database, 'marc_file') || die "$database doesn't have 'marc_file' defined!";
788    
789                  # optional argument is format                  # optional argument is format
790                  my $format = x($config->{format}) || 'usmarc';                  my $format = x($config->{marc_format}) || 'usmarc';
791    
792                  print STDERR "Reading MARC file '$marc_file'\n";                  print STDERR "Reading MARC file '$marc_file'\n";
793    
794                  my $marc = new MARC;                  my $marc = new MARC;
795                  my $nr = $marc->openmarc({                  my $nr = $marc->openmarc({
796                                  file=>$marc_file, format=>$format                                  file=>$marc_file, format=>$format
797                          }) || die "Can't open MARC file '$marc_file'";                          }) || die "Can't open MARC file '$marc_file' with format '$format'";
798    
799                    # read MARC file in memory
800                    $marc->nextmarc(-1);
801    
802                  my $i=0;        # record nr.                  my $max_rec = $marc->marc_count();
803    
804                  my $rec;                  for(my $i=1; $i<=$max_rec; $i++) {
805    
806                  while ($marc->nextmarc(1)) {                          progress($i,$max_rec);
807    
808                          # XXX                          # store value for marc_sf.pm
809                          fakeprogress($i++);                          $main::cache->{marc_record} = $i;
810    
811                          my $swishpath = $database."#".$i;                          my $swishpath = $database."#".$i;
812    
# Line 802  print STDERR "using: $type...\n"; Line 818  print STDERR "using: $type...\n";
818                                  print "Document-Type: XML\n\n$xml\n";                                  print "Document-Type: XML\n\n$xml\n";
819                          }                          }
820                  }                  }
821    
822                    print STDERR "\n";
823    
824          } elsif ($type_base eq "feed") {          } elsif ($type_base eq "feed") {
825    
826                  $import2cp = Text::Iconv->new($config->{feed_codepage},$codepage);                  $import2cp = Text::Iconv->new($config->{feed_codepage},$codepage);

Legend:
Removed from v.197  
changed lines
  Added in v.263

  ViewVC Help
Powered by ViewVC 1.1.26