- Timestamp:
- 11/02/05 19:52:18 (19 years ago)
- Location:
- trunk/soft
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/soft/ObsData/ObsData.pm
- Property cvs2svn:cvs-rev changed from 1.4 to 1.5
r23 r25 8 8 9 9 our $VERSION = 0.01; 10 11 =head1 NAME 12 13 ObsData - Main object to manage data files 14 15 =head1 SYNOPSIS 16 17 use ObsData; 18 my $conf = "configfile"; 19 my $obsdata = ObsData->new($conf); 20 21 =head1 METHODS 22 23 =head2 new($configfile) 24 25 Create a new Obsdata object from $configfile 26 27 =cut 10 28 11 29 sub new { … … 23 41 } 24 42 43 =head2 checkconfig() 44 45 Check the validity of information contains in configfile. 46 47 Notice: This test does not include the syntaxe validity 48 49 =cut 50 25 51 sub checkconfig { 26 52 my ($self) = @_; … … 28 54 my ($obs) = $g =~ /\S+\s+(.*)/; 29 55 if (!$self->{config}->SectionExists($obs)) { 30 print "E: '$obs' is listed as Obs but it does not exists\n";56 print STDERR "E: '$obs' is listed as Obs but it does not exists\n"; 31 57 next; 32 58 } … … 36 62 } 37 63 64 =head2 getvalue($section, $var, $default) 65 66 Return a value from the configuration, $default is assumed if the value is not set 67 68 =cut 69 38 70 sub getvalue { 39 71 my ($self, $section, $var, $default) = @_; 40 72 $self->{config}->val($section, $var, $default); 41 73 } 74 75 =head2 list_obs 76 77 Return the list of observatories defined in configuration 78 79 =cut 42 80 43 81 sub list_obs { … … 48 86 } 49 87 88 =head2 is_obs($obsname) 89 90 Return True if $obsname is an observatory 91 92 =cut 93 50 94 sub is_obs { 51 95 my ($self, $obs) = @_; … … 53 97 } 54 98 55 sub list_datadir { 99 =head2 list_obsdatadir($obsname) 100 101 Return a hash of data directories per data type for $obsname observatories 102 103 =cut 104 105 sub list_obsdatadir { 56 106 my ($self, $obs) = @_; 57 107 $self->is_obs($obs) or return undef; 58 map { m,^datadir/(.*),; ( $1=> $self->{config}->val($obs, $_) ) }59 grep { m,^datadir/, }108 map { m,^datadir/(.*),; ( ($1 || "") => $self->{config}->val($obs, $_) ) } 109 grep { m,^datadir/, || $_ eq 'datadir' } 60 110 $self->{config}->Parameters($obs) 61 111 } 112 113 =head2 list_typedatadir($type) 114 115 List all directories for $type data 116 117 =cut 118 119 sub list_typedatadir { 120 my ($self, $type) = @_; 121 my %dirs; 122 foreach my $obs ($self->list_obs) { 123 $dirs{$_} = 1 foreach(grep { $_ } $self->get_datadir($obs, $type)); 124 } 125 keys %dirs; 126 127 } 128 129 =head2 get_datadir($obs, $type) 130 131 Return a list of directories for $type data on $obs observatory 132 133 =cut 62 134 63 135 sub get_datadir { 64 136 my ($self, $obs, $type) = @_; 65 137 $self->is_obs($obs) or return undef; 66 $self->getvalue($obs, "datadir/$type");138 grep { defined($_) } ($self->getvalue($obs, "datadir/$type"), $self->getvalue($obs, "datadir")); 67 139 } 68 140 -
trunk/soft/ObsData/ObsData/Data.pm
- Property cvs2svn:cvs-rev changed from 1.1 to 1.2
r24 r25 11 11 obsdata => $obsdata, 12 12 datafile => $file, 13 datatype => undef, 13 14 }; 14 15 … … 23 24 my ($self) = @_; 24 25 # check if the config has all info need for proccessing 26 if(!$self->{datatype}) { 27 return 0; 28 } 29 # if ($self->{obsdata}->getvalue($self->{datatype}, ' 25 30 } 31 32 26 33 27 34 1; -
trunk/soft/ObsData/t/O-01.t
- Property cvs2svn:cvs-rev changed from 1.2 to 1.3
r23 r25 5 5 use_ok('ObsData'); 6 6 7 can_ok('ObsData', qw(list_obs list_ datadir get_datadir getvalue is_obs));7 can_ok('ObsData', qw(list_obs list_obsdatadir list_typedatadir get_datadir getvalue is_obs)); 8 8 9 9 ok(ObsData->new('testdata/obsdata-conftest'), "Can create object"); -
trunk/soft/ObsData/t/O-02.t
- Property cvs2svn:cvs-rev changed from 1.2 to 1.3
r23 r25 1 1 # $Id$ 2 2 3 use Test::More tests => 8;3 use Test::More tests => 9; 4 4 5 5 use_ok('ObsData'); … … 8 8 ok($o->getvalue('ohp', 'description'), "can get value"); 9 9 10 ok( grep { 'ohp' } $o->list_obs, "Can list observatories");10 ok(eq_set([ $o->list_obs ], [ 'ohp' ]), "Can list observatories"); 11 11 12 12 ok($o->is_obs('ohp'), "check is an obs is defined"); 13 13 ok(!$o->is_obs('NOohp'), "check is an obs is not defined"); 14 14 15 my %datadir = $o->list_datadir('ohp'); 15 { 16 my %datadir = $o->list_obsdatadir('ohp'); 16 17 ok($datadir{ozone} eq 'testdata/ohp/ozone', "Can get list of data directory"); 17 ok($o->get_datadir('ohp', 'ozone') eq 'testdata/ohp/ozone', 'Can retrive data directory'); 18 } 19 20 ok(eq_set([ $o->list_typedatadir('ozone') ], [ 'testdata/ohp/ozone', 'testdata/ohp' ]) , 'Can list data directory'); 21 ok(eq_set([ $o->get_datadir('ohp', 'ozone') ], [ 'testdata/ohp/ozone', 'testdata/ohp' ]) , 'Can retrive data directory'); -
trunk/soft/ObsData/testdata/obsdata-conftest
- Property cvs2svn:cvs-rev changed from 1.2 to 1.3
r22 r25 9 9 [ohp] 10 10 description=Observatoire de Haute Provence 11 datadir=testdata/ohp 11 12 datadir/ozone=testdata/ohp/ozone 12 13 13 14 14 [ozone] 15 15 16 [oxygene] -
trunk/soft/README
- Property cvs2svn:cvs-rev changed from 1.2 to 1.3
r11 r25 1 $Id$ 2 1 3 ObsData : Perl Libary to manage data files 2 4 3 $Id$ 5 *********** 6 * Methode * 7 *********** 8 9 - répertoire d'arrivée des données 10 - 1 répertoire par station ! 11 - lister les archives présentes 12 - filtrer les archives encore à traiter (comment identifier ?) 13 - on listes les fichiers de données contenu 14 - si une règle de traitement est applicable => applique le traitement 15 - sinon => poser le fichier dans les rejets 16 17 Besoin par archive: 18 - date de traitement 19 - fichiers data 20 - regle apliquée 21 - destination finale 22 23 [STATION] 24 source = /sources/archives 25 26 [LIDAR] 27 match = ^LIDAR.* 28 properties = ^LIDAR-([^-]*)-([^\.]*)$ date extension 29 archive_properties = ^LIDAR-([^-]*)-([^\.]*)$ date extension 30 destination = /foo/%s/name/LIDAR/ date
Note: See TracChangeset
for help on using the changeset viewer.