mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-03-26 21:33:25 +00:00
Remove six usages. (#884)
This commit is contained in:
@@ -10,7 +10,6 @@ import datetime
|
||||
import re
|
||||
from collections import namedtuple
|
||||
|
||||
from ansible.module_utils import six
|
||||
from ansible_collections.community.crypto.plugins.module_utils.acme.errors import (
|
||||
BackendException,
|
||||
)
|
||||
@@ -86,8 +85,7 @@ def _parse_acme_timestamp(timestamp_str, with_timezone):
|
||||
raise BackendException(f"Cannot parse ISO 8601 timestamp {timestamp_str!r}")
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class CryptoBackend:
|
||||
class CryptoBackend(metaclass=abc.ABCMeta):
|
||||
def __init__(self, module, with_timezone=False):
|
||||
self.module = module
|
||||
self._with_timezone = with_timezone
|
||||
|
||||
@@ -7,7 +7,6 @@ from __future__ import annotations
|
||||
|
||||
import abc
|
||||
|
||||
from ansible.module_utils import six
|
||||
from ansible_collections.community.crypto.plugins.module_utils.acme.errors import (
|
||||
ModuleFailException,
|
||||
)
|
||||
@@ -98,8 +97,7 @@ class Criterium:
|
||||
self.authority_key_identifier = criterium["authority_key_identifier"]
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class ChainMatcher:
|
||||
class ChainMatcher(metaclass=abc.ABCMeta):
|
||||
@abc.abstractmethod
|
||||
def match(self, certificate):
|
||||
"""
|
||||
|
||||
@@ -7,7 +7,6 @@ from __future__ import annotations
|
||||
|
||||
import abc
|
||||
|
||||
from ansible.module_utils import six
|
||||
from ansible_collections.community.crypto.plugins.module_utils.argspec import (
|
||||
ArgumentSpec,
|
||||
)
|
||||
@@ -47,8 +46,7 @@ class CertificateError(OpenSSLObjectError):
|
||||
pass
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class CertificateBackend:
|
||||
class CertificateBackend(metaclass=abc.ABCMeta):
|
||||
def __init__(self, module):
|
||||
self.module = module
|
||||
|
||||
@@ -308,8 +306,7 @@ class CertificateBackend:
|
||||
return result
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class CertificateProvider:
|
||||
class CertificateProvider(metaclass=abc.ABCMeta):
|
||||
@abc.abstractmethod
|
||||
def validate_module_args(self, module):
|
||||
"""Check module arguments"""
|
||||
|
||||
@@ -9,7 +9,6 @@ from __future__ import annotations
|
||||
import abc
|
||||
import binascii
|
||||
|
||||
from ansible.module_utils import six
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.cryptography_support import (
|
||||
CRYPTOGRAPHY_TIMEZONE,
|
||||
@@ -48,8 +47,7 @@ except ImportError:
|
||||
TIMESTAMP_FORMAT = "%Y%m%d%H%M%SZ"
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class CertificateInfoRetrieval:
|
||||
class CertificateInfoRetrieval(metaclass=abc.ABCMeta):
|
||||
def __init__(self, module, content):
|
||||
# content must be a bytes string
|
||||
self.module = module
|
||||
|
||||
@@ -8,7 +8,6 @@ from __future__ import annotations
|
||||
import abc
|
||||
import binascii
|
||||
|
||||
from ansible.module_utils import six
|
||||
from ansible.module_utils.common.text.converters import to_text
|
||||
from ansible_collections.community.crypto.plugins.module_utils.argspec import (
|
||||
ArgumentSpec,
|
||||
@@ -69,8 +68,7 @@ class CertificateSigningRequestError(OpenSSLObjectError):
|
||||
# - module.fail_json(msg: str, **kwargs)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class CertificateSigningRequestBackend:
|
||||
class CertificateSigningRequestBackend(metaclass=abc.ABCMeta):
|
||||
def __init__(self, module):
|
||||
self.module = module
|
||||
self.digest = module.params["digest"]
|
||||
|
||||
@@ -9,7 +9,6 @@ from __future__ import annotations
|
||||
import abc
|
||||
import binascii
|
||||
|
||||
from ansible.module_utils import six
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.cryptography_support import (
|
||||
cryptography_decode_name,
|
||||
@@ -41,8 +40,7 @@ except ImportError:
|
||||
TIMESTAMP_FORMAT = "%Y%m%d%H%M%SZ"
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class CSRInfoRetrieval:
|
||||
class CSRInfoRetrieval(metaclass=abc.ABCMeta):
|
||||
def __init__(self, module, content, validate_signature):
|
||||
# content must be a bytes string
|
||||
self.module = module
|
||||
|
||||
@@ -9,7 +9,6 @@ import abc
|
||||
import base64
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils import six
|
||||
from ansible.module_utils.common.text.converters import to_bytes
|
||||
from ansible_collections.community.crypto.plugins.module_utils.argspec import (
|
||||
ArgumentSpec,
|
||||
@@ -64,8 +63,7 @@ class PrivateKeyError(OpenSSLObjectError):
|
||||
# - module.fail_json(msg: str, **kwargs)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class PrivateKeyBackend:
|
||||
class PrivateKeyBackend(metaclass=abc.ABCMeta):
|
||||
def __init__(self, module):
|
||||
self.module = module
|
||||
self.type = module.params["type"]
|
||||
|
||||
@@ -7,7 +7,6 @@ from __future__ import annotations
|
||||
import abc
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils import six
|
||||
from ansible.module_utils.common.text.converters import to_bytes
|
||||
from ansible_collections.community.crypto.plugins.module_utils.argspec import (
|
||||
ArgumentSpec,
|
||||
@@ -58,8 +57,7 @@ class PrivateKeyError(OpenSSLObjectError):
|
||||
# - module.fail_json(msg: str, **kwargs)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class PrivateKeyConvertBackend:
|
||||
class PrivateKeyConvertBackend(metaclass=abc.ABCMeta):
|
||||
def __init__(self, module):
|
||||
self.module = module
|
||||
self.src_path = module.params["src_path"]
|
||||
|
||||
@@ -8,7 +8,6 @@ from __future__ import annotations
|
||||
|
||||
import abc
|
||||
|
||||
from ansible.module_utils import six
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
@@ -172,8 +171,7 @@ class PrivateKeyParseError(OpenSSLObjectError):
|
||||
self.result = result
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class PrivateKeyInfoRetrieval:
|
||||
class PrivateKeyInfoRetrieval(metaclass=abc.ABCMeta):
|
||||
def __init__(
|
||||
self,
|
||||
module,
|
||||
|
||||
@@ -6,7 +6,6 @@ from __future__ import annotations
|
||||
|
||||
import abc
|
||||
|
||||
from ansible.module_utils import six
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -85,8 +84,7 @@ class PublicKeyParseError(OpenSSLObjectError):
|
||||
self.result = result
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class PublicKeyInfoRetrieval:
|
||||
class PublicKeyInfoRetrieval(metaclass=abc.ABCMeta):
|
||||
def __init__(self, module, content=None, key=None):
|
||||
# content must be a bytes string
|
||||
self.module = module
|
||||
|
||||
@@ -9,7 +9,6 @@ import errno
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
from ansible.module_utils import six
|
||||
from ansible.module_utils.common.text.converters import to_bytes
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.pem import (
|
||||
identify_pem_format,
|
||||
@@ -218,7 +217,7 @@ def parse_name_field(input_dict, name_field_name=None):
|
||||
for key, value in input_dict.items():
|
||||
if isinstance(value, list):
|
||||
for entry in value:
|
||||
if not isinstance(entry, six.string_types):
|
||||
if not isinstance(entry, (str, bytes)):
|
||||
raise TypeError(
|
||||
f"Values {error_str} must be strings".format(
|
||||
key=key, name=name_field_name
|
||||
@@ -231,7 +230,7 @@ def parse_name_field(input_dict, name_field_name=None):
|
||||
)
|
||||
)
|
||||
result.append((key, entry))
|
||||
elif isinstance(value, six.string_types):
|
||||
elif isinstance(value, (str, bytes)):
|
||||
if not value:
|
||||
raise ValueError(
|
||||
f"Value for {error_str} must not be an empty string".format(
|
||||
@@ -281,8 +280,7 @@ def select_message_digest(digest_string):
|
||||
return digest
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class OpenSSLObject:
|
||||
class OpenSSLObject(metaclass=abc.ABCMeta):
|
||||
|
||||
def __init__(self, path, state, force, check_mode):
|
||||
self.path = path
|
||||
|
||||
@@ -7,15 +7,12 @@ from __future__ import annotations
|
||||
import abc
|
||||
import os
|
||||
|
||||
from ansible.module_utils import six
|
||||
|
||||
|
||||
class GPGError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class GPGRunner:
|
||||
class GPGRunner(metaclass=abc.ABCMeta):
|
||||
@abc.abstractmethod
|
||||
def run_command(self, command, check_rc=True, data=None):
|
||||
"""
|
||||
|
||||
@@ -9,7 +9,6 @@ import os
|
||||
import stat
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils import six
|
||||
from ansible_collections.community.crypto.plugins.module_utils.openssh.utils import (
|
||||
parse_openssh_version,
|
||||
)
|
||||
@@ -59,8 +58,7 @@ def _restore_all_on_failure(f):
|
||||
return backup_and_restore
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class OpensshModule:
|
||||
class OpensshModule(metaclass=abc.ABCMeta):
|
||||
def __init__(self, module):
|
||||
self.module = module
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ from __future__ import annotations
|
||||
import abc
|
||||
import os
|
||||
|
||||
from ansible.module_utils import six
|
||||
from ansible.module_utils.basic import missing_required_lib
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_text
|
||||
from ansible_collections.community.crypto.plugins.module_utils.cryptography_dep import (
|
||||
@@ -40,8 +39,7 @@ from ansible_collections.community.crypto.plugins.module_utils.version import (
|
||||
)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class KeypairBackend(OpensshModule):
|
||||
class KeypairBackend(OpensshModule, metaclass=abc.ABCMeta):
|
||||
|
||||
def __init__(self, module):
|
||||
super(KeypairBackend, self).__init__(module)
|
||||
|
||||
@@ -12,7 +12,6 @@ from base64 import b64encode
|
||||
from datetime import datetime
|
||||
from hashlib import sha256
|
||||
|
||||
from ansible.module_utils import six
|
||||
from ansible.module_utils.common.text.converters import to_text
|
||||
from ansible_collections.community.crypto.plugins.module_utils.openssh.utils import (
|
||||
OpensshParser,
|
||||
@@ -159,7 +158,7 @@ class OpensshCertificateTimeParameters:
|
||||
@staticmethod
|
||||
def to_datetime(time_string_or_timestamp):
|
||||
try:
|
||||
if isinstance(time_string_or_timestamp, six.string_types):
|
||||
if isinstance(time_string_or_timestamp, (str, bytes)):
|
||||
result = OpensshCertificateTimeParameters._time_string_to_datetime(
|
||||
time_string_or_timestamp.strip()
|
||||
)
|
||||
@@ -216,10 +215,10 @@ class OpensshCertificateOption:
|
||||
if option_type not in ("critical", "extension"):
|
||||
raise ValueError("type must be either 'critical' or 'extension'")
|
||||
|
||||
if not isinstance(name, six.string_types):
|
||||
if not isinstance(name, (str, bytes)):
|
||||
raise TypeError(f"name must be a string not {type(name)}")
|
||||
|
||||
if not isinstance(data, six.string_types):
|
||||
if not isinstance(data, (str, bytes)):
|
||||
raise TypeError(f"data must be a string not {type(data)}")
|
||||
|
||||
self._option_type = option_type
|
||||
@@ -263,7 +262,7 @@ class OpensshCertificateOption:
|
||||
|
||||
@classmethod
|
||||
def from_string(cls, option_string):
|
||||
if not isinstance(option_string, six.string_types):
|
||||
if not isinstance(option_string, (str, bytes)):
|
||||
raise ValueError(
|
||||
f"option_string must be a string not {type(option_string)}"
|
||||
)
|
||||
@@ -287,8 +286,7 @@ class OpensshCertificateOption:
|
||||
)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class OpensshCertificateInfo:
|
||||
class OpensshCertificateInfo(metaclass=abc.ABCMeta):
|
||||
"""Encapsulates all certificate information which is signed by a CA key"""
|
||||
|
||||
def __init__(
|
||||
|
||||
Reference in New Issue
Block a user