IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2010, 12:49:05 PM (16 years ago)
Author:
eugene
Message:

merging changes from trunk into branches/pap

Location:
branches/pap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/PS-IPP-Metadata-Config/lib/PS/IPP/Metadata/Config.pm

    r15558 r28003  
    5959}
    6060
     61# Parse a list of METADATAs
     62sub parse_list
     63{
     64    my $self = shift;           # This parser
     65
     66    # Split input into separate METADATAs because the parser seems to take forever handling those together
     67    my @whole = split /\n/, join( '', @_ ); # The whole input
     68    my @single;                             # A single METADATA element
     69    my @output;                             # Output
     70    foreach my $value (@whole) {
     71        push @single, $value;
     72        if ($value =~ /^\s*END\s*$/) {
     73            push @single, "\n";
     74
     75            my $md = join("\n", @single); # Metadata to parse
     76            my $parsed = $self->parse($md) or (carp "Unable to parse input: $md\n" and next);
     77            (carp "More than one entry in input: $md\n" and next) if scalar @$parsed > 1;
     78            my $metadata = shift @$parsed; # Metadata of interest
     79            (carp "MD element is not of type METADATA: $md\n" and next) if $metadata->{class} ne "metadata";
     80            my $components = $metadata->{value}; # Components of metadata
     81            my %hash;           # Hash for entry
     82            foreach my $comp (@$components) {
     83                $hash{$comp->{name}} = $comp->{value};
     84            }
     85            push @output, \%hash;
     86            @single = ();
     87        }
     88    }
     89
     90    return \@output;
     91}
     92
    6193sub _merge_duplicates {
    6294    my ( $self, $tree ) = @_;
     
    73105        # stop if the prevous pass removed the last element and called redo
    74106        last unless defined $elem;
    75                
     107
    76108        # recurse through nested metadata
    77109        if ( $elem->{class} eq "metadata" ) {
     
    83115            delete $elem->{multi};
    84116            next;
    85         } 
     117        }
    86118
    87119        if ( defined $names{ $elem->{name} } ) {
Note: See TracChangeset for help on using the changeset viewer.