lib/App/SeismicUnixGui/developer/code/sunix/sudoc2pm_pt1.pl untested

filter: Statementstmt 0.0% 0 / 94 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 101 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 =head1 DOCUMENTATION
2  
3 =head2 SYNOPSIS
4  
5 PROGRAM NAME: sudoc2pm_pt1.pm
6  
7 AUTHOR: Juan Lorenzo
8 DATE: Jan 25 2018
9 DESCRIPTION: generate (1) package for sunix module
10 and (2) configuration file for the same sunix module
11 Version: 1.0.0
12 1.1 May 2021: updated file searches in directories
13  
14 =head2 USE
15  
16 Build new files: ~/configs/"program_group_name"/"module".config
17 ~/sunix/"program_group_name"/"module".pm and
18 ~specs/"program_group_name"/"module"_spec
19 and modify old files:
20 ~/misc/L_SU_global_constants.pm
21  
22 =head3 NOTES
23 ramp
24  
25 0. make sure that the documentation
26 exists for the program in the
27 "Stripped" directory
28 Even if you do, make sure that at least
29 one parameter exists e.g. "opt=null"
30  
31 1. Modify "nameNnumber.txt" (in current folder)
32 with the correct base
33 file name and number
34 e.g. susynlv 7
35  
36 Example file contents for nameNnumber.txt:
37 Which group number do you want to use to create
38 for *.pm, *.config, and *_spec.pm files ?
39  
40 e.g., for transforms use:
41 $sunix_category_number = 14
42  
43 3. define program (ONLY in one location) within a
44 developer category in ~misc/L_SU_global_constants.pm
45 e.g., _suhilb => $developer_sunix_categories[14]
46  
47 4. Also, define program in two locations within
48 ~misc/L_SU_path for hash and the colon definitions
49  
50 5. Run the current script: sudoc2pm_pt1.pl
51 N.B., You may have to run this program from within
52 its directory e.g.
53 , ~/usr/local/pl/App-SeismicUnixGui/lib/App/SeismicUnixGui/developer/code/sunix
54 This program generates "module".pm, "module".config, and "module"_spec.pm
55  
56 6. After running this script (sudoc2pm_pt1.pl)
57 and before running sudoc2pm_pt2.pl:
58 modify "module".config file , as needed
59  
60 7. Go to ~/usr/local/pl/App-SeismicUnixGui/lib/App/SeismicUnixGui/developer/code/sunix
61 A "program_name"_changes.txt file may be needed to set up needed directory
62 bindings in the spec file, but it is not always necessary.
63 The current step will prepare the *_spec.pm file
64 with the correct bindings for the screen
65 parameters.
66  
67 Now, run sudoc2pm_pt2.pl
68  
69  
70 =head4 Examples:
71  
72 perl sudoc2pm_pt1.pl
73  
74 =head3 NOTES
75  
76 Program group array and the directory names:
77  
78 $developer_sunix_categories[0] = 'data';
79 $developer_sunix_categories[1] = 'datum';
80 $developer_sunix_categories[2] = 'plot';
81 $developer_sunix_categories[3] = 'filter';
82 $developer_sunix_categories[4] = 'header';
83 $developer_sunix_categories[5] = 'inversion';
84 $developer_sunix_categories[6] = 'migration';
85 $developer_sunix_categories[7] = 'model';
86 $developer_sunix_categories[8] = 'NMO_Vel_Stk';
87 $developer_sunix_categories[9] = 'par';
88 $developer_sunix_categories[10] = 'picks';
89 $developer_sunix_categories[11] = 'shapeNcut';
90 $developer_sunix_categories[12] = 'shell';
91 $developer_sunix_categories[13] = 'statsMath';
92 $developer_sunix_categories[14] = 'transform';
93 $developer_sunix_categories[15] = 'well';
94 $developer_sunix_categories[16] = 'unix';
95 $developer_sunix_categories[17] = '';
96
97 =head2 CHANGES and their DATES
98 V1.1.1 Jan 2 2026 Improved comments
99  
100 =cut
101  
102 use Moose;
103 our $VERSION = '1.1.1';
104  
105 use aliased 'App::SeismicUnixGui::developer::code::sunix::sudoc';
106 use aliased 'App::SeismicUnixGui::developer::code::sunix::sunix_package';
107 use aliased 'App::SeismicUnixGui::developer::code::sunix::prog_doc2pm';
108 use aliased 'App::SeismicUnixGui::developer::code::sunix::sudoc2pm_nameNnumber';
109  
110 my $sudoc = sudoc->new();
111 my $sunix_package = sunix_package->new();
112 my $prog_doc2pm = prog_doc2pm->new();
113 my $sudoc2pm_nameNnumber = sudoc2pm_nameNnumber->new();
114  
115 my ( @file_in, @pm_file_out );
116 my (@config_file_out);
117 my (@spec_file_out);
118 my (@path_out);
119 my ($i);
120 my @file;
121 my @package_path_out4configs;
122 my @package_path_out4developer;
123 my @package_path_out4specs;
124 my @package_path_out4sunix;
125  
126 my $sudoc2pm = {
127 _names => '',
128 _values => '',
129 _line_contents => '',
130 };
131  
132 =head2 TBD
133  
134 psgraph thru psmovie
135  
136 =cut
137  
138 my $selected_program_name = $sudoc2pm_nameNnumber->get_selected_program_name();
139 my $sunix_category_number = $sudoc2pm_nameNnumber->get_category_number();
140  
141 print("sudoc2pm_pt1,selected_program_name=$selected_program_name\n");
142 print("sudoc2pm_pt1,sunix_category_number=$sunix_category_number\n");
143  
144 $prog_doc2pm->set_group_directory($sunix_category_number);
145 $selected_program_name =~ s/\ //g;
146  
147 =head2 private values
148  
149  
150 =cut
151  
152 my $path_in = $prog_doc2pm->get_path_in();
153 my $list_length = $prog_doc2pm->get_list_length();
154 my $path_out4configs = $prog_doc2pm->get_path_out4configs();
155 my $path_out4developer = $prog_doc2pm->get_path_out4developer();
156 my $path_out4specs = $prog_doc2pm->get_path_out4specs();
157 my $path_out4sunix = $prog_doc2pm->get_path_out4sunix();
158 my @long_file_name = @{ $prog_doc2pm->get_list_aref() };
159  
160 # print("sudoc2pm_pt1.pl,long_file_name: @long_file_name\n");
161 #print("sudoc2pm_pt1.pl,path_out: $path_out4developer\n");
162 #print("sudoc2pm_pt1.pl,list_length: $list_length\n");
163  
164 my @program_name = @{ $prog_doc2pm->get_program_aref() };
165 my $package_name;
166  
167 for ( my $i = 0 ; $i < $list_length ; $i++ ) {
168  
169 # print("sudoc2pm_pt1.pl,program_name, num=$i, program_name=$program_name[$i]\n");
170  
171 $package_name = $program_name[$i];
172 $pm_file_out[0] = $package_name . '.pm';
173 $config_file_out[0] = $package_name . '.config';
174 $spec_file_out[0] = $package_name . '_spec.pm';
175  
176 #print("sudoc2pm_pt1.pl,program_name, selected_program_name=$selected_program_name \n");
177 #print("sudoc2pm_pt1.pl, package_name =$package_name \n");
178  
179 if ( $selected_program_name eq $package_name ) {
180  
181 print("sudoc2pm_pt1.pl, I am in group=$sunix_category_number \n");
182 # print("sudoc2pm_pt1.pl, I am working on package =$package_name \n");
183 # print("sudoc2pm_pt1.pl, writing $pm_file_out[0] in scratch\n");
184 # print("sudoc2pm_pt1.pl, writing $config_file_out[0] in scratch\\n");
185 # print("sudoc2pm_pt1.pl, writing $spec_file_out[0]in scratch\ \n");
186  
187 =head2 Read in sunix documentaion
188 =cut
189  
190 my $file = $long_file_name[$i];
191 $sudoc->set_file_in_sref( \$file );
192 $sudoc->set_perl_path_in($path_in);
193 $sudoc->whole();
194 my $whole_aref = $sudoc->get_whole();
195  
196 my $ans = scalar @$whole_aref;
197  
198 print("sudoc2pm_pt1.pl,num_lines= $ans\n");
199 for (my $i=0; $i <$ans; $i++) {
200 print("sudoc2pm_pt1.pl,All sunix documentation @{$whole_aref}[$i]\n");
201 }
202  
203 $sudoc2pm->{_line_contents} = $sudoc->lines_with('=');
204 my $sudoc_namVal = $sudoc->parameters( $sudoc2pm->{_line_contents} );
205 my $length = scalar @{ $sudoc_namVal->{_names} };
206  
207 print("sudoc2pm_pt1.pl, num names count = $length\n");
208  
209 # for ( my $i = 0 ; $i < $length ; $i++ ) {
210 # print(
211 # "\n3. sudoc2pm,_names = _values,
212 # line#$i @{$sudoc_namVal->{_names}}[$i] = "
213 # );
214 # print("@{$sudoc_namVal->{_values}}[$i]\n");
215 # }
216  
217 $package_path_out4configs[0] = $path_out4configs;
218 $package_path_out4developer[0] = $path_out4developer;
219 $package_path_out4specs[0] = $path_out4specs;
220 $package_path_out4sunix[0] = $path_out4sunix;
221  
222 $sunix_package->set_file_out( \@pm_file_out );
223 $sunix_package->set_path_out4configs( \@package_path_out4configs );
224  
225 # $sunix_package->set_path_out4developer( \@package_path_out4developer );
226 # print(
227 #"sudoc2pm_pt1,path_out4specs is $sunix_package->{@package_path_out4specs}\n"
228 # );
229  
230  
231 $sunix_package->set_path_out4specs( \@package_path_out4specs );
232 $sunix_package->set_path_out4sunix( \@package_path_out4sunix );
233 $sunix_package->set_config_file_out( \@config_file_out );
234 $sunix_package->set_spec_file_out( \@spec_file_out );
235 my @package_name_array;
236 $package_name_array[0] = $package_name;
237 $sunix_package->set_package_name( \@package_name_array );
238 $sunix_package->set_param_names( $sudoc_namVal->{_names} );
239 $sunix_package->set_param_values( $sudoc_namVal->{_values} );
240 $sunix_package->set_sudoc_aref($whole_aref);
241 $sunix_package->write_pm();
242 $sunix_package->write_config();
243 $sunix_package->write_spec();
244 }
245 } # for a selected program name in the group
246  
247 1;