« lib/App/SeismicUnixGui/misc/sunix_pl.pm
↑ Summary
lib/App/SeismicUnixGui/sunix/statsMath/sumax.pm »
| 1 | package App::SeismicUnixGui::misc::su_param; | ||
| 2 | |||
| 3 | =head1 DOCUMENTATION | ||
| 4 | |||
| 5 | |||
| 6 | =head2 SYNOPSIS | ||
| 7 | |||
| 8 | PERL PERL PROGRAM NAME: su_param | ||
| 9 | AUTHOR: Juan Lorenzo | ||
| 10 | DATE: May 5 2018 | ||
| 11 | |||
| 12 | DESCRIPTION V 0.2 | ||
| 13 | |||
| 14 | |||
| 15 | BASED ON: 0.1 | ||
| 16 | |||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | =head2 USE | ||
| 21 | |||
| 22 | =head3 NOTES | ||
| 23 | |||
| 24 | =head4 Examples | ||
| 25 | |||
| 26 | |||
| 27 | =head2 CHANGES and their DATES | ||
| 28 | May 5 2018 looks for configurations | ||
| 29 | first in the local directory | ||
| 30 | then in the default configuration | ||
| 31 | directory /usr/local/pl/big_streams/config | ||
| 32 | |||
| 33 | V 0.0.3 June 2022 reference to L_SU_local_user_constants | ||
| 34 | removed | ||
| 35 | L_SU_local_user_constants may create cirularity | ||
| 36 | |||
| 37 | =cut | ||
| 38 | |||
| 39 | =head2 | ||
| 40 | |||
| 41 | parameters for seismic unix programs | ||
| 42 | both macros and individual modules | ||
| 43 | |||
| 44 | =cut | ||
| 45 | |||
| 46 | use Moose; | ||
| 47 | our $VERSION = '0.0.3'; | ||
| 48 | |||
| 49 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 50 | use aliased 'App::SeismicUnixGui::misc::L_SU_path'; | ||
| 51 | use aliased 'App::SeismicUnixGui::misc::developer'; | ||
| 52 | use aliased 'App::SeismicUnixGui::misc::readfiles'; | ||
| 53 | use Shell qw(echo); | ||
| 54 | |||
| 55 | =head2 Instantiation | ||
| 56 | |||
| 57 | =cut | ||
| 58 | |||
| 59 | my $L_SU_global_constants = L_SU_global_constants->new(); | ||
| 60 | my $L_SU_path = L_SU_path->new(); | ||
| 61 | |||
| 62 | my $HOME = ` echo \$HOME`; | ||
| 63 | chomp $HOME; | ||
| 64 | |||
| 65 | # magic number TODO | ||
| 66 | my $var = $L_SU_global_constants->var(); | ||
| 67 | my $ACTIVE_PROJECT = $HOME . $var->{_ACTIVE_PROJECT}; | ||
| 68 | my $user_active_project_path = $ACTIVE_PROJECT; | ||
| 69 | |||
| 70 | my $true = $var->{_true}; | ||
| 71 | my $false = $var->{_false}; | ||
| 72 | my $empty_string = $var->{_empty_string}; | ||
| 73 | |||
| 74 | my $flow_type_href = $L_SU_global_constants->flow_type_href(); | ||
| 75 | |||
| 76 | my $su_param = { | ||
| 77 | _flow_type => '', | ||
| 78 | _name_space => 'name_space', | ||
| 79 | _local_path => '', | ||
| 80 | _path => '', | ||
| 81 | _sub_category_directory => '', | ||
| 82 | _program_config => '', | ||
| 83 | _program_sref => '', | ||
| 84 | _user_active_project_path => $user_active_project_path, | ||
| 85 | _names_aref => '', | ||
| 86 | }; | ||
| 87 | |||
| 88 | sub set_flow_type { | ||
| 89 | |||
| 90 | my ( $self, $flow_type ) = @_; | ||
| 91 | |||
| 92 | if ( defined $flow_type | ||
| 93 | && $flow_type ne $empty_string ) | ||
| 94 | { | ||
| 95 | |||
| 96 | $su_param->{_flow_type} = $flow_type; | ||
| 97 | |||
| 98 | # print("su_param, set_flow_type ,flow_type=$su_param->{_flow_type}\n"); | ||
| 99 | |||
| 100 | } | ||
| 101 | else { | ||
| 102 | print("su_param, set_flow_type , missing value\n"); | ||
| 103 | } | ||
| 104 | |||
| 105 | return (); | ||
| 106 | } | ||
| 107 | |||
| 108 | sub _get_global_lib { | ||
| 109 | |||
| 110 | my ($elf) = @_; | ||
| 111 | |||
| 112 | my $global_libs_href = $L_SU_global_constants->global_libs(); | ||
| 113 | |||
| 114 | if ( defined $global_libs_href | ||
| 115 | && $global_libs_href ne $empty_string | ||
| 116 | && defined $su_param->{_flow_type} ) | ||
| 117 | { | ||
| 118 | |||
| 119 | my $result; | ||
| 120 | |||
| 121 | if ( | ||
| 122 | $su_param->{_flow_type} eq $flow_type_href->{_pre_built_superflow} ) | ||
| 123 | { | ||
| 124 | |||
| 125 | $su_param->{_lib_path} = $global_libs_href->{_param}; | ||
| 126 | |||
| 127 | # print("su_param, _get_global_lib,lib_path= $su_param->{_lib_path}\n"); | ||
| 128 | $result = $su_param->{_lib_path}; | ||
| 129 | return ($result); | ||
| 130 | |||
| 131 | } | ||
| 132 | elsif ( $su_param->{_flow_type} eq $flow_type_href->{_user_built} ) { | ||
| 133 | |||
| 134 | $su_param->{_lib_path} = $global_libs_href->{_param}; | ||
| 135 | |||
| 136 | # print("su_param, _get_global_lib, lib_path: $su_param->{_lib_path}\n"); | ||
| 137 | $result = $su_param->{_lib_path}; | ||
| 138 | return ($result); | ||
| 139 | |||
| 140 | } | ||
| 141 | else { | ||
| 142 | print("su_param, _get_global_lib, unexpected value\n"); | ||
| 143 | return (); | ||
| 144 | } | ||
| 145 | |||
| 146 | } | ||
| 147 | else { | ||
| 148 | print("su_param, _get_global_lib, missing value\n"); | ||
| 149 | } | ||
| 150 | |||
| 151 | return (); | ||
| 152 | |||
| 153 | } | ||
| 154 | |||
| 155 | sub _set_sub_category_directory { | ||
| 156 | |||
| 157 | my ($sub_category_directory) = @_; | ||
| 158 | |||
| 159 | if ( defined $sub_category_directory | ||
| 160 | && $sub_category_directory ne $empty_string ) | ||
| 161 | { | ||
| 162 | |||
| 163 | $su_param->{_sub_category_directory} = $sub_category_directory; | ||
| 164 | |||
| 165 | } | ||
| 166 | else { | ||
| 167 | print("su_param, _set_sub_category_directory, missing value\n"); | ||
| 168 | print( | ||
| 169 | "su_param, _set_sub_category_directory, $sub_category_directory\n"); | ||
| 170 | } | ||
| 171 | |||
| 172 | return (); | ||
| 173 | } | ||
| 174 | |||
| 175 | sub _set_path { | ||
| 176 | |||
| 177 | my ($path) = @_; | ||
| 178 | |||
| 179 | if ( length $path | ||
| 180 | && $path ne $empty_string ) | ||
| 181 | { | ||
| 182 | |||
| 183 | $su_param->{_path} = $path; | ||
| 184 | |||
| 185 | # print("su_param, _set_path, path=$path\n"); | ||
| 186 | |||
| 187 | } | ||
| 188 | else { | ||
| 189 | print("su_param, _set_path, missing value\n"); | ||
| 190 | } | ||
| 191 | |||
| 192 | return (); | ||
| 193 | } | ||
| 194 | |||
| 195 | sub _set_program_sref { | ||
| 196 | |||
| 197 | my ($program_sref) = @_; | ||
| 198 | |||
| 199 | if ( defined $$program_sref | ||
| 200 | && $$program_sref ne $empty_string ) | ||
| 201 | { | ||
| 202 | |||
| 203 | $su_param->{_program_sref} = $program_sref; | ||
| 204 | |||
| 205 | } | ||
| 206 | else { | ||
| 207 | print("su_param, _set_program_config, missing value\n"); | ||
| 208 | } | ||
| 209 | |||
| 210 | return (); | ||
| 211 | } | ||
| 212 | |||
| 213 | sub _get_program_config { | ||
| 214 | |||
| 215 | my ($path) = @_; | ||
| 216 | |||
| 217 | my ( $program_config, $sub_category_directory, $program_sref ); | ||
| 218 | |||
| 219 | $path = $su_param->{_path}; | ||
| 220 | $sub_category_directory = $su_param->{_sub_category_directory}; | ||
| 221 | $program_sref = $su_param->{_program_sref}; | ||
| 222 | |||
| 223 | # print("su_param, get_program_config, path = $path\n"); | ||
| 224 | # print( | ||
| 225 | #"su_param, get_program_config, sub_category_directory = $sub_category_directory\n" | ||
| 226 | # ); | ||
| 227 | # print("su_param, get_program_config, program_sref= $$program_sref\n"); | ||
| 228 | |||
| 229 | if ( defined $path | ||
| 230 | && $path ne $empty_string | ||
| 231 | && defined $sub_category_directory | ||
| 232 | && $sub_category_directory ne $empty_string | ||
| 233 | && defined $$program_sref | ||
| 234 | && $$program_sref ne $empty_string ) | ||
| 235 | { | ||
| 236 | |||
| 237 | $program_config = | ||
| 238 | $path . '/' | ||
| 239 | . $sub_category_directory . '/' | ||
| 240 | . $$program_sref | ||
| 241 | . '.config'; | ||
| 242 | |||
| 243 | $su_param->{_program_config} = $program_config; | ||
| 244 | my $result = $program_config; | ||
| 245 | return ($result); | ||
| 246 | |||
| 247 | } | ||
| 248 | else { | ||
| 249 | print("su_param, _set_program_config, missing value\n"); | ||
| 250 | return (); | ||
| 251 | } | ||
| 252 | |||
| 253 | } | ||
| 254 | |||
| 255 | =head2 sub get | ||
| 256 | |||
| 257 | returns values | ||
| 258 | as an array | ||
| 259 | input is a scalar reference | ||
| 260 | used both by superflow/pre-built flows and seismic unix configuration files | ||
| 261 | |||
| 262 | Read a default specification file | ||
| 263 | If default specification file# does not exist locally | ||
| 264 | then look in the user's configuration directory | ||
| 265 | ~HOME/.L_SU/configuration/active and if that does not exist | ||
| 266 | then use the default one defined under global libs | ||
| 267 | |||
| 268 | Debug with | ||
| 269 | print ("this is $this\n"); | ||
| 270 | print ("self is $self,program is $program\n"); | ||
| 271 | |||
| 272 | Changing the namespace variables to lower | ||
| 273 | case is not a general solution because | ||
| 274 | original variables can have mixed upper and lower | ||
| 275 | case names | ||
| 276 | |||
| 277 | DEPRECATED: | ||
| 278 | Older versions may use Config::Simple | ||
| 279 | my $a = Config::Simple->import_from($this,'Z'); | ||
| 280 | foreach my $key ( keys %Z:: ) | ||
| 281 | { | ||
| 282 | my $x = lc $key; | ||
| 283 | print "key is $x\n"; | ||
| 284 | print "$cfg->param($key)\n"; | ||
| 285 | } | ||
| 286 | |||
| 287 | |||
| 288 | =cut | ||
| 289 | |||
| 290 | sub get { | ||
| 291 | |||
| 292 | my ( $self, $program_sref ) = @_; | ||
| 293 | if ( defined $program_sref | ||
| 294 | && ( defined $su_param->{_flow_type} ) | ||
| 295 | && ( $su_param->{_flow_type} ne $empty_string ) ) | ||
| 296 | { | ||
| 297 | |||
| 298 | my (@CFG); | ||
| 299 | my ( $length, $names_aref, $values_aref ); | ||
| 300 | my ( $i, $j, $program_config, $path ); | ||
| 301 | my $sub_category_directory; | ||
| 302 | |||
| 303 | my $read = readfiles->new(); | ||
| 304 | my $developer = developer->new(); | ||
| 305 | |||
| 306 | $developer->set_program_name($$program_sref); | ||
| 307 | $developer->set_flow_type( $su_param->{_flow_type} ); | ||
| 308 | _set_program_sref($program_sref); | ||
| 309 | |||
| 310 | # reset the following tests to 0 (false) | ||
| 311 | my $local_config_exists = _check4local_config($program_sref); | ||
| 312 | my $user_active_project_path_exists = _check4user_config($program_sref); | ||
| 313 | |||
| 314 | # print("B. su_param, get, local_config_exists: $local_config_exists\n"); | ||
| 315 | # print( | ||
| 316 | #"C. su_param, get,user_active_project_path_exists: $user_active_project_path_exists\n" | ||
| 317 | # ); | ||
| 318 | |||
| 319 | if ( | ||
| 320 | $su_param->{_flow_type} eq $flow_type_href->{_pre_built_superflow} ) | ||
| 321 | { | ||
| 322 | |||
| 323 | if ($local_config_exists) { | ||
| 324 | |||
| 325 | use Module::Refresh; # reload updated module | ||
| 326 | my $refresher = Module::Refresh->new; | ||
| 327 | |||
| 328 | # CASE 1A: If progam_sref = a pre-built superflow | ||
| 329 | # e.g., tools like Sseg2su.config | ||
| 330 | # but not with Project.config | ||
| 331 | |||
| 332 | # my $module_spec = $$program_sref . '_spec'; | ||
| 333 | # my $module_spec_pm = $module_spec . '.pm'; | ||
| 334 | # | ||
| 335 | # $L_SU_global_constants->set_file_name($module_spec_pm); | ||
| 336 | # my $spec_path = $L_SU_global_constants->get_path4spec_file(); | ||
| 337 | # my $pathNmodule_pm = $spec_path . '/' . $module_spec_pm; | ||
| 338 | |||
| 339 | $L_SU_path->set_program_name($$program_sref); | ||
| 340 | |||
| 341 | my $pathNmodule_spec_w_slash_pm = | ||
| 342 | $L_SU_path->get_pathNmodule_spec_w_slash_pm(); | ||
| 343 | my $pathNmodule_spec_w_colon = | ||
| 344 | $L_SU_path->get_pathNmodule_spec_w_colon(); | ||
| 345 | $refresher->refresh_module($pathNmodule_spec_w_slash_pm); | ||
| 346 | |||
| 347 | # INSTANTIATE | ||
| 348 | my $package = $pathNmodule_spec_w_colon->new(); | ||
| 349 | |||
| 350 | # my $package = $module_spec->new; | ||
| 351 | |||
| 352 | # collect specifications of output directory | ||
| 353 | # from a program_spec.pm module | ||
| 354 | my $specs_h = $package->variables(); | ||
| 355 | my $CONFIG = $specs_h->{_CONFIG}; | ||
| 356 | |||
| 357 | $su_param->{_local_path} = $CONFIG; | ||
| 358 | $path = $su_param->{_local_path}; | ||
| 359 | $sub_category_directory = '.'; | ||
| 360 | my $local_path = $su_param->{_local_path}; | ||
| 361 | my $sub_category_directory = | ||
| 362 | $developer->get_program_sub_category(); | ||
| 363 | |||
| 364 | # print("1.1 su_param,get,local configuration files exists\n"); | ||
| 365 | # print("1.2 su_param,get,local_path:$CONFIG \n"); | ||
| 366 | # print("1.3 su_param,get,sub_category_directory=$sub_category_directory\n"); | ||
| 367 | |||
| 368 | } | ||
| 369 | elsif ($user_active_project_path_exists) { | ||
| 370 | |||
| 371 | # su_param, missing either program_sref CASE 1B: | ||
| 372 | # If progam_sref= Project | ||
| 373 | # and ONLY applies to ./L_SU/configuration/active/Project.config | ||
| 374 | $path = $su_param->{_user_active_project_path}; | ||
| 375 | $sub_category_directory = '.'; | ||
| 376 | |||
| 377 | # print("CASE 1B su_param,get,user_active_project_path_exists= $user_active_project_path_exists\n"); | ||
| 378 | # print("1B su_param,get,active path is now $su_param->{_user_active_project_path} \n"); | ||
| 379 | |||
| 380 | } | ||
| 381 | elsif ( not $local_config_exists ) { | ||
| 382 | |||
| 383 | # CASE 1C: for previously unused pre-built superflow | ||
| 384 | $path = _get_global_lib(); | ||
| 385 | $sub_category_directory = | ||
| 386 | $developer->get_program_sub_category(); | ||
| 387 | |||
| 388 | # print("1C su_param,get,using global lib: path is $path\n"); | ||
| 389 | } | ||
| 390 | |||
| 391 | } | ||
| 392 | elsif ( $su_param->{_flow_type} eq $flow_type_href->{_user_built} ) { | ||
| 393 | |||
| 394 | # CASE 2A: for use of sunix programs in user_built_flows | ||
| 395 | $path = _get_global_lib(); | ||
| 396 | |||
| 397 | # print("CASE 2.A su_param,get,using global lib: path for sunix programs is $path\n"); | ||
| 398 | $sub_category_directory = $developer->get_program_sub_category(); | ||
| 399 | |||
| 400 | # print("2.A su_param,get,using sub_category_directory: for sunix programs is $sub_category_directory\n"); | ||
| 401 | |||
| 402 | } | ||
| 403 | else { | ||
| 404 | print("su_param,get,unexpected\n"); | ||
| 405 | |||
| 406 | } | ||
| 407 | |||
| 408 | # share local variables with the package namespace | ||
| 409 | _set_path($path); | ||
| 410 | _set_sub_category_directory($sub_category_directory); | ||
| 411 | |||
| 412 | $program_config = _get_program_config(); | ||
| 413 | |||
| 414 | # print("su_param, get,configuration file to read=$program_config\n"); | ||
| 415 | |||
| 416 | ( $names_aref, $values_aref ) = $read->configs($program_config); | ||
| 417 | $su_param->{_names_aref} = $names_aref; | ||
| 418 | $length = scalar @$names_aref; | ||
| 419 | |||
| 420 | # print("su_param,get:we have $length pairs\n\n"); | ||
| 421 | for ( $i = 0, $j = 0 ; $i < $length ; $i++, $j = $j + 2 ) { | ||
| 422 | |||
| 423 | $CFG[$j] = $$names_aref[$i]; | ||
| 424 | $CFG[ ( $j + 1 ) ] = $$values_aref[$i]; | ||
| 425 | |||
| 426 | # print("su_param,get,values:--$CFG[$j+1]--\n"); | ||
| 427 | } | ||
| 428 | |||
| 429 | return ( \@CFG ); | ||
| 430 | |||
| 431 | } | ||
| 432 | else { | ||
| 433 | print("su_param, missing either program_sref or flow type\n"); | ||
| 434 | print("program_sref: $program_sref\n"); | ||
| 435 | print("su_param->{_flow_type}: $su_param->{_flow_type}\n"); | ||
| 436 | } | ||
| 437 | } | ||
| 438 | |||
| 439 | =head2 sub _check4local_config | ||
| 440 | |||
| 441 | needs name_sref | ||
| 442 | |||
| 443 | CASE for any type of flow | ||
| 444 | big streams/superflows or for | ||
| 445 | or sunix programs in user-built flows | ||
| 446 | Check for local versions of the configuration files in PL_SEISMIC | ||
| 447 | and also look in specified _CONFIG folder | ||
| 448 | _CONFIG folder is defined as PL_SEISMIC for all but | ||
| 449 | pre-built big streams/superflows (e.g., immodpg) | ||
| 450 | |||
| 451 | (For pre-built big streams, look at program_spec to find | ||
| 452 | the definition for _CONFIG) | ||
| 453 | |||
| 454 | # my $a = $package->variables(); | ||
| 455 | # foreach my $key (sort keys %$a) { | ||
| 456 | # print (" su_param,_check4local_config, , key is $key, value is $a->{$key}\n"); | ||
| 457 | # } | ||
| 458 | # my $ans= $a->{_CONFIG}; | ||
| 459 | # print("2. su_param,_check4local_config,package=$ans\n"); | ||
| 460 | |||
| 461 | =cut | ||
| 462 | |||
| 463 | sub _check4local_config { | ||
| 464 | |||
| 465 | my ($name_sref) = @_; | ||
| 466 | |||
| 467 | my $ans = $false; | ||
| 468 | |||
| 469 | if ( length $name_sref | ||
| 470 | && $name_sref ne $empty_string ) | ||
| 471 | { | ||
| 472 | my $program_name = $$name_sref; | ||
| 473 | $L_SU_path->set_program_name($program_name); | ||
| 474 | |||
| 475 | my $pathNmodule_spec_w_slash_pm = | ||
| 476 | $L_SU_path->get_pathNmodule_spec_w_slash_pm(); | ||
| 477 | my $pathNmodule_spec_w_colon = | ||
| 478 | $L_SU_path->get_pathNmodule_spec_w_colon(); | ||
| 479 | |||
| 480 | # print("1. su_param,_get_suffix_aref, prog_name: $pathNmodule_spec_w_slash_pm\n"); | ||
| 481 | # print("1. _get_suffix_aref, prog_name: $colon_pathNmodule_spec\n"); | ||
| 482 | |||
| 483 | if ( length $pathNmodule_spec_w_slash_pm ) { | ||
| 484 | |||
| 485 | require $pathNmodule_spec_w_slash_pm; | ||
| 486 | |||
| 487 | # INSTANTIATE | ||
| 488 | my $package = $pathNmodule_spec_w_colon->new(); | ||
| 489 | |||
| 490 | # collect specifications of output directory | ||
| 491 | # from a program_spec.pm module | ||
| 492 | my $specs_h = $package->variables(); | ||
| 493 | my $CONFIG = $specs_h->{_CONFIG}; | ||
| 494 | |||
| 495 | # print("3. su_param,_check4local_config, CONFIG=$CONFIG \n"); | ||
| 496 | my $prog_name_config = $CONFIG . '/' . $$name_sref . '.config'; | ||
| 497 | |||
| 498 | # print( | ||
| 499 | #"su_param,_check4local_config,prog_name_config =$prog_name_config\n" | ||
| 500 | # ); | ||
| 501 | if ( -e ($prog_name_config) ) { | ||
| 502 | |||
| 503 | # print( | ||
| 504 | #"su_param,_check4local_config,found: $prog_name_config. Using local configuration file\n" | ||
| 505 | # ); | ||
| 506 | $ans = $true; | ||
| 507 | |||
| 508 | } | ||
| 509 | else { | ||
| 510 | $ans = $false; | ||
| 511 | |||
| 512 | # print("su_param,_check4local_config, $prog_name_config not found\n") | ||
| 513 | } | ||
| 514 | } # module is found | ||
| 515 | } | ||
| 516 | else { | ||
| 517 | print("su_param,_check4local_config, missing name_sref \n"); | ||
| 518 | $ans = $false; | ||
| 519 | } | ||
| 520 | return ($ans); | ||
| 521 | } | ||
| 522 | |||
| 523 | =head2 sub _check4user_config | ||
| 524 | |||
| 525 | check for versions of the configuration files | ||
| 526 | in the user's configuration directory: | ||
| 527 | .L_SU/configuration/active | ||
| 528 | only needed for Project.config | ||
| 529 | e.g., not for Sseg2su | ||
| 530 | |||
| 531 | =cut | ||
| 532 | |||
| 533 | sub _check4user_config { | ||
| 534 | |||
| 535 | my ($name_sref) = @_; | ||
| 536 | |||
| 537 | my $ans = $false; | ||
| 538 | |||
| 539 | if ( length $ACTIVE_PROJECT | ||
| 540 | and length $name_sref ) | ||
| 541 | { | ||
| 542 | |||
| 543 | if ( -e ( $ACTIVE_PROJECT . '/' . $$name_sref . '.config' ) ) { | ||
| 544 | $ans = $true; | ||
| 545 | } | ||
| 546 | else { | ||
| 547 | $ans = $false; | ||
| 548 | |||
| 549 | # print( | ||
| 550 | # "su_param,_check4user_config, ACTIVE_PROJECT=$ACTIVE_PROJECT\n" | ||
| 551 | # ); | ||
| 552 | # print("su_param,_check4user_config, name =$$name_sref\n"); | ||
| 553 | # print( | ||
| 554 | # "su_param,_check4user_config,$$name_sref not found. \n | ||
| 555 | # Going forward will use default (GLOBAL LIBS) configuration file\n" | ||
| 556 | # ); | ||
| 557 | # print( | ||
| 558 | #"su_param,_check4user_config,$$name_sref.config found, Using user configuration file\n" | ||
| 559 | # ); | ||
| 560 | # print("su_param,_check4user_config=$ans\n"); | ||
| 561 | } | ||
| 562 | } | ||
| 563 | return ($ans); #sub check4local_config | ||
| 564 | } | ||
| 565 | |||
| 566 | =head2 sub check4user_config | ||
| 567 | |||
| 568 | check for versions of the Project.config file | ||
| 569 | in the user's configuration directory: | ||
| 570 | .L_SU/configuration/active | ||
| 571 | for Project.config | ||
| 572 | True when for $$name_sref='Project'; | ||
| 573 | |||
| 574 | =cut | ||
| 575 | |||
| 576 | sub check4user_config { | ||
| 577 | |||
| 578 | my ( $self, $name_sref ) = @_; | ||
| 579 | |||
| 580 | my $ans = $false; | ||
| 581 | |||
| 582 | if ($name_sref) { | ||
| 583 | if ( -e ( $ACTIVE_PROJECT . '/' . $$name_sref . '.config' ) ) { | ||
| 584 | $ans = $true; | ||
| 585 | |||
| 586 | # print("su_param,check4user_config,$$name_sref.config found, Using user configuration file\n"); | ||
| 587 | # print("su_param,check4user_config=$ans\n"); | ||
| 588 | } | ||
| 589 | else { | ||
| 590 | $ans = $false; | ||
| 591 | |||
| 592 | # print("su_param,check4user_config,$$name_sref not found. Using default (GLOBAL LIBS) configuration file\n") | ||
| 593 | } | ||
| 594 | } | ||
| 595 | return ($ans); | ||
| 596 | } | ||
| 597 | |||
| 598 | =head2 sub my_length | ||
| 599 | not found | ||
| 600 | This length is twice the number of parameter | ||
| 601 | names | ||
| 602 | print("su_param,length: is $length\n"); | ||
| 603 | |||
| 604 | =cut | ||
| 605 | |||
| 606 | sub my_length { | ||
| 607 | |||
| 608 | my ($self) = @_; | ||
| 609 | if ( $su_param->{_names_aref} ) { | ||
| 610 | my $my_length = ( scalar @{ $su_param->{_names_aref} } ) * 2; | ||
| 611 | return ($my_length); | ||
| 612 | } | ||
| 613 | else { | ||
| 614 | |||
| 615 | # print ("su_param,my_length, empty names array reference\n"); | ||
| 616 | } | ||
| 617 | |||
| 618 | } | ||
| 619 | |||
| 620 | 1; |