mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-05-06 13:22:58 +00:00
Code refactoring (#889)
* Add __all__ to all module and plugin utils. * Convert quite a few positional args to keyword args. * Avoid Python 3.8+ syntax.
This commit is contained in:
@@ -17,7 +17,7 @@ if t.TYPE_CHECKING:
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def load_file(path: str | os.PathLike, module: AnsibleModule | None = None) -> bytes:
|
||||
def load_file(*, path: str | os.PathLike, module: AnsibleModule | None = None) -> bytes:
|
||||
"""
|
||||
Load the file as a bytes string.
|
||||
"""
|
||||
@@ -31,6 +31,7 @@ def load_file(path: str | os.PathLike, module: AnsibleModule | None = None) -> b
|
||||
|
||||
|
||||
def load_file_if_exists(
|
||||
*,
|
||||
path: str | os.PathLike,
|
||||
module: AnsibleModule | None = None,
|
||||
ignore_errors: bool = False,
|
||||
@@ -62,6 +63,7 @@ def load_file_if_exists(
|
||||
|
||||
|
||||
def write_file(
|
||||
*,
|
||||
module: AnsibleModule,
|
||||
content: bytes,
|
||||
default_mode: str | int | None = None,
|
||||
@@ -117,3 +119,6 @@ def write_file(
|
||||
except Exception:
|
||||
pass
|
||||
module.fail_json(msg=f"Error while writing result: {e}")
|
||||
|
||||
|
||||
__all__ = ("load_file", "load_file_if_exists", "write_file")
|
||||
|
||||
Reference in New Issue
Block a user