Skip to content

Commit

Permalink
Add and standarize docstrings on module-utils/zos_tso_command.py
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacVRey committed Apr 4, 2024
1 parent b4156f8 commit 0e8387f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
trivial:
- zos_tso_command - Updated docstrings to numpy style for visual aid to developers.
(https://github.com/ansible-collections/ibm_zos_core/pull/1390).
65 changes: 65 additions & 0 deletions plugins/modules/zos_tso_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@


def run_tso_command(commands, module, max_rc):
"""Run tso command.
Parameters
----------
commands : str
Commands to run.
module : AnsibleModule
Ansible module to run the command with.
max_rc : int
Max return code.
Returns
-------
Union[dict]
The command result details.
"""
script = """/* REXX */
PARSE ARG cmd
address tso
Expand All @@ -152,6 +169,24 @@ def run_tso_command(commands, module, max_rc):


def copy_rexx_and_run_commands(script, commands, module, max_rc):
"""Copy rexx and run commands
Parameters
----------
script : str
Script to run the command.
commands : str
Commands to run.
module : AnsibleModule
Ansible module to run the command with.
max_rc : int
Max return code.
Returns
-------
Union[dict]
The command result details.
"""
command_detail_json = []
delete_on_close = True
tmp_file = NamedTemporaryFile(delete=delete_on_close)
Expand Down Expand Up @@ -180,6 +215,25 @@ def copy_rexx_and_run_commands(script, commands, module, max_rc):


def list_or_str_type(contents, dependencies):
"""Checks if a variable contains a string or a list of strings and returns it as a list of strings.
Parameters
----------
contents : str | list[str]
String or list of strings.
dependencies
Unused.
Returns
-------
str | Union[str]
The parameter given as a list of strings.
Raises
------
ValueError
Invalid argument type. Expected "string or list of strings".
"""
failed = False
if isinstance(contents, list):
for item in contents:
Expand All @@ -200,6 +254,17 @@ def list_or_str_type(contents, dependencies):


def run_module():
"""Initialize module.
Raises
------
fail_json
ValueError on BetterArgParser.
fail_json
Some command(s) failed.
fail_json
An unexpected error occurred.
"""
module_args = dict(
commands=dict(type="raw", required=True, aliases=["command"]),
max_rc=dict(type="int", required=False, default=0),
Expand Down

0 comments on commit 0e8387f

Please sign in to comment.