Skip to content

Commit ae24956

Browse files
[Documentation][zos_encode] Add and standarize docstrings on modules/zos_encode.py (#1348)
* Add and standarize docstrings on modules/zos_encode.py * Create changelog fragment * Modify google style to numpy * Standarize numpy style * Updated docstrings --------- Co-authored-by: Fernando Flores <[email protected]>
1 parent 18486df commit ae24956

File tree

2 files changed

+89
-2
lines changed

2 files changed

+89
-2
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
trivial:
2+
- zos_encode - Updated docstrings to numpy style for visual aid to developers.
3+
(https://github.com/ansible-collections/ibm_zos_core/pull/1348).

plugins/modules/zos_encode.py

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,25 @@
295295

296296

297297
def check_pds_member(ds, mem):
298+
"""Check if a member exists in a PDS.
299+
300+
Parameters
301+
----------
302+
ds : str
303+
PDS data set name.
304+
mem : str
305+
Member name to check if is under PDS.
306+
307+
Returns
308+
-------
309+
bool
310+
If it is a member of the data set.
311+
312+
Raises
313+
------
314+
EncodeError
315+
Can not find member in provided dataset.
316+
"""
298317
check_rc = False
299318
if mem in datasets.list_members(ds):
300319
check_rc = True
@@ -304,7 +323,25 @@ def check_pds_member(ds, mem):
304323

305324

306325
def check_mvs_dataset(ds):
307-
""" To call data_set utils to check if the MVS data set exists or not """
326+
"""To call data_set utils to check if the MVS data set exists or not.
327+
328+
Parameters
329+
----------
330+
ds : str
331+
Data set name.
332+
333+
Returns
334+
-------
335+
tuple(bool,str)
336+
If the data set exists and it's type.
337+
338+
Raises
339+
------
340+
EncodeError
341+
If data set is not cataloged.
342+
EncodeError
343+
Unable to determine data set type.
344+
"""
308345
check_rc = False
309346
ds_type = None
310347
if not data_set.DataSet.data_set_exists(ds):
@@ -321,7 +358,23 @@ def check_mvs_dataset(ds):
321358

322359

323360
def check_file(file):
324-
""" check file is a USS file or an MVS data set """
361+
"""Check file is a USS file or an MVS data set.
362+
363+
Parameters
364+
----------
365+
file : str
366+
File to check.
367+
368+
Returns
369+
-------
370+
tuple(bool,bool,str)
371+
If is USS file, MVS dataset, and the dataset type.
372+
373+
Raises
374+
------
375+
EncodeError
376+
The data set is not partitioned.
377+
"""
325378
is_uss = False
326379
is_mvs = False
327380
ds_type = None
@@ -347,6 +400,18 @@ def check_file(file):
347400

348401

349402
def verify_uss_path_exists(file):
403+
"""Verify if USS path exists.
404+
405+
Parameters
406+
----------
407+
file : str
408+
Path of the file.
409+
410+
Raises
411+
------
412+
EncodeError
413+
File does not exist in the directory.
414+
"""
350415
if not path.exists(file):
351416
mypath = "/" + file.split("/")[0] + "/*"
352417
ld = listdir(mypath)
@@ -359,6 +424,13 @@ def verify_uss_path_exists(file):
359424

360425

361426
def run_module():
427+
"""Runs the module.
428+
429+
Raises
430+
------
431+
fail_json
432+
Exception during execution.
433+
"""
362434
module_args = dict(
363435
src=dict(type="str", required=True),
364436
dest=dict(type="str"),
@@ -530,6 +602,18 @@ def run_module():
530602

531603
class EncodeError(Exception):
532604
def __init__(self, message):
605+
"""Error during encoding.
606+
607+
Parameters
608+
----------
609+
message : str
610+
Human readable string describing the exception.
611+
612+
Attributes
613+
----------
614+
msg : str
615+
Human readable string describing the exception.
616+
"""
533617
self.msg = 'An error occurred during encoding: "{0}"'.format(message)
534618
super(EncodeError, self).__init__(self.msg)
535619

0 commit comments

Comments
 (0)