Changeset 6616
- Timestamp:
- Mar 16, 2006, 3:18:48 PM (20 years ago)
- Location:
- trunk/DataStore/lib/DataStore
- Files:
-
- 2 edited
-
File/Parser.pm (modified) (4 diffs)
-
FileSet/Parser.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataStore/lib/DataStore/File/Parser.pm
r6609 r6616 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: Parser.pm,v 1. 9 2006-03-16 22:00:29jhoblitt Exp $3 # $Id: Parser.pm,v 1.10 2006-03-17 01:18:48 jhoblitt Exp $ 4 4 5 5 package DataStore::File::Parser; … … 15 15 use Carp qw( carp ); 16 16 use Data::Validate::URI qw( is_uri ); 17 use DataStore::Utils qw( $STD_FIELD $BYTE_FIELD $MD5_FIELD %KNOWN_FILE_TYPES ); 17 18 use DataStore::File; 18 19 use 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 );24 20 25 21 __PACKAGE__->mk_ro_accessors(qw(base_uri)); … … 163 159 # validate format of fileid and type 164 160 foreach my $field ($fileid, $type) { 165 unless ($field =~ $ std_field) {161 unless ($field =~ $STD_FIELD) { 166 162 carp "line $lineno: field $field:" 167 . " does not conform to $ std_field: $line";163 . " does not conform to $STD_FIELD: $line"; 168 164 next LINE; 169 165 } … … 171 167 172 168 # validate format of bytes 173 unless ($bytes =~ $ byte_field) {169 unless ($bytes =~ $BYTE_FIELD) { 174 170 carp "line $lineno: field $bytes:" 175 . " does not conform to $ byte_field: $line";171 . " does not conform to $BYTE_FIELD: $line"; 176 172 next LINE; 177 173 } 178 174 179 175 # validate format of md5sum, hex encoded 180 unless ($md5sum =~ $ md5_field) {176 unless ($md5sum =~ $MD5_FIELD) { 181 177 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"; 183 184 next LINE; 184 185 } -
trunk/DataStore/lib/DataStore/FileSet/Parser.pm
r6609 r6616 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: Parser.pm,v 1.1 1 2006-03-16 22:00:29jhoblitt Exp $3 # $Id: Parser.pm,v 1.12 2006-03-17 01:18:48 jhoblitt Exp $ 4 4 5 5 package DataStore::FileSet::Parser; … … 16 16 use Data::Validate::URI qw( is_uri ); 17 17 use DataStore::FileSet; 18 use DataStore::Utils qw( $STD_FIELD $TIME_FIELD %KNOWN_FILESET_TYPES ); 18 19 use 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 );23 20 24 21 __PACKAGE__->mk_ro_accessors(qw(base_uri)); … … 161 158 # validate format of fileset and type 162 159 foreach my $field ($fileset, $type) { 163 unless ($field =~ $ std_field) {160 unless ($field =~ $STD_FIELD) { 164 161 carp "line $lineno: field $field:" 165 . " does not conform to $ std_field: $line";162 . " does not conform to $STD_FIELD: $line"; 166 163 next LINE; 167 164 } … … 169 166 170 167 # validate format of datetime 171 unless ($datetime =~ $ time_field) {168 unless ($datetime =~ $TIME_FIELD) { 172 169 carp "line $lineno: field $datetime:" 173 . " does not conform to $ time_field";170 . " does not conform to $TIME_FIELD"; 174 171 next LINE; 175 172 } 176 173 177 unless (exists $ known_types{$type}) {174 unless (exists $KNOWN_FILESET_TYPES{$type}) { 178 175 carp "line $lineno: type $type unknown: $line"; 179 176 next LINE;
Note:
See TracChangeset
for help on using the changeset viewer.
