--- trunk/run.pl 2005/12/18 21:06:39 285 +++ trunk/run.pl 2005/12/18 21:06:46 286 @@ -74,25 +74,36 @@ $log->info("database $database doesn't have inputs defined"); } + my @supported_inputs = keys %{ $config->{webpac}->{inputs} }; + foreach my $input (@inputs) { my $type = lc($input->{type}); - die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis'); + die "I know only how to handle input types ", join(",", @supported_inputs), " not '$type'!\n" unless (grep(/$type/, @supported_inputs)); my $lookup = new WebPAC::Lookup( lookup_file => $input->{lookup}, ); - $log->info("working on input $input->{path} [$input->{type}]"); + my $input_module = $config->{webpac}->{inputs}->{$type}; + + $log->info("working on input $input->{path} [$input->{type}] using $input_module"); - my $isis = new WebPAC::Input::ISIS( + sub new_input { + my $name = shift; + my $args = shift; + new $name->($args); + } + + my $input = new_input($input_module,{ code_page => $config->{webpac}->{webpac_encoding}, limit_mfn => $input->{limit}, lookup => $lookup, - ); + }); + $log->logdie("can't create input using $input_module") unless ($input); - my $maxmfn = $isis->open( + my $maxmfn = $input->open( path => $input->{path}, code_page => $input->{encoding}, # database encoding ); @@ -119,9 +130,9 @@ ); } - for ( 0 ... $isis->size ) { + for ( 0 ... $input->size ) { - my $row = $isis->fetch || next; + my $row = $input->fetch || next; my $mfn = $row->{'000'}->[0] || die "can't find MFN";