IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6616


Ignore:
Timestamp:
Mar 16, 2006, 3:18:48 PM (20 years ago)
Author:
jhoblitt
Message:

change DataStore::FileSet::Parser to use DataStore::Utils
change DataStore::File::Parser to use DataStore::Utils

Location:
trunk/DataStore/lib/DataStore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataStore/lib/DataStore/File/Parser.pm

    r6609 r6616  
    11# Copyright (C) 2006  Joshua Hoblitt
    22#
    3 # $Id: Parser.pm,v 1.9 2006-03-16 22:00:29 jhoblitt Exp $
     3# $Id: Parser.pm,v 1.10 2006-03-17 01:18:48 jhoblitt Exp $
    44
    55package DataStore::File::Parser;
     
    1515use Carp qw( carp );
    1616use Data::Validate::URI qw( is_uri );
     17use DataStore::Utils qw( $STD_FIELD $BYTE_FIELD $MD5_FIELD %KNOWN_FILE_TYPES );
    1718use DataStore::File;
    1819use Params::Validate qw( validate validate_pos SCALAR );
    19 
    20 my $std_field = qr/^[a-z0-9-_.]+$/;
    21 my $byte_field = qr/^\d+$/;
    22 my $md5_field = qr/^[0-9a-f]{32}$/;
    23 my %known_types = map { $_ => 1 } qw( chip );
    2420
    2521__PACKAGE__->mk_ro_accessors(qw(base_uri));
     
    163159        # validate format of fileid and type
    164160        foreach my $field ($fileid, $type) {
    165             unless ($field =~ $std_field) {
     161            unless ($field =~ $STD_FIELD) {
    166162                carp "line $lineno: field $field:"
    167                    . " does not conform to $std_field: $line";
     163                   . " does not conform to $STD_FIELD: $line";
    168164                next LINE;
    169165            }
     
    171167
    172168        # validate format of bytes
    173         unless ($bytes =~ $byte_field) {
     169        unless ($bytes =~ $BYTE_FIELD) {
    174170            carp "line $lineno: field $bytes:"
    175                . " does not conform to $byte_field: $line";
     171               . " does not conform to $BYTE_FIELD: $line";
    176172            next LINE;
    177173        }
    178174
    179175        # validate format of md5sum, hex encoded
    180         unless ($md5sum =~ $md5_field) {
     176        unless ($md5sum =~ $MD5_FIELD) {
    181177            carp "line $lineno: field $md5sum:"
    182                . " does not conform to $md5_field: $line";
     178               . " does not conform to $MD5_FIELD: $line";
     179            next LINE;
     180        }
     181
     182        unless (exists $KNOWN_FILE_TYPES{$type}) {
     183            carp "line $lineno: type $type unknown: $line";
    183184            next LINE;
    184185        }
  • trunk/DataStore/lib/DataStore/FileSet/Parser.pm

    r6609 r6616  
    11# Copyright (C) 2006  Joshua Hoblitt
    22#
    3 # $Id: Parser.pm,v 1.11 2006-03-16 22:00:29 jhoblitt Exp $
     3# $Id: Parser.pm,v 1.12 2006-03-17 01:18:48 jhoblitt Exp $
    44
    55package DataStore::FileSet::Parser;
     
    1616use Data::Validate::URI qw( is_uri );
    1717use DataStore::FileSet;
     18use DataStore::Utils qw( $STD_FIELD $TIME_FIELD %KNOWN_FILESET_TYPES );
    1819use Params::Validate qw( validate validate_pos SCALAR);
    19 
    20 my $time_field = qr/^ (\d{4})-(\d\d)-(\d\d) T (\d\d):(\d\d):(\d\d) Z $/x;
    21 my $std_field = qr/^[a-z0-9-_.]+$/;
    22 my %known_types = map { $_ => 1 } qw( object domeflat skyflat bias dark );
    2320
    2421__PACKAGE__->mk_ro_accessors(qw(base_uri));
     
    161158        # validate format of fileset and type
    162159        foreach my $field ($fileset, $type) {
    163             unless ($field =~ $std_field) {
     160            unless ($field =~ $STD_FIELD) {
    164161                carp "line $lineno: field $field:"
    165                    . " does not conform to $std_field: $line";
     162                   . " does not conform to $STD_FIELD: $line";
    166163                next LINE;
    167164            }
     
    169166
    170167        # validate format of datetime
    171         unless ($datetime =~ $time_field) {
     168        unless ($datetime =~ $TIME_FIELD) {
    172169            carp "line $lineno: field $datetime:"
    173                . " does not conform to $time_field";
     170               . " does not conform to $TIME_FIELD";
    174171            next LINE;
    175172        }
    176173
    177         unless (exists $known_types{$type}) {
     174        unless (exists $KNOWN_FILESET_TYPES{$type}) {
    178175            carp "line $lineno: type $type unknown: $line";
    179176            next LINE;
Note: See TracChangeset for help on using the changeset viewer.