IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10420


Ignore:
Timestamp:
Dec 3, 2006, 8:43:40 AM (19 years ago)
Author:
eugene
Message:

added ipprc.convert_filename method

File:
1 edited

Legend:

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

    r10332 r10420  
    11# Copyright (c) 2006  Paul Price, Joshua Hoblitt
    22#
    3 # $Id: Config.pm,v 1.7 2006-12-01 02:24:27 price Exp $
     3# $Id: Config.pm,v 1.8 2006-12-03 18:43:40 eugene Exp $
    44
    55package PS::IPP::Config;
     
    9090}
    9191
     92
     93# select a datapath from config.site
     94sub datapath
     95{
     96    my $self = shift;           # Configuration object
     97    my $name = shift;           # datapath name
     98
     99    my $path_list = _mdLookupMD($self->{_ipprc}, 'DATAPATH'); # List of cameras
     100    my $pathname = _mdLookupStr($path_list, $name); # Filename of camera configuration
     101    croak "Unable to find camera configuration file $pathname\n" if not defined $pathname;
     102
     103    return $pathname;
     104}
     105
     106sub convert_filename
     107{
     108    my $self = shift;           # Configuration object
     109    my $name = shift;           # raw name
     110    my $base;
     111
     112    my $abspath = false;
     113
     114    # strip off file:// prefix
     115    $name =~ s|^file://||;
     116   
     117    # replace path://PATH with datapath lookup
     118    if ($name =~ m|^path://|) {
     119        ($base) = $name =~ m|^path://(.*)|;
     120        my @list = split ("/", $base);
     121        my $path = shift @list;
     122        my $realpath = $self->datapath($path);
     123        unshift @list, $realpath;
     124        $name = join ("/", @list);
     125    }
     126
     127    # if we have a relative path in the end, prepend WORKDIR
     128    unless ($name =~ m|^/|) {
     129        my $workdir = $self->workdir();
     130        if defined $workdir {
     131            $name = File::Spec->rel2abs( $name, $workdir);
     132        }
     133    }
     134
     135    return $name;
     136}
    92137
    93138# Return a rejection limit from the camera configuration
Note: See TracChangeset for help on using the changeset viewer.