added an default display

Dieser Commit ist enthalten in:
Sebastian Tobie 2024-03-12 21:18:09 +01:00
Ursprung 47c8d3319e
Commit 1da65334e2
2 geänderte Dateien mit 6 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,2 @@
---
release_summary: added an default Display to the module

Datei anzeigen

@ -1,6 +1,7 @@
import pathlib import pathlib
from copy import deepcopy from copy import deepcopy
from typing import Any, Callable, ClassVar, Dict, NoReturn, Optional, Type, TypeVar, Union, overload from typing import Any, Callable, ClassVar, Dict, NoReturn, Optional, Type, TypeVar, Union, overload
from ansible.utils.display import Display
import ansible.module_utils.basic as basic import ansible.module_utils.basic as basic
@ -55,6 +56,8 @@ class AnsibleModule(object):
module_spec: ClassVar[dict] module_spec: ClassVar[dict]
#: This is set by classes that define common things for their subclasses, like behaviour of the run and check methods. This is used by `SystemdUnitModule` #: This is set by classes that define common things for their subclasses, like behaviour of the run and check methods. This is used by `SystemdUnitModule`
_common_args: ClassVar[dict[str, Any]] = dict() _common_args: ClassVar[dict[str, Any]] = dict()
#: For log messages
display: Display
@property @property
def params(self) -> Dict[str, Any]: def params(self) -> Dict[str, Any]:
@ -70,6 +73,7 @@ class AnsibleModule(object):
specs["argument_spec"].update(modspec["argument_spec"]) specs["argument_spec"].update(modspec["argument_spec"])
del modspec["argument_spec"] del modspec["argument_spec"]
specs.update(modspec) specs.update(modspec)
self.display = Display()
self.module = basic.AnsibleModule(**specs) self.module = basic.AnsibleModule(**specs)
self.tmpdir = pathlib.Path(self.module.tmpdir) self.tmpdir = pathlib.Path(self.module.tmpdir)