1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-08 04:57:16 +00:00

Reformat everything.

This commit is contained in:
Felix Fontein 2025-11-01 12:08:41 +01:00
parent 3f2213791a
commit 340ff8586d
1008 changed files with 61301 additions and 58309 deletions

View file

@ -155,7 +155,7 @@ def run_command(command, module, check_rc=True):
:param module: Ansible make module instance
:return: return code, stdout content, stderr content
"""
rc, out, err = module.run_command(command, check_rc=check_rc, cwd=module.params['chdir'])
rc, out, err = module.run_command(command, check_rc=check_rc, cwd=module.params["chdir"])
return rc, sanitize_output(out), sanitize_output(err)
@ -170,7 +170,7 @@ def sanitize_output(output):
:return: sanitized output
"""
if output is None:
return ''
return ""
else:
return output.rstrip("\r\n")
@ -178,55 +178,55 @@ def sanitize_output(output):
def main():
module = AnsibleModule(
argument_spec=dict(
target=dict(type='str'),
targets=dict(type='list', elements='str'),
params=dict(type='dict'),
chdir=dict(type='path', required=True),
file=dict(type='path'),
make=dict(type='path'),
jobs=dict(type='int'),
target=dict(type="str"),
targets=dict(type="list", elements="str"),
params=dict(type="dict"),
chdir=dict(type="path", required=True),
file=dict(type="path"),
make=dict(type="path"),
jobs=dict(type="int"),
),
mutually_exclusive=[('target', 'targets')],
mutually_exclusive=[("target", "targets")],
supports_check_mode=True,
)
make_path = module.params['make']
make_path = module.params["make"]
if make_path is None:
# Build up the invocation of `make` we are going to use
# For non-Linux OSes, prefer gmake (GNU make) over make
make_path = module.get_bin_path('gmake', required=False)
make_path = module.get_bin_path("gmake", required=False)
if not make_path:
# Fall back to system make
make_path = module.get_bin_path('make', required=True)
if module.params['params'] is not None:
make_parameters = [k + (f"={v!s}" if v is not None else '') for k, v in module.params['params'].items()]
make_path = module.get_bin_path("make", required=True)
if module.params["params"] is not None:
make_parameters = [k + (f"={v!s}" if v is not None else "") for k, v in module.params["params"].items()]
else:
make_parameters = []
# build command:
# handle any make specific arguments included in params
base_command = [make_path]
if module.params['jobs'] is not None:
jobs = str(module.params['jobs'])
if module.params["jobs"] is not None:
jobs = str(module.params["jobs"])
base_command.extend(["-j", jobs])
if module.params['file'] is not None:
base_command.extend(["-f", module.params['file']])
if module.params["file"] is not None:
base_command.extend(["-f", module.params["file"]])
# add make target
if module.params['target']:
base_command.append(module.params['target'])
elif module.params['targets']:
base_command.extend(module.params['targets'])
if module.params["target"]:
base_command.append(module.params["target"])
elif module.params["targets"]:
base_command.extend(module.params["targets"])
# add makefile parameters
base_command.extend(make_parameters)
# Check if the target is already up to date
rc, out, err = run_command(base_command + ['-q'], module, check_rc=False)
rc, out, err = run_command(base_command + ["-q"], module, check_rc=False)
if module.check_mode:
# If we've been asked to do a dry run, we only need
# to report whether or not the target is up to date
changed = (rc != 0)
changed = rc != 0
else:
if rc == 0:
# The target is up to date, so we don't have to
@ -247,15 +247,15 @@ def main():
failed=False,
stdout=out,
stderr=err,
target=module.params['target'],
targets=module.params['targets'],
params=module.params['params'],
chdir=module.params['chdir'],
file=module.params['file'],
jobs=module.params['jobs'],
command=' '.join([shlex_quote(part) for part in base_command]),
target=module.params["target"],
targets=module.params["targets"],
params=module.params["params"],
chdir=module.params["chdir"],
file=module.params["file"],
jobs=module.params["jobs"],
command=" ".join([shlex_quote(part) for part in base_command]),
)
if __name__ == '__main__':
if __name__ == "__main__":
main()