Skip to content

Commit

Permalink
Add and standarize docstrings on modules/zos_gather_facts.py
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacVRey committed Mar 27, 2024
1 parent b4156f8 commit ed25d9d
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions plugins/modules/zos_gather_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,13 @@
def zinfo_facts_list_builder(gather_subset):
"""Builds a list of strings to pass into 'zinfo' based off the
gather_subset list.
Arguments:
gather_subset {list} -- A list of subsets to pass in.
Returns:
[list[str]] -- A list of strings that contains sanitized subsets.
[None] -- An invalid value was received for the subsets.
list[str] -- A list of strings that contains sanitized subsets.
None -- An invalid value was received for the subsets.
"""
if gather_subset is None or 'all' in gather_subset:
return ["all"]
Expand All @@ -157,11 +159,13 @@ def zinfo_facts_list_builder(gather_subset):
def flatten_zinfo_json(zinfo_dict):
"""Removes one layer of mapping in the dictionary. Top-level keys
correspond to zinfo subsets and are removed.
Arguments:
zinfo_dict {dict} -- A dictionary that contains the parsed result from
the zinfo json string.
Returns:
[dict] -- A flattened dictionary.
dict -- A flattened dictionary.
"""
d = {}
for subset in list(zinfo_dict):
Expand All @@ -172,13 +176,15 @@ def flatten_zinfo_json(zinfo_dict):
def apply_filter(zinfo_dict, filter_list):
"""Returns a dictionary that contains only the keys which fit the specified
filters.
Arguments:
zinfo_dict {dict} -- A flattened dictionary that contains results from
zinfo.
filter_list {list} -- A string list of shell wildcard patterns (i.e.
'filters') to apply to the zinfo_dict keys.
Returns:
[dict] -- A dictionary with keys that are filtered out.
dict -- A dictionary with keys that are filtered out.
"""

if filter_list is None or filter_list == [] or '*' in filter_list:
Expand All @@ -193,6 +199,14 @@ def apply_filter(zinfo_dict, filter_list):


def run_module():
"""Initialize module
Raises:
fail_json: The zos_gather_facts module requires ZOAU >= 1.3.0.
fail_json: An invalid subset was passed to Ansible.
fail_json: An invalid subset was detected.
fail_json: An exception has occurred. Unable to gather facts.
"""
# define available arguments/parameters a user can pass to the module
module_args = dict(
gather_subset=dict(
Expand Down

0 comments on commit ed25d9d

Please sign in to comment.