r11711@llin: dpavlin | 2005-12-15 20:02:16 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 15 Dec 2005 17:01:04 +0000 (17:01 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 15 Dec 2005 17:01:04 +0000 (17:01 +0000)
 varios tweaks to make lookups work

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

conf/log.conf
conf/normalize/isis_ffzg.xml
lib/WebPAC/Lookup.pm
lib/WebPAC/Normalize.pm
lib/WebPAC/Normalize/XML.pm
t/6-unit.t

index 6f8da85..d2b7f42 100644 (file)
@@ -16,14 +16,15 @@ log4perl.logger.main=INFO
 #log4perl.logger.WebPAC.Store.load_ds=DEBUG
 
 #log4perl.logger.WebPAC.Lookup=DEBUG
-log4perl.logger.WebPAC.Lookup.lookup=DEBUG
+#log4perl.logger.WebPAC.Lookup.lookup=DEBUG
 
 #log4perl.logger.WebPAC.Input=DEBUG
 #log4perl.logger.WebPAC.Input.ISIS=DEBUG
 #log4perl.logger.WebPAC.Input.ISIS.fetch=DEBUG
 #log4perl.logger.WebPAC.Input.ISIS.open=DEBUG
 
-log4perl.logger.WebPAC.Normalize=DEBUG
+#log4perl.logger.WebPAC.Normalize=DEBUG
+log4perl.logger.WebPAC.Normalize.new=DEBUG
 #log4perl.logger.WebPAC.Normalize.XML=DEBUG
 #log4perl.logger.WebPAC.Normalize.data_structure=DEBUG
 #log4perl.logger.WebPAC.Normalize.fill_in_to_arr=DEBUG
index 8cf2e9f..9ed6c4f 100644 (file)
        </Set_2>
 
        <Parts>
-               <isis>lookup{[tip-naslovi:v946^1]}</isis>
+               <isis>lookup{naslov:[tip-naslovi:v946^1]}</isis>
        </Parts>
        
        <CallNo>
index fc1001d..443d49c 100644 (file)
@@ -83,7 +83,7 @@ sub new {
 
        $log->logconfess("lookup config file isn't ARRAY but ", sub { Dumper( $self->{'lookup_def'} ) }) if ($self->{'lookup_def'} !~ /ARRAY/o);
 
-       $self->{'is_lookup_regex'} ||= 'lookup{\[[^\{\}]+\]}';
+       $self->{'is_lookup_regex'} ||= 'lookup{[^\{\}]+}';
         $self->{'save_lookup_regex'} ||= 'lookup{([^\{\}]+)}';
 
 
@@ -162,8 +162,6 @@ sub lookup {
        if ($tmp =~ $self->{'LOOKUP_REGEX'}) {
                my @in = ( $tmp );
 
-               $log->debug("lookup for: ",$tmp);
-
                my @out;
                while (my $f = shift @in) {
                        if ($f =~ $self->{'LOOKUP_REGEX_SAVE'}) {
@@ -181,7 +179,10 @@ sub lookup {
                                push @out, $f;
                        }
                }
+               $log->debug("lookup for: ",$tmp, " returned: ", join(", ",@out));
+
                $log->logconfess("return is array and it's not expected!") unless wantarray;
+
                return @out;
        } else {
                return $tmp;
index bbc4094..2bc9a41 100644 (file)
@@ -117,6 +117,8 @@ sub new {
 
        $log->warn("no prefix defined. please check that!") unless ($self->{'prefix'});
 
+       $log->debug("using lookup regex: ", $self->{lookup_regex}) if ($r && $l);
+
        $self ? return $self : return undef;
 }
 
@@ -213,7 +215,7 @@ sub data_structure {
 
                        foreach my $type (@types) {
                                # append to previous line?
-                               $log->debug("type: $type ",sub { join(" ",@v) }, $row->{'append'} || 'no append');
+                               $log->debug("type: $type ",sub { join(" ",@v) }, " ", $row->{'append'} || 'no append');
                                if ($tag->{'append'}) {
 
                                        # I will delimit appended part with
@@ -461,7 +463,9 @@ sub fill_in {
                # do we have lookups?
                if ($self->{'lookup'}) {
                        if ($self->{'lookup'}->can('lookup')) {
-                               return $self->{'lookup'}->lookup($format);
+                               my @lookup = $self->{lookup}->lookup($format);
+                               $log->debug('lookup $format', join(", ", @lookup));
+                               return @lookup;
                        } else {
                                $log->warn("Have lookup object but can't invoke lookup method");
                        }
index 9da782f..99162a5 100644 (file)
@@ -76,7 +76,7 @@ sub open {
                ForceContent => 1,
        );
 
-       $log->debug("import xml is ",sub { Dumper($self->{'import_xml'}) });
+       $log->debug("import xml is ",sub { Dumper($self->{'import_xml'}) }, $self->{lookup} ? " using lookups" : "lookups disabled");
 
        return $self;
 }
index 3c5f67d..1e26994 100755 (executable)
@@ -38,6 +38,7 @@ ok(my $isis = new WebPAC::Input::ISIS(
 ok(my $maxmfn = $isis->open(
        filename => $isis_file,
        code_page => '852',             # database encoding
+       lookup => $lookup,
 ), "Input::ISIS->open");
 
 ok(my $path = tempdir( CLEANUP => 1 ), "path");