/[webpac]/trunk2/lib/WebPAC.pm
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/lib/WebPAC.pm

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

revision 439 by dpavlin, Mon Sep 13 23:13:54 2004 UTC revision 453 by dpavlin, Wed Sep 15 21:21:36 2004 UTC
# Line 209  sub open_isis { Line 209  sub open_isis {
209          if (my $s = $self->{'start_mfn'}) {          if (my $s = $self->{'start_mfn'}) {
210                  $log->info("skipping to MFN $s");                  $log->info("skipping to MFN $s");
211                  $startmfn = $s;                  $startmfn = $s;
212            } else {
213                    $self->{'start_mfn'} = $startmfn;
214          }          }
215    
216          $maxmfn = $startmfn + $self->{limit_mfn} if ($self->{limit_mfn});          $maxmfn = $startmfn + $self->{limit_mfn} if ($self->{limit_mfn});
# Line 264  sub open_isis { Line 266  sub open_isis {
266    
267          }          }
268    
269          $self->{'current_mfn'} = $startmfn;          $self->{'current_mfn'} = -1;
270          $self->{'last_pcnt'} = 0;          $self->{'last_pcnt'} = 0;
271    
272          $log->debug("max mfn: $maxmfn");          $log->debug("max mfn: $maxmfn");
# Line 287  sub fetch_rec { Line 289  sub fetch_rec {
289    
290          my $log = $self->_get_logger();          my $log = $self->_get_logger();
291    
292          my $mfn = $self->{'current_mfn'}++ || $log->logconfess("it seems that you didn't load database!");          $log->logconfess("it seems that you didn't load database!") unless ($self->{'current_mfn'});
293    
294            if ($self->{'current_mfn'} == -1) {
295                    $self->{'current_mfn'} = $self->{'start_mfn'};
296            } else {
297                    $self->{'current_mfn'}++;
298            }
299    
300            my $mfn = $self->{'current_mfn'};
301    
302          if ($mfn > $self->{'max_mfn'}) {          if ($mfn > $self->{'max_mfn'}) {
303                  $self->{'current_mfn'} = $self->{'max_mfn'};                  $self->{'current_mfn'} = $self->{'max_mfn'};
# Line 304  sub fetch_rec { Line 314  sub fetch_rec {
314          }          }
315  }  }
316    
317    =head2 mfn
318    
319    Returns current record number (MFN).
320    
321     print $webpac->mfn;
322    
323    =cut
324    
325    sub mfn {
326            my $self = shift;
327            return $self->{'current_mfn'};
328    }
329    
330  =head2 progress_bar  =head2 progress_bar
331    
332  Draw progress bar on STDERR.  Draw progress bar on STDERR.
# Line 335  sub progress_bar { Line 358  sub progress_bar {
358          if ($p < $self->{'last_pcnt'}) {          if ($p < $self->{'last_pcnt'}) {
359                  $self->{'last_pcnt'} = $p;                  $self->{'last_pcnt'} = $p;
360                  $self->{'last_t'} = time();                  $self->{'last_t'} = time();
361                  $self->{'last_curr'} = 1;                  $self->{'last_curr'} = undef;
362          }          }
363    
364          if ($p != $self->{'last_pcnt'}) {          if ($p != $self->{'last_pcnt'}) {
# Line 754  sub fill_in_to_arr { Line 777  sub fill_in_to_arr {
777          return @arr;          return @arr;
778  }  }
779    
780    =head2 sort_arr
781    
782    Sort array ignoring case and html in data
783    
784     my @sorted = $webpac->sort_arr(@unsorted);
785    
786    =cut
787    
788    sub sort_arr {
789            my $self = shift;
790    
791            my $log = $self->_get_logger();
792    
793            # FIXME add Schwartzian Transformation?
794    
795            my @sorted = sort {
796                    $a =~ s#<[^>]+/*>##;
797                    $b =~ s#<[^>]+/*>##;
798                    lc($b) cmp lc($a)
799            } @_;
800            $log->debug("sorted values: ",sub { join(", ",@sorted) });
801    
802            return @sorted;
803    }
804    
805    
806  =head2 data_structure  =head2 data_structure
807    
# Line 811  sub data_structure { Line 859  sub data_structure {
859                          next if (! @v);                          next if (! @v);
860    
861                          if ($tag->{'sort'}) {                          if ($tag->{'sort'}) {
862                                  # very special sort, ignoring case and                                  @v = $self->sort_arr(@v);
                                 # html  
                                 @v = sort {  
                                         $a =~ s#<[^>]+/*>##;  
                                         $b =~ s#<[^>]+/*>##;  
                                         lc($b) cmp lc($a)  
                                 } @v;  
863                                  $log->warn("sort within tag is usually not what you want!");                                  $log->warn("sort within tag is usually not what you want!");
                                 $log->debug("sorted values: ",sub { join(", ",@v) });  
864                          }                          }
865    
866                          # use format?                          # use format?
# Line 880  sub data_structure { Line 921  sub data_structure {
921                          # post-sort all values in field                          # post-sort all values in field
922                          if ($self->{'import_xml'}->{'indexer'}->{$field}->{'sort'}) {                          if ($self->{'import_xml'}->{'indexer'}->{$field}->{'sort'}) {
923                                  $log->warn("sort at field tag not implemented");                                  $log->warn("sort at field tag not implemented");
   
924                          }                          }
925    
926                          push @ds, $row;                          push @ds, $row;

Legend:
Removed from v.439  
changed lines
  Added in v.453

  ViewVC Help
Powered by ViewVC 1.1.26