198 |
my $rec = $self->{'data'}->{$mfn}; |
my $rec = $self->{'data'}->{$mfn}; |
199 |
$self->create_lookup($rec, @{$arg->{'lookup'}}); |
$self->create_lookup($rec, @{$arg->{'lookup'}}); |
200 |
|
|
201 |
|
$self->progress_bar($mfn,$maxmfn); |
202 |
|
|
203 |
} |
} |
204 |
|
|
205 |
$self->{'current_mfn'} = 1; |
$self->{'current_mfn'} = 1; |
206 |
|
$self->{'last_pcnt'} = 0; |
207 |
|
|
208 |
# store max mfn and return it. |
# store max mfn and return it. |
209 |
return $self->{'max_mfn'} = $maxmfn; |
return $self->{'max_mfn'} = $maxmfn; |
231 |
return; |
return; |
232 |
} |
} |
233 |
|
|
234 |
|
$self->progress_bar($mfn,$self->{'max_mfn'}); |
235 |
|
|
236 |
return $self->{'data'}->{$mfn}; |
return $self->{'data'}->{$mfn}; |
237 |
} |
} |
238 |
|
|
239 |
|
=head2 progress_bar |
240 |
|
|
241 |
|
Draw progress bar on STDERR. |
242 |
|
|
243 |
|
$webpac->progress_bar($current, $max); |
244 |
|
|
245 |
|
=cut |
246 |
|
|
247 |
|
sub progress_bar { |
248 |
|
my $self = shift; |
249 |
|
|
250 |
|
my ($curr,$max) = @_; |
251 |
|
|
252 |
|
my $log = $self->_get_logger(); |
253 |
|
|
254 |
|
$log->logconfess("no current value!") if (! $curr); |
255 |
|
$log->logconfess("no maximum value!") if (! $max); |
256 |
|
|
257 |
|
if ($curr > $max) { |
258 |
|
$max = $curr; |
259 |
|
$log->debug("overflow to $curr"); |
260 |
|
} |
261 |
|
|
262 |
|
$self->{'last_pcnt'} ||= 1; |
263 |
|
|
264 |
|
$self->{'last_pcnt'} = $curr if ($curr < $self->{'last_pcnt'}); |
265 |
|
|
266 |
|
my $p = int($curr * 100 / $max); |
267 |
|
if ($p != $self->{'last_pcnt'}) { |
268 |
|
printf STDERR ("%5d / %5d [%-51s] %-2d %% \r",$curr,$max,"=" x ($p/2).">", $p ); |
269 |
|
$self->{'last_pcnt'} = $p; |
270 |
|
} |
271 |
|
} |
272 |
|
|
273 |
=head2 open_import_xml |
=head2 open_import_xml |
274 |
|
|
275 |
Read file from C<import_xml/> directory and parse it. |
Read file from C<import_xml/> directory and parse it. |
374 |
|
|
375 |
if ($$rec->{$f}) { |
if ($$rec->{$f}) { |
376 |
return '' if (! $$rec->{$f}->[$i]); |
return '' if (! $$rec->{$f}->[$i]); |
377 |
|
no strict 'refs'; |
378 |
if ($sf && $$rec->{$f}->[$i]->{$sf}) { |
if ($sf && $$rec->{$f}->[$i]->{$sf}) { |
379 |
$$found++ if (defined($$found)); |
$$found++ if (defined($$found)); |
380 |
return $$rec->{$f}->[$i]->{$sf}; |
return $$rec->{$f}->[$i]->{$sf}; |
415 |
This function B<does not> perform parsing of format to inteligenty skip |
This function B<does not> perform parsing of format to inteligenty skip |
416 |
delimiters before fields which aren't used. |
delimiters before fields which aren't used. |
417 |
|
|
418 |
|
This method will automatically decode UTF-8 string to local code page |
419 |
|
if needed. |
420 |
|
|
421 |
=cut |
=cut |
422 |
|
|
423 |
sub fill_in { |
sub fill_in { |
433 |
# FIXME remove for speedup? |
# FIXME remove for speedup? |
434 |
$log->logconfess("need HASH as first argument!") if ($rec !~ /HASH/o); |
$log->logconfess("need HASH as first argument!") if ($rec !~ /HASH/o); |
435 |
|
|
436 |
|
if (utf8::is_utf8($format)) { |
437 |
|
$format = $self->_x($format); |
438 |
|
} |
439 |
|
|
440 |
my $found = 0; |
my $found = 0; |
441 |
|
|
442 |
my $eval_code; |
my $eval_code; |