@@ -24,14 +24,20 @@ def get_volume_entry(volume):
24
24
"""Retrieve VTOC information for all data sets with entries
25
25
on the volume.
26
26
27
- Arguments:
28
- volume {str} -- The name of the volume.
29
-
30
- Raises:
31
- VolumeTableOfContentsError: When any exception is raised during VTOC operations.
32
-
33
- Returns:
34
- list[dict] -- List of dictionaries holding data set information from VTOC.
27
+ Parameters
28
+ ----------
29
+ volume : str
30
+ The name of the volume.
31
+
32
+ Returns
33
+ -------
34
+ Union[dict]
35
+ List of dictionaries holding data set information from VTOC.
36
+
37
+ Raises
38
+ ------
39
+ VolumeTableOfContentsError
40
+ When any exception is raised during VTOC operations.
35
41
"""
36
42
try :
37
43
stdin = " LISTVTOC FORMAT,VOL=3390={0}" .format (volume .upper ())
@@ -50,12 +56,17 @@ def get_data_set_entry(data_set_name, volume):
50
56
"""Retrieve VTOC information for a single data set
51
57
on a volume.
52
58
53
- Arguments:
54
- data_set_name {str} -- The name of the data set to retrieve information for.
55
- volume {str} -- The name of the volume.
56
-
57
- Returns:
58
- dict -- The information for the data set found in VTOC.
59
+ Parameters
60
+ ----------
61
+ data_set_name : str
62
+ The name of the data set to retrieve information for.
63
+ volume : str
64
+ The name of the volume.
65
+
66
+ Returns
67
+ -------
68
+ dict
69
+ The information for the data set found in VTOC.
59
70
"""
60
71
data_set = None
61
72
data_sets = get_volume_entry (volume )
@@ -72,12 +83,17 @@ def find_data_set_in_volume_output(data_set_name, data_sets):
72
83
set if present. This method is useful when wanting to avoid multiple
73
84
IEHLIST calls.
74
85
75
- Arguments:
76
- data_set_name {str} -- The name of the data set to retrieve information for.
77
- data_sets {list[dict]} -- List of dictionaries holding data set information from VTOC.
78
-
79
- Returns:
80
- dict -- The information for the data set found in VTOC.
86
+ Parameters
87
+ ----------
88
+ data_set_name : str
89
+ The name of the data set to retrieve information for.
90
+ data_sets : list[dict]
91
+ List of dictionaries holding data set information from VTOC.
92
+
93
+ Returns
94
+ -------
95
+ dict
96
+ The information for the data set found in VTOC.
81
97
"""
82
98
if isinstance (data_sets , list ):
83
99
for data_set in data_sets :
@@ -89,12 +105,17 @@ def find_data_set_in_volume_output(data_set_name, data_sets):
89
105
def _iehlist (dd , stdin ):
90
106
"""Calls IEHLIST program.
91
107
92
- Arguments:
93
- dd {str} -- Volume information to pass as DD statement.
94
- stdin {str} -- Input to stdin.
95
-
96
- Returns:
97
- str -- The sysprint response of IEHLIST.
108
+ Parameters
109
+ ----------
110
+ dd : str
111
+ Volume information to pass as DD statement.
112
+ stdin : str
113
+ Input to stdin.
114
+
115
+ Returns
116
+ -------
117
+ str
118
+ The sysprint response of IEHLIST.
98
119
"""
99
120
module = AnsibleModuleHelper (argument_spec = {})
100
121
response = None
@@ -110,11 +131,15 @@ def _iehlist(dd, stdin):
110
131
def _process_output (stdout ):
111
132
"""Process output of LISTVTOC.
112
133
113
- Arguments:
114
- stdout {str} -- The output of LISTVTOC.
134
+ Parameters
135
+ ----------
136
+ stdout : str
137
+ The output of LISTVTOC.
115
138
116
- Returns:
117
- list[dict] -- List of dictionaries holding data set information from VTOC.
139
+ Returns
140
+ -------
141
+ Union[dict]
142
+ List of dictionaries holding data set information from VTOC.
118
143
"""
119
144
data_sets = []
120
145
data_set_strings = _separate_data_set_sections (stdout )
@@ -126,11 +151,15 @@ def _process_output(stdout):
126
151
def _separate_data_set_sections (contents ):
127
152
"""Split LISTVTOC output into data set sections.
128
153
129
- Arguments:
130
- contents {str} -- The output of LISTVTOC.
154
+ Parameters
155
+ ----------
156
+ contents : str
157
+ The output of LISTVTOC.
131
158
132
- Returns:
133
- list[str] -- LISTVTOC output separated into sections by data set.
159
+ Returns
160
+ -------
161
+ Union[str]
162
+ LISTVTOC output separated into sections by data set.
134
163
"""
135
164
delimeter = "0---------------DATA SET NAME----------------"
136
165
data_sets = re .split (delimeter , contents )
@@ -142,11 +171,15 @@ def _parse_data_set_info(data_set_string):
142
171
"""Build dictionaries representing data set information
143
172
from LISTVTOC output.
144
173
145
- Arguments:
146
- data_set_string {str} -- Single data set section of the LISTVTOC output.
174
+ Parameters
175
+ ----------
176
+ data_set_string : str
177
+ Single data set section of the LISTVTOC output.
147
178
148
- Returns:
149
- dict -- Holds data set information from VTOC.
179
+ Returns
180
+ -------
181
+ dict
182
+ Holds data set information from VTOC.
150
183
"""
151
184
lines = data_set_string .split ("\n " )
152
185
data_set_info = {}
@@ -172,13 +205,19 @@ def _parse_table_row(regex, header_row, data_row):
172
205
"""Parse out a single row of VTOC table information from
173
206
VTOCLIST output.
174
207
175
- Arguments:
176
- regex {str} -- The regular expression used to parse table row.
177
- header_row {str} -- The row of the table containing headers.
178
- data_row {str} -- The row of the table containing data.
179
-
180
- Returns:
181
- dict -- Structured data for the row of the table.
208
+ Parameters
209
+ ----------
210
+ regex : str
211
+ The regular expression used to parse table row.
212
+ header_row : str
213
+ The row of the table containing headers.
214
+ data_row : str
215
+ The row of the table containing data.
216
+
217
+ Returns
218
+ -------
219
+ dict
220
+ Structured data for the row of the table.
182
221
"""
183
222
table_data = {}
184
223
fields = re .findall (regex , header_row )
@@ -200,11 +239,15 @@ def _format_table_data(table_data):
200
239
This includes separating and renaming fields from
201
240
their original naming and style in VTOCLIST.
202
241
203
- Arguments:
204
- table_data {dict} -- Structured data parsed from VTOCLIST output.
242
+ Parameters
243
+ ----------
244
+ table_data : dict
245
+ Structured data parsed from VTOCLIST output.
205
246
206
- Returns:
207
- dict -- Updated data.
247
+ Returns
248
+ -------
249
+ dict
250
+ Updated data.
208
251
"""
209
252
handlers = {
210
253
"DATA SET NAME" : "data_set_name" ,
@@ -250,13 +293,18 @@ def _format_table_data(table_data):
250
293
def _format_extend (contents , formatted_table_data ):
251
294
"""Format the extend field from VTOCLIST.
252
295
253
- Arguments:
254
- contents {str} -- Contents of the extend field from VTOCLIST.
255
- formatted_table_data {dict} -- The dictionary containing other already formatted
296
+ Parameters
297
+ ----------
298
+ contents : str
299
+ Contents of the extend field from VTOCLIST.
300
+ formatted_table_data : dict
301
+ The dictionary containing other already formatted
256
302
table data.
257
303
258
- Returns:
259
- dict -- The updated formatted_table_data dictionary.
304
+ Returns
305
+ -------
306
+ dict
307
+ The updated formatted_table_data dictionary.
260
308
"""
261
309
matches = re .search (r"([0-9]+)(AV|BY|KB|MB)" , contents )
262
310
original_space_secondary = ""
@@ -280,11 +328,15 @@ def _format_extend(contents, formatted_table_data):
280
328
def _format_last_blk (contents ):
281
329
"""Format the last blk field from VTOCLIST.
282
330
283
- Arguments:
284
- contents {str} -- Contents of the last blk field from VTOCLIST.
331
+ Parameters
332
+ ----------
333
+ contents : str
334
+ Contents of the last blk field from VTOCLIST.
285
335
286
- Returns:
287
- dict -- Structured data parsed from last blk field contents.
336
+ Returns
337
+ -------
338
+ dict
339
+ Structured data parsed from last blk field contents.
288
340
"""
289
341
result = None
290
342
matches = re .search (r"[ ]*([0-9]+)[ ]+([0-9]+)[ ]+([0-9]+)?" , contents )
@@ -300,11 +352,15 @@ def _format_last_blk(contents):
300
352
def _format_f2_or_f3 (contents ):
301
353
"""Format the F2 or F3 field from VTOCLIST.
302
354
303
- Arguments:
304
- contents {str} -- Contents of the F2 or F3 field from VTOCLIST.
355
+ Parameters
356
+ ----------
357
+ contents : str
358
+ Contents of the F2 or F3 field from VTOCLIST.
305
359
306
- Returns:
307
- dict -- Structured data parsed from the F2 or F3 field contents.
360
+ Returns
361
+ -------
362
+ dict
363
+ Structured data parsed from the F2 or F3 field contents.
308
364
"""
309
365
result = None
310
366
matches = re .search (r"[ ]*([0-9]+)[ ]+([0-9]+)[ ]+([0-9]+)" , contents )
@@ -319,11 +375,15 @@ def _format_f2_or_f3(contents):
319
375
def _format_dscb (contents ):
320
376
"""Format the dscb field from VTOCLIST.
321
377
322
- Arguments:
323
- contents {str} -- Contents of the dscb field from VTOCLIST.
378
+ Parameters
379
+ ----------
380
+ contents : str
381
+ Contents of the dscb field from VTOCLIST.
324
382
325
- Returns:
326
- dict -- Structured data parsed from the dscb field contents.
383
+ Returns
384
+ -------
385
+ dict
386
+ Structured data parsed from the dscb field contents.
327
387
"""
328
388
result = None
329
389
matches = re .search (r"[ ]*([0-9]+)[ ]+([0-9]+)[ ]+([0-9]+)" , contents )
@@ -338,13 +398,17 @@ def _format_dscb(contents):
338
398
def _parse_extents (lines ):
339
399
"""Parse and structure extent data from VTOCLIST.
340
400
341
- Arguments:
342
- contents {list[str]} -- Partial contents of single data set section
401
+ Parameters
402
+ ----------
403
+ contents : list[str]
404
+ Partial contents of single data set section
343
405
from VTOCLIST that will contain extent information if data set has
344
406
extents.
345
407
346
- Returns:
347
- list[dict] -- Structured data parsed from the extent field contents.
408
+ Returns
409
+ -------
410
+ dict
411
+ Structured data parsed from the extent field contents.
348
412
"""
349
413
extents = []
350
414
if re .search (r"THE\sABOVE\sDATASET\sHAS\sNO\sEXTENTS" , "" .join (lines )):
@@ -366,13 +430,18 @@ def _parse_extents(lines):
366
430
def _extent_regex_builder (indent_length , header_groups ):
367
431
"""Build regular expressions for parsing extent information.
368
432
369
- Arguments:
370
- indent_length {int} -- The number of spaces before extent information starts.
371
- header_groups {list[tuple]} -- Captured output of header groups identified
433
+ Parameters
434
+ ----------
435
+ indent_length : int
436
+ The number of spaces before extent information starts.
437
+ header_groups : list[tuple]
438
+ Captured output of header groups identified
372
439
during VTOCLIST parsing.
373
440
374
- Returns:
375
- str -- The regular expression for parsing extent information.
441
+ Returns
442
+ -------
443
+ str
444
+ The regular expression for parsing extent information.
376
445
"""
377
446
extent_regex = "^[ ]{{{0}}}" .format (str (indent_length ))
378
447
for index , header_group in enumerate (header_groups ):
@@ -389,11 +458,15 @@ def _extent_regex_builder(indent_length, header_groups):
389
458
def _format_extent_data (extent_data ):
390
459
"""Format the dscb field from VTOCLIST.
391
460
392
- Arguments:
393
- extent_data {list[tuple]} -- Captured output of extent data.
461
+ Parameters
462
+ ----------
463
+ extent_data : list[tuple]
464
+ Captured output of extent data.
394
465
395
- Returns:
396
- dict -- Structured data parsed from captured output of extent data.
466
+ Returns
467
+ -------
468
+ Union[dict]
469
+ Structured data parsed from captured output of extent data.
397
470
"""
398
471
extents = []
399
472
flattened_extent_data = []
@@ -418,5 +491,17 @@ def _format_extent_data(extent_data):
418
491
419
492
class VolumeTableOfContentsError (Exception ):
420
493
def __init__ (self , msg = "" ):
494
+ """Error during VTOC parsing or retrieval.
495
+
496
+ Parameters
497
+ ----------
498
+ msg : str
499
+ Human readable string describing the exception.
500
+
501
+ Attributes
502
+ ----------
503
+ msg : str
504
+ Human readable string describing the exception.
505
+ """
421
506
self .msg = "An error occurred during VTOC parsing or retrieval. {0}" .format (msg )
422
507
super (VolumeTableOfContentsError , self ).__init__ (self .msg )
0 commit comments