1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-25 05:02:46 +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

@ -33,7 +33,7 @@ def cause_changes(when=None):
def module_fails_on_exception(func):
conflict_list = ('msg', 'exception', 'output', 'vars', 'changed')
conflict_list = ("msg", "exception", "output", "vars", "changed")
@wraps(func)
def wrapper(self, *args, **kwargs):
@ -51,14 +51,17 @@ def module_fails_on_exception(func):
self.update_output(e.update_output)
# patchy solution to resolve conflict with output variables
output = fix_var_conflicts(self.output)
self.module.fail_json(msg=e.msg, exception=traceback.format_exc(),
output=self.output, vars=self.vars.output(), **output)
self.module.fail_json(
msg=e.msg, exception=traceback.format_exc(), output=self.output, vars=self.vars.output(), **output
)
except Exception as e:
# patchy solution to resolve conflict with output variables
output = fix_var_conflicts(self.output)
msg = f"Module failed with exception: {str(e).strip()}"
self.module.fail_json(msg=msg, exception=traceback.format_exc(),
output=self.output, vars=self.vars.output(), **output)
self.module.fail_json(
msg=msg, exception=traceback.format_exc(), output=self.output, vars=self.vars.output(), **output
)
return wrapper
@ -72,22 +75,25 @@ def check_mode_skip(func):
def check_mode_skip_returns(callable=None, value=None):
def deco(func):
if callable is not None:
@wraps(func)
def wrapper_callable(self, *args, **kwargs):
if self.module.check_mode:
return callable(self, *args, **kwargs)
return func(self, *args, **kwargs)
return wrapper_callable
else:
@wraps(func)
def wrapper_value(self, *args, **kwargs):
if self.module.check_mode:
return value
return func(self, *args, **kwargs)
return wrapper_value
return deco