Changeset 2176 in ProjectBuilder for devel/pb-modules/lib/ProjectBuilder/Conf.pm
- Timestamp:
- Feb 14, 2017, 7:17:12 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Conf.pm
r2154 r2176 19 19 use ProjectBuilder::Base; 20 20 use ProjectBuilder::Version; 21 #use YAML; 21 22 22 23 # Inherit from the "Exporter" module which handles exporting functions. … … 123 124 my $cf = shift; 124 125 my $lh = shift; 126 my $confver = "0.14"; 125 127 126 128 # Read the content of the config file and cache it in the %h hash then available for queries 127 open(CONF,$cf) || confess "Unable to open $cf"; 128 while(<CONF>) { 129 next if (/^#/); 130 if (/^\s*([A-z0-9-_.]+)\s+([[A-z0-9-_.\?\[\]\*\+\\]+)\s*=\s*(.*)$/) { 131 pb_log(3,"DEBUG: 1:$1 2:$2 3:$3\n"); 132 $lh->{$1}->{$2}=$3; 129 if ($confver < 0.15) { 130 open(CONF,$cf) || confess "Unable to open $cf"; 131 # This is the original conf file format for versions up to 0.14 132 while(<CONF>) { 133 next if (/^#/); 134 if (/^\s*([A-z0-9-_.]+)\s+([[A-z0-9-_.\?\[\]\*\+\\]+)\s*=\s*(.*)$/) { 135 pb_log(3,"DEBUG: 1:$1 2:$2 3:$3\n"); 136 $lh->{$1}->{$2}=$3; 137 } 133 138 } 134 } 135 close(CONF); 139 close(CONF); 140 } else { 141 $lh = LoadFile($cf); 142 } 136 143 return($lh); 137 144 } … … 244 251 my $conffile = shift; 245 252 my $h = shift; 253 my $confver = "0.14"; 246 254 247 255 confess "No configuration file defined to write into !" if (not defined $conffile); … … 249 257 open(CONF,"> $conffile") || confess "Unable to write into $conffile"; 250 258 251 foreach my $p (sort keys %$h) { 252 my $j = $h->{$p}; 253 foreach my $k (sort keys %$j) { 254 print CONF "$p $k = $j->{$k}\n"; 259 if ($confver < 0.15) { 260 # This is the original conf file format for versions up to 0.14 261 foreach my $p (sort keys %$h) { 262 my $j = $h->{$p}; 263 foreach my $k (sort keys %$j) { 264 print CONF "$p $k = $j->{$k}\n"; 265 } 255 266 } 267 } else { 268 # This is the new YAML format 269 print CONF Dump($h); 256 270 } 257 271 close(CONF);
Note:
See TracChangeset
for help on using the changeset viewer.