r1298@llin: dpavlin | 2007-06-22 02:03:23 +0200
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 22 Jun 2007 00:03:46 +0000 (00:03 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 22 Jun 2007 00:03:46 +0000 (00:03 +0000)
 input_config can be given to new or open now

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@873 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/Input.pm
lib/WebPAC/Input/DBF.pm

index 4651f3b..d8a2f0b 100644 (file)
@@ -236,7 +236,7 @@ sub open {
 
        my $ll_db = $class->new(
                path => $arg->{path},
-               input_config => $arg->{input_config},
+               input_config => $arg->{input_config} || $self->{input_config},
 #              filter => sub {
 #                      my ($l,$f_nr) = @_;
 #                      return unless defined($l);
index 84506f2..bf6723f 100644 (file)
@@ -81,10 +81,10 @@ sub new {
 
        $log->info("opening DBF database '$arg->{path}' with $size records");
 
-       my $mapping_path = $arg->{input_config}->{mapping_path};
+       my $mapping_path = $arg->{input_config}->{mapping_path} || $self->{input_config}->{mapping_path};
        my $mapping;
 
-       if ( ! $mapping_path ) {
+       if ( ! $mapping_path || ! -e $mapping_path ) {
                $log->debug("didn't found any mapping_path in configuration", sub { dump( $arg->{input_config} ) });
 
                foreach my $field ( $db->field_names ) {
@@ -96,7 +96,7 @@ sub new {
 
                $log->logdie("mapping file $mapping_path allready exists, aborting.") if ( -e $mapping_path );
 
-               DumpFile( $mapping_path, Dump( { mapping => $mapping } ) ) ||
+               DumpFile( $mapping_path, { mapping => $mapping } ) ||
                        $log->logdie("can't write template file for mapping_path $mapping_path: $!");
 
                $log->logdie("template file for mapping_path created as $mapping_path");