/[webpac]/trunk/all2xml.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/all2xml.pl

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

revision 488 by dpavlin, Wed Sep 29 17:22:24 2004 UTC revision 618 by dpavlin, Fri Dec 31 03:35:43 2004 UTC
# Line 139  sub data2xml { Line 139  sub data2xml {
139                  } else {                  } else {
140                          print STDERR "WARNING: field '$field' doesn't have 'name' attribute!";                          print STDERR "WARNING: field '$field' doesn't have 'name' attribute!";
141                  }                  }
142    
143                  if ($field_name) {                  if ($field_name) {
144                            $field_name = x($field_name);
145                          if (! $last_field_name) {                          if (! $last_field_name) {
146                                  $last_field_name = x($field_name);                                  $last_field_name = $field_name;
147                                  return $last_field_name;                                  return $last_field_name;
148                          } elsif ($field_name ne $last_field_name) {                          } elsif ($field_name ne $last_field_name) {
149                                  $last_field_name = x($field_name);                                  $last_field_name = $field_name;
150                                  return $last_field_name;                                  return $last_field_name;
151                          }                          }
152                  }                  }
# Line 665  print STDERR "reading ./import_xml/$type Line 667  print STDERR "reading ./import_xml/$type
667    
668          $config=XMLin("./import_xml/$type.xml", ForceArray => [ $type2tag{$type_base}, 'config', 'format' ], ForceContent => 1 );          $config=XMLin("./import_xml/$type.xml", ForceArray => [ $type2tag{$type_base}, 'config', 'format' ], ForceContent => 1 );
669    
670            # helper for progress bar
671            sub fmt_time {
672                    my $t = shift || 0;
673                    my $out = "";
674    
675                    my ($ss,$mm,$hh) = gmtime($t);
676                    $out .= "${hh}h" if ($hh);
677                    $out .= sprintf("%02d:%02d", $mm,$ss);
678                    $out .= "  " if ($hh == 0);
679                    return $out;
680            }
681    
682          # output current progress indicator          # output current progress indicator
683          my $last_p = 0;          my $last_p = 0;
684            my $start_t = time();
685          sub progress {          sub progress {
686                  return if (! $show_progress);                  return if (! $show_progress);
687                  my $current = shift;                  my $current = shift;
688                  my $total = shift || 1;                  my $total = shift || 1;
689                  my $p = int($current * 100 / $total);                  my $p = int($current * 100 / $total);
690                  if ($p != $last_p) {                  if ($p != $last_p) {
691                          printf STDERR ("%5d / %5d [%-51s] %-2d %% \r",$current,$total,"=" x ($p/2).">", $p );                          my $rate = ($current / (time() - $start_t || 1));
692                            my $eta = ($total-$current) / ($rate || 1);
693                            printf STDERR ("%5d [%-38s] %-5d %0.1f/s %s\r",$current,"=" x ($p/3)."$p%>", $total, $rate, fmt_time($eta));
694                          $last_p = $p;                          $last_p = $p;
695                  }                  }
696          }          }

Legend:
Removed from v.488  
changed lines
  Added in v.618

  ViewVC Help
Powered by ViewVC 1.1.26