mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
refactor: remove unneeded to_native calls (#477)
##### SUMMARY Since we only support python >=3.8, the `to_native` python2/3 compatibility function is not needed anymore. We only keep it for printing a traceback free exception message. Where a type conversion is needed, we use the built-in `str()` function.
This commit is contained in:
parent
64f7824cc8
commit
4bb02b9cd2
34 changed files with 394 additions and 453 deletions
|
|
@ -79,7 +79,6 @@ hcloud_ssh_key_info:
|
|||
"""
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
|
||||
from ..module_utils.hcloud import AnsibleHCloud
|
||||
from ..module_utils.vendor.hcloud import HCloudException
|
||||
|
|
@ -92,20 +91,22 @@ class AnsibleHCloudSSHKeyInfo(AnsibleHCloud):
|
|||
hcloud_ssh_key_info: list[BoundSSHKey] | None = None
|
||||
|
||||
def _prepare_result(self):
|
||||
ssh_keys = []
|
||||
tmp = []
|
||||
|
||||
for ssh_key in self.hcloud_ssh_key_info:
|
||||
if ssh_key:
|
||||
ssh_keys.append(
|
||||
{
|
||||
"id": to_native(ssh_key.id),
|
||||
"name": to_native(ssh_key.name),
|
||||
"fingerprint": to_native(ssh_key.fingerprint),
|
||||
"public_key": to_native(ssh_key.public_key),
|
||||
"labels": ssh_key.labels,
|
||||
}
|
||||
)
|
||||
return ssh_keys
|
||||
if ssh_key is None:
|
||||
continue
|
||||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(ssh_key.id),
|
||||
"name": ssh_key.name,
|
||||
"fingerprint": ssh_key.fingerprint,
|
||||
"public_key": ssh_key.public_key,
|
||||
"labels": ssh_key.labels,
|
||||
}
|
||||
)
|
||||
return tmp
|
||||
|
||||
def get_ssh_keys(self):
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue