annotate lib/conf.pm @ 0:7c9269bded0e draft

Init repository for [downloader_bank_hmdb]
author fgiacomoni
date Tue, 14 Jan 2020 05:21:23 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
1 package conf ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
2
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
3 use strict;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
4 use warnings ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
5 use Exporter ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
6 use Carp ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
7 use Data::Dumper ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
8
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
9 use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS);
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
10
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
11 our $VERSION = "1.0" ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
12 our @ISA = qw(Exporter) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
13 our @EXPORT = qw( as_conf get_value_from_conf check_path_and_file ) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
14 our %EXPORT_TAGS = ( ALL => [qw( as_conf get_value_from_conf )] ) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
15
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
16 =head1 NAME
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
17
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
18 conf - A module for manage pfem conf file
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
19
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
20 =head1 SYNOPSIS
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
21
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
22 use conf ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
23 my $object = conf->new() ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
24
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
25 =head1 DESCRIPTION
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
26
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
27 This module does manage conf file (extract all or selected fields)
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
28
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
29 =head1 METHODS
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
30
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
31 Methods are :
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
32
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
33 =head2 METHOD new
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
34
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
35 ## Description : new
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
36 ## Input : $self
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
37 ## Ouput : bless $self ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
38 ## Usage : new() ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
39
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
40 =cut
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
41 ## START of SUB
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
42 sub new {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
43 ## Variables
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
44 my $self={};
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
45 bless($self) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
46 return $self ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
47 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
48 ### END of SUB
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
49
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
50 =head2 METHOD as_conf
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
51
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
52 ## Description : permet de creer l'object conf a partir d'un fichier de conf de type KEY=VALUE
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
53 ## Input : $file
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
54 ## Ouput : $oConf (a hash)
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
55 ## Usage : my ( $oConf ) = as_conf( $file ) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
56
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
57 =cut
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
58 ## START of SUB
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
59 sub as_conf {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
60 ## Retrieve Values
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
61 my $self = shift ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
62 my ( $file, $separator ) = @_ ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
63
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
64 # if (!defined $separator) { $separator = ';' } ## set separator to ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
65
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
66 if ( !defined $file ) { croak "Can't create object with an none defined file\n" ; }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
67
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
68 my %Conf = () ; ## Hash devant contenir l'ensemble des parametres locaux
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
69
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
70 if (-e $file) {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
71 open (CFG, "<$file") or die "Can't open $file\n" ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
72 while (<CFG>) {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
73 chomp $_ ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
74 if ( $_ =~ /^#(.*)/) { next ; }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
75 elsif ($_ =~/^(\w+?)=(.*)/) { ## ALPHANUMERIC OR UNDERSCORE ONLY FOR THE KEY AND ANYTHING ELSE FOR VALUE
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
76
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
77 my ($key, $value) = ($1, $2) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
78
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
79 if (defined $separator) {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
80 if ( $value=~/$separator/ ) { ## is a list to split
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
81 my @tmp = split(/$separator/ , $value) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
82 $Conf{$key} = \@tmp ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
83 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
84 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
85 else {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
86 $Conf{$key} = $value ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
87 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
88 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
89 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
90 close(CFG) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
91 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
92 else {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
93 croak "Can't create object with an none existing file\n" ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
94 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
95
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
96 return ( \%Conf ) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
97 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
98 ## END of SUB
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
99
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
100 =head2 METHOD as_conf_list
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
101
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
102 ## Description : permet de charger une liste txt en array
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
103 ## Input : $file
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
104 ## Output : elements
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
105 ## Usage : my ( elements ) = as_conf_list( $conf_file ) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
106
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
107 =cut
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
108 ## START of SUB
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
109 sub as_conf_list {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
110 ## Retrieve Values
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
111 my $self = shift ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
112 my ( $file ) = @_ ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
113
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
114 my @elements = () ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
115 if ( !defined $file ) { croak "Can't create object with an none defined file\n" ; }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
116
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
117 if (-e $file) {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
118 open (CFG, "<$file") or die "Can't open $file\n" ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
119 while (<CFG>) {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
120 chomp $_ ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
121 if ( $_ =~ /^#(.*)/) { next ; }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
122 elsif ($_ =~/^(.*)/) { if (defined $1) { push (@elements, $1) ; } }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
123 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
124 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
125 else {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
126 croak "Can't create object with an none existing file\n" ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
127 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
128 return(\@elements) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
129 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
130 ## END of SUB
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
131
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
132 =head2 METHOD get_value_from_conf
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
133
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
134 ## Description : permet de retourner une valeur du hash de conf a partir d'une key
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
135 ## Input : $oConf, $Key
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
136 ## Ouput : $Value
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
137 ## Usage : my ( $Value ) = get_value_from_conf( $oConf, $Key ) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
138
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
139 =cut
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
140 ## START of SUB
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
141 sub get_value_from_conf {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
142 ## Retrieve Values
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
143 my $self = shift ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
144 my ( $oConf, $Key ) = @_ ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
145
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
146 my $Value = undef ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
147
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
148 if ( defined $oConf ) {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
149 if ( defined $oConf->{$Key} ) {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
150 $Value = $oConf->{$Key} ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
151 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
152 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
153 else {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
154 croak "Can't manage value with undefined object\n" ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
155 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
156 return($Value) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
157 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
158 ## END of SUB
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
159
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
160 =head2 METHOD get_value_from_conf
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
161
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
162 ## Description : permet de retourner une valeur du hash de conf a partir d'une key
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
163 ## Input : $oConf, $Key
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
164 ## Ouput : $Value
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
165 ## Usage : my ( $Value ) = get_value_from_conf( $oConf, $Key ) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
166
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
167 =cut
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
168 ## START of SUB
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
169 sub split_value_from_conf {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
170 ## Retrieve Values
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
171 my $self = shift ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
172 my ( $oConf, $Key, $sep ) = @_ ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
173
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
174 my $value = undef ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
175 my @values = () ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
176
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
177 if ( defined $oConf ) {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
178 if ( defined $oConf->{$Key} ) {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
179 $value = $oConf->{$Key} ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
180 @values = split ( /$sep/, $value) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
181 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
182 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
183 else {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
184 croak "Can't manage value with undefined object\n" ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
185 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
186 return(\@values) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
187 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
188 ## END of SUB
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
189
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
190
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
191 =head2 METHOD check_path_and_file
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
192
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
193 ## Description : permet de verifier les path et la presence des exe decrits dans le file conf. Bloque le script en cas de probleme
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
194 ## Input : $oConfs
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
195 ## Ouput : NA
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
196 ## Usage : &get_value_from_conf( $oConf ) ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
197
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
198 =cut
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
199 ## START of SUB
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
200 sub check_path_and_file {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
201
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
202 my $self = shift ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
203 my ( $oConfs ) = @_ ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
204
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
205 foreach my $conf ( keys %{ $oConfs } ) {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
206 if ( $conf =~ /^FILE/ ) {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
207 if ( -e $oConfs->{$conf} ) {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
208 if ( -s $oConfs->{$conf} ) { next ; }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
209 else { carp "[Warning] : The size of file $oConfs->{$conf} is null\n" ; }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
210 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
211 else {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
212 carp "[Warning] : The file $oConfs->{$conf} doesn't exist\n" ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
213 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
214 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
215 elsif ( $conf =~ /^PATH/ ) {
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
216 if ( -d $oConfs->{$conf} ) { next ; }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
217 else { carp "[Warning] : The dir $oConfs->{$conf} doesn't exist\n" ; }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
218 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
219 else { next ; }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
220 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
221 return ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
222 }
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
223 ## END of SUB
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
224
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
225 1 ;
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
226
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
227
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
228 __END__
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
229
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
230 =head1 SUPPORT
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
231
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
232 You can find documentation for this module with the perldoc command.
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
233
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
234 perldoc conf.pm
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
235
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
236
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
237 =head1 Exports
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
238
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
239 =over 4
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
240
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
241 =item :ALL is as_conf get_value_from_conf
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
242
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
243 =back
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
244
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
245 =head1 AUTHOR
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
246
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
247 Franck Giacomoni E<lt>franck.giacomoni@clermont.inra.frE<gt>
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
248
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
249 =head1 LICENSE
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
250
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
251 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
252
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
253 =head1 VERSION
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
254
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
255 version 1 : 10 / 02 / 2013
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
256
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
257 version 2 : 15 / 12 / 2015
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
258
7c9269bded0e Init repository for [downloader_bank_hmdb]
fgiacomoni
parents:
diff changeset
259 =cut