Skip to content

Commit 54ea6ba

Browse files
IsaacVReyfernandofloresgrichp405
authored
[Documentation][zos_tso_command] Add and standarize docstrings on modules/zos_tso_command.py (#1391)
* Add and standarize docstrings on module-utils/zos_tso_command.py * Add changelog fragment * Modified docstrings --------- Co-authored-by: Fernando Flores <[email protected]> Co-authored-by: Rich Parker <[email protected]>
1 parent 216baa5 commit 54ea6ba

File tree

2 files changed

+68
-0
lines changed

2 files changed

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

plugins/modules/zos_tso_command.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,23 @@
135135

136136

137137
def run_tso_command(commands, module, max_rc):
138+
"""Run tso command.
139+
140+
Parameters
141+
----------
142+
commands : str
143+
Commands to run.
144+
module : AnsibleModule
145+
Ansible module to run the command with.
146+
max_rc : int
147+
Max return code.
148+
149+
Returns
150+
-------
151+
Union[dict]
152+
The command result details.
153+
154+
"""
138155
script = """/* REXX */
139156
PARSE ARG cmd
140157
address tso
@@ -152,6 +169,24 @@ def run_tso_command(commands, module, max_rc):
152169

153170

154171
def copy_rexx_and_run_commands(script, commands, module, max_rc):
172+
"""Copy rexx into a temporary file and run commands.
173+
174+
Parameters
175+
----------
176+
script : str
177+
Script to run the command.
178+
commands : str
179+
Commands to run.
180+
module : AnsibleModule
181+
Ansible module to run the command with.
182+
max_rc : int
183+
Max return code.
184+
185+
Returns
186+
-------
187+
Union[dict]
188+
The command result details.
189+
"""
155190
command_detail_json = []
156191
delete_on_close = True
157192
tmp_file = NamedTemporaryFile(delete=delete_on_close)
@@ -180,6 +215,25 @@ def copy_rexx_and_run_commands(script, commands, module, max_rc):
180215

181216

182217
def list_or_str_type(contents, dependencies):
218+
"""Checks if a variable contains a string or a list of strings and returns it as a list of strings.
219+
220+
Parameters
221+
----------
222+
contents : str | list[str]
223+
String or list of strings.
224+
dependencies
225+
Unused.
226+
227+
Returns
228+
-------
229+
str | Union[str]
230+
The parameter given as a list of strings.
231+
232+
Raises
233+
------
234+
ValueError
235+
Invalid argument type. Expected "string or list of strings".
236+
"""
183237
failed = False
184238
if isinstance(contents, list):
185239
for item in contents:
@@ -200,6 +254,17 @@ def list_or_str_type(contents, dependencies):
200254

201255

202256
def run_module():
257+
"""Initialize module.
258+
259+
Raises
260+
------
261+
fail_json
262+
ValueError on BetterArgParser.
263+
fail_json
264+
Some command(s) failed.
265+
fail_json
266+
An unexpected error occurred.
267+
"""
203268
module_args = dict(
204269
commands=dict(type="raw", required=True, aliases=["command"]),
205270
max_rc=dict(type="int", required=False, default=0),

0 commit comments

Comments
 (0)