IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 28, 2008, 11:12:12 AM (18 years ago)
Author:
eugene
Message:

perl function to handle REDUCTION as an external file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-Config/lib/PS/IPP/Config.pm

    r16917 r17487  
    11# Copyright (c) 2006  Paul Price, Joshua Hoblitt
    22#
    3 # $Id: Config.pm,v 1.80 2008-03-11 01:30:37 eugene Exp $
     3# $Id: Config.pm,v 1.81 2008-04-28 21:12:12 eugene Exp $
    44
    55package PS::IPP::Config;
     
    9191        filerules => undef,     # File rules from the camera configuration
    9292        rejection => undef,     # Rejection data
     93        reductionClasses => undef, # Reduction class definitions
    9394        _userConfig => $mdc,    # The top-level user configuration
    9495        _siteConfig => undef,   # The site configuration (from _userConfig)
     
    10041005    }
    10051006
    1006     my $camera = $self->{camera}; # Camera configuration
    1007     unless (defined $camera) {
    1008         carp "Camera has not yet been defined.\n";
    1009         return undef;
    1010     }
    1011    
    1012     my $classes = metadataLookupMD($camera, "REDUCTION") or # Reduction classes
    1013         (carp "Can't find REDUCTION in camera configuration.\n" and exit($PS_EXIT_CONFIG_ERROR));
    1014 
    1015     my $class = metadataLookupMD($classes, $reduction) or # Class of interest
     1007    my $reductionClasses;
     1008    if (defiend $self->{reductionClasses}) {
     1009        $reductionClasses = $self->{reductionClasses};
     1010    } else  {
     1011        # load and save the reductionClasses table
     1012
     1013        # need to have a valid camear
     1014        my $camera = $self->{camera}; # Camera configuration
     1015        unless (defined $camera) {
     1016            carp "Camera has not yet been defined.\n";
     1017            return undef;
     1018        }
     1019
     1020        $reductionClasses = metadataLookup($camera, 'REDUCTION');       # File rules
     1021
     1022        unless (defined $reductionClasses) {
     1023            carp "Can't find REDUCTION list in camera configuration.\n";
     1024            return undef;
     1025        }
     1026       
     1027        if ($reductionClasses->{class} eq "scalar" and $reductionClasses->{type} eq "STR") {
     1028            # Allow indirection to a file
     1029            my $filename = $self->_find_config($reductionClasses->{value}); # Resolved filename
     1030            # Read the file
     1031            my $file;           # File handle
     1032            unless (open $file, $filename) {
     1033                carp "Unable to open reductionClasses file $filename: $!";
     1034                exit($PS_EXIT_CONFIG_ERROR);
     1035            }
     1036            my @contents = <$file>;
     1037            close $file;
     1038            $reductionClasses = $parser->parse( join '', @contents);
     1039        } elsif ($reductionClasses->{class} eq "metadata") {
     1040            $reductionClasses = $reductionClasses->{value};
     1041        } else {
     1042            carp "Can't interpret REDUCTIONS in camera configuration.\n";
     1043            return undef;
     1044        }
     1045        $self->{reductionClasses} = $reductionClasses;
     1046    }
     1047
     1048    my $class = metadataLookupMD($reductionClasses, $reduction) or # Class of interest
    10161049        (carp "Can't find $reduction in REDUCTION in camera configuration.\n" and
    10171050         exit($PS_EXIT_CONFIG_ERROR));
Note: See TracChangeset for help on using the changeset viewer.