Commits vergleichen
Keine gemeinsamen Commits. „144ffc72a52503b5c4c4b46b34ce198e385b389c“ und „c5e6129682a32caaf74330ad6fc403deb83a33f6“ haben vollständig unterschiedliche Historien.
144ffc72a5
...
c5e6129682
2 geänderte Dateien mit 10 neuen und 9 gelöschten Zeilen
|
@ -23,9 +23,9 @@ def wrap_func(func, **updates):
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
attrs = set(('__module__', '__name__', '__qualname__', '__doc__', '__annotations__', '__type_params__')).difference(
|
attrs = frozenset(
|
||||||
updates.keys()
|
('__module__', '__name__', '__qualname__', '__doc__', '__annotations__', '__type_params__')
|
||||||
)
|
) - frozenset(updates.keys())
|
||||||
for attr in attrs:
|
for attr in attrs:
|
||||||
try:
|
try:
|
||||||
value = getattr(func, attr)
|
value = getattr(func, attr)
|
||||||
|
@ -90,7 +90,6 @@ class meta(type):
|
||||||
|
|
||||||
class Types(metaclass=meta):
|
class Types(metaclass=meta):
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def list( # type: ignore[misc]
|
def list( # type: ignore[misc]
|
||||||
elements: Union[Type[object], str, AnsibleParameter],
|
elements: Union[Type[object], str, AnsibleParameter],
|
||||||
required: bool = False,
|
required: bool = False,
|
||||||
|
@ -110,7 +109,7 @@ class Types(metaclass=meta):
|
||||||
option["elements"] = elements["type"]
|
option["elements"] = elements["type"]
|
||||||
if elements["type"] == "dict":
|
if elements["type"] == "dict":
|
||||||
option["options"] = dict()
|
option["options"] = dict()
|
||||||
for name, value in elements["options"].items():
|
for name, value in elements["option"].items():
|
||||||
option["options"][name] = value
|
option["options"][name] = value
|
||||||
if "description" not in option["options"][name]:
|
if "description" not in option["options"][name]:
|
||||||
warnings.warn( # pragma: nocover
|
warnings.warn( # pragma: nocover
|
||||||
|
@ -121,7 +120,6 @@ class Types(metaclass=meta):
|
||||||
option["description"] = help.split("\n")
|
option["description"] = help.split("\n")
|
||||||
return option
|
return option
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def dict(required: bool = False, help: Optional[str] = None, **options: AnsibleParameter) -> AnsibleParameter: # type: ignore[misc]
|
def dict(required: bool = False, help: Optional[str] = None, **options: AnsibleParameter) -> AnsibleParameter: # type: ignore[misc]
|
||||||
"""Wrapper for the Ansible dict type
|
"""Wrapper for the Ansible dict type
|
||||||
|
|
||||||
|
@ -156,7 +154,6 @@ def modspec(
|
||||||
supports_check_mode: bool = False,
|
supports_check_mode: bool = False,
|
||||||
add_file_common_args: bool = False,
|
add_file_common_args: bool = False,
|
||||||
) -> Dict[str, Any]: # pragma: nocover
|
) -> Dict[str, Any]: # pragma: nocover
|
||||||
"""Wrapper to properly Type the module specs"""
|
|
||||||
return dict(
|
return dict(
|
||||||
argument_spec=argument_spec,
|
argument_spec=argument_spec,
|
||||||
mutually_exclusive=mutually_exclusive,
|
mutually_exclusive=mutually_exclusive,
|
||||||
|
|
|
@ -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, TypedDict
|
from typing import Any, Callable, ClassVar, Dict, NoReturn, Optional, Type, TypeVar, Union, overload, TypedDict
|
||||||
|
from ansible.utils.display import Display
|
||||||
|
|
||||||
import ansible.module_utils.basic as basic
|
import ansible.module_utils.basic as basic
|
||||||
|
|
||||||
|
@ -20,8 +21,8 @@ T = TypeVar("T")
|
||||||
class TypedDiff(TypedDict):
|
class TypedDiff(TypedDict):
|
||||||
before: str
|
before: str
|
||||||
after: str
|
after: str
|
||||||
before_header: Optional[str]
|
before_header: Optional[str] = None
|
||||||
after_header: Optional[str]
|
after_header: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
def docify(input: Union[dict, AnsibleParameter]) -> dict:
|
def docify(input: Union[dict, AnsibleParameter]) -> dict:
|
||||||
|
@ -62,6 +63,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]:
|
||||||
|
@ -77,6 +80,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)
|
||||||
|
|
||||||
|
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren