mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-05-07 05:43:06 +00:00
Replace to_native with to_text. (#897)
This commit is contained in:
@@ -277,7 +277,7 @@ _value:
|
||||
import typing as t
|
||||
|
||||
from ansible.errors import AnsibleFilterError
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_text
|
||||
from ansible_collections.community.crypto.plugins.module_utils._crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -301,7 +301,7 @@ def openssl_csr_info_filter(
|
||||
raise AnsibleFilterError(
|
||||
f"The name_encoding option must be of a text type, not {type(name_encoding)}"
|
||||
)
|
||||
name_encoding = to_native(name_encoding)
|
||||
name_encoding = to_text(name_encoding)
|
||||
if name_encoding not in ("ignore", "idna", "unicode"):
|
||||
raise AnsibleFilterError(
|
||||
f'The name_encoding option must be one of the values "ignore", "idna", or "unicode", not "{name_encoding}"'
|
||||
|
||||
@@ -42,7 +42,7 @@ _value:
|
||||
import typing as t
|
||||
|
||||
from ansible.errors import AnsibleFilterError
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible.module_utils.common.text.converters import to_text
|
||||
from ansible_collections.community.crypto.plugins.module_utils._serial import (
|
||||
parse_serial,
|
||||
)
|
||||
@@ -54,7 +54,7 @@ def parse_serial_filter(serial_str: str | bytes) -> int:
|
||||
f"The input for the community.crypto.parse_serial filter must be a string; got {type(serial_str)} instead"
|
||||
)
|
||||
try:
|
||||
return parse_serial(to_native(serial_str))
|
||||
return parse_serial(to_text(serial_str))
|
||||
except ValueError as exc:
|
||||
raise AnsibleFilterError(str(exc)) from exc
|
||||
|
||||
|
||||
@@ -311,7 +311,7 @@ _value:
|
||||
import typing as t
|
||||
|
||||
from ansible.errors import AnsibleFilterError
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_text
|
||||
from ansible_collections.community.crypto.plugins.module_utils._crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -335,7 +335,7 @@ def x509_certificate_info_filter(
|
||||
raise AnsibleFilterError(
|
||||
f"The name_encoding option must be of a text type, not {type(name_encoding)}"
|
||||
)
|
||||
name_encoding = to_native(name_encoding)
|
||||
name_encoding = to_text(name_encoding)
|
||||
if name_encoding not in ("ignore", "idna", "unicode"):
|
||||
raise AnsibleFilterError(
|
||||
f'The name_encoding option must be one of the values "ignore", "idna", or "unicode", not "{name_encoding}"'
|
||||
|
||||
@@ -158,7 +158,7 @@ import binascii
|
||||
import typing as t
|
||||
|
||||
from ansible.errors import AnsibleFilterError
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_text
|
||||
from ansible_collections.community.crypto.plugins.module_utils._crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -191,7 +191,7 @@ def x509_crl_info_filter(
|
||||
raise AnsibleFilterError(
|
||||
f"The list_revoked_certificates option must be a boolean, not {type(list_revoked_certificates)}"
|
||||
)
|
||||
name_encoding = to_native(name_encoding)
|
||||
name_encoding = to_text(name_encoding)
|
||||
if name_encoding not in ("ignore", "idna", "unicode"):
|
||||
raise AnsibleFilterError(
|
||||
f'The name_encoding option must be one of the values "ignore", "idna", or "unicode", not "{name_encoding}"'
|
||||
@@ -200,7 +200,7 @@ def x509_crl_info_filter(
|
||||
data_bytes = to_bytes(data)
|
||||
if not identify_pem_format(data_bytes):
|
||||
try:
|
||||
data_bytes = base64.b64decode(to_native(data_bytes))
|
||||
data_bytes = base64.b64decode(to_text(data_bytes))
|
||||
except (binascii.Error, TypeError, ValueError, UnicodeEncodeError):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user