ansible-core 2.19.4rc1__py3-none-any.whl → 2.20.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ansible-core might be problematic. Click here for more details.
- ansible/_internal/__init__.py +1 -4
- ansible/_internal/_ansiballz/_builder.py +1 -3
- ansible/_internal/_collection_proxy.py +7 -9
- ansible/_internal/_json/__init__.py +3 -4
- ansible/_internal/_templating/_engine.py +1 -1
- ansible/_internal/_templating/_jinja_plugins.py +1 -2
- ansible/_internal/_wrapt.py +105 -301
- ansible/cli/__init__.py +11 -10
- ansible/cli/adhoc.py +1 -2
- ansible/cli/arguments/option_helpers.py +1 -1
- ansible/cli/config.py +5 -6
- ansible/cli/doc.py +67 -67
- ansible/cli/galaxy.py +15 -24
- ansible/cli/inventory.py +0 -1
- ansible/cli/playbook.py +0 -1
- ansible/cli/pull.py +0 -1
- ansible/cli/scripts/ansible_connection_cli_stub.py +1 -1
- ansible/config/base.yml +1 -25
- ansible/config/manager.py +0 -2
- ansible/executor/play_iterator.py +42 -20
- ansible/executor/playbook_executor.py +0 -9
- ansible/executor/task_executor.py +26 -18
- ansible/executor/task_queue_manager.py +1 -3
- ansible/galaxy/api.py +33 -80
- ansible/galaxy/collection/__init__.py +11 -21
- ansible/galaxy/dependency_resolution/__init__.py +10 -9
- ansible/galaxy/dependency_resolution/dataclasses.py +86 -70
- ansible/galaxy/dependency_resolution/providers.py +54 -134
- ansible/galaxy/dependency_resolution/versioning.py +2 -4
- ansible/galaxy/role.py +1 -33
- ansible/inventory/manager.py +2 -3
- ansible/keyword_desc.yml +0 -3
- ansible/module_utils/_internal/_datatag/__init__.py +2 -10
- ansible/module_utils/_internal/_no_six.py +86 -0
- ansible/module_utils/_text.py +28 -8
- ansible/module_utils/ansible_release.py +2 -2
- ansible/module_utils/basic.py +26 -23
- ansible/module_utils/common/_collections_compat.py +11 -2
- ansible/module_utils/common/collections.py +8 -3
- ansible/module_utils/common/dict_transformations.py +1 -2
- ansible/module_utils/common/network.py +4 -2
- ansible/module_utils/common/parameters.py +32 -41
- ansible/module_utils/common/text/converters.py +109 -23
- ansible/module_utils/common/text/formatters.py +6 -2
- ansible/module_utils/common/validation.py +11 -9
- ansible/module_utils/connection.py +8 -3
- ansible/module_utils/facts/hardware/linux.py +23 -7
- ansible/module_utils/facts/hardware/netbsd.py +1 -1
- ansible/module_utils/facts/hardware/sunos.py +2 -1
- ansible/module_utils/facts/packages.py +6 -2
- ansible/module_utils/facts/system/distribution.py +2 -1
- ansible/module_utils/facts/system/env.py +6 -3
- ansible/module_utils/facts/system/local.py +3 -1
- ansible/module_utils/parsing/convert_bool.py +6 -2
- ansible/module_utils/service.py +2 -3
- ansible/module_utils/six/__init__.py +11 -6
- ansible/module_utils/yumdnf.py +0 -5
- ansible/modules/apt.py +18 -13
- ansible/modules/apt_repository.py +1 -1
- ansible/modules/assemble.py +5 -9
- ansible/modules/blockinfile.py +39 -23
- ansible/modules/cron.py +26 -35
- ansible/modules/deb822_repository.py +83 -12
- ansible/modules/dnf.py +3 -7
- ansible/modules/dnf5.py +4 -6
- ansible/modules/expect.py +0 -3
- ansible/modules/find.py +1 -2
- ansible/modules/get_url.py +1 -1
- ansible/modules/git.py +4 -5
- ansible/modules/include_vars.py +1 -1
- ansible/modules/known_hosts.py +7 -1
- ansible/modules/lineinfile.py +71 -63
- ansible/modules/package_facts.py +1 -1
- ansible/modules/pip.py +8 -2
- ansible/modules/replace.py +6 -6
- ansible/modules/service.py +3 -4
- ansible/modules/stat.py +20 -0
- ansible/modules/uri.py +9 -10
- ansible/modules/user.py +1 -2
- ansible/modules/wait_for.py +2 -2
- ansible/modules/wait_for_connection.py +2 -1
- ansible/modules/yum_repository.py +1 -16
- ansible/parsing/dataloader.py +24 -31
- ansible/parsing/vault/__init__.py +1 -2
- ansible/playbook/base.py +8 -56
- ansible/playbook/block.py +0 -60
- ansible/playbook/collectionsearch.py +1 -2
- ansible/playbook/handler.py +1 -7
- ansible/playbook/helpers.py +0 -7
- ansible/playbook/included_file.py +1 -1
- ansible/playbook/play.py +102 -36
- ansible/playbook/play_context.py +4 -0
- ansible/playbook/role/__init__.py +10 -65
- ansible/playbook/role/definition.py +3 -4
- ansible/playbook/role/include.py +2 -3
- ansible/playbook/role/metadata.py +1 -12
- ansible/playbook/role/requirement.py +1 -2
- ansible/playbook/role_include.py +1 -2
- ansible/playbook/taggable.py +16 -5
- ansible/playbook/task.py +11 -50
- ansible/plugins/action/__init__.py +20 -19
- ansible/plugins/action/add_host.py +1 -2
- ansible/plugins/action/fetch.py +3 -5
- ansible/plugins/action/group_by.py +1 -2
- ansible/plugins/action/include_vars.py +20 -22
- ansible/plugins/action/script.py +1 -3
- ansible/plugins/action/template.py +1 -2
- ansible/plugins/action/uri.py +4 -2
- ansible/plugins/cache/__init__.py +1 -0
- ansible/plugins/callback/__init__.py +13 -6
- ansible/plugins/connection/__init__.py +3 -7
- ansible/plugins/connection/local.py +2 -3
- ansible/plugins/connection/psrp.py +0 -2
- ansible/plugins/connection/ssh.py +2 -7
- ansible/plugins/connection/winrm.py +0 -2
- ansible/plugins/doc_fragments/result_format_callback.py +15 -0
- ansible/plugins/filter/core.py +4 -5
- ansible/plugins/filter/encryption.py +3 -27
- ansible/plugins/filter/mathstuff.py +1 -2
- ansible/plugins/filter/to_nice_yaml.yml +31 -3
- ansible/plugins/filter/to_yaml.yml +29 -12
- ansible/plugins/inventory/__init__.py +1 -2
- ansible/plugins/inventory/toml.py +3 -6
- ansible/plugins/inventory/yaml.py +1 -2
- ansible/plugins/loader.py +3 -4
- ansible/plugins/lookup/password.py +1 -2
- ansible/plugins/lookup/subelements.py +2 -3
- ansible/plugins/lookup/url.py +1 -1
- ansible/plugins/lookup/varnames.py +1 -2
- ansible/plugins/shell/__init__.py +9 -4
- ansible/plugins/shell/powershell.py +8 -24
- ansible/plugins/strategy/__init__.py +5 -2
- ansible/plugins/test/core.py +4 -1
- ansible/plugins/test/falsy.yml +1 -1
- ansible/plugins/test/regex.yml +18 -6
- ansible/plugins/test/truthy.yml +1 -1
- ansible/release.py +2 -2
- ansible/template/__init__.py +3 -7
- ansible/utils/collection_loader/_collection_config.py +5 -0
- ansible/utils/collection_loader/_collection_finder.py +11 -14
- ansible/utils/context_objects.py +7 -4
- ansible/utils/display.py +7 -6
- ansible/utils/encrypt.py +0 -5
- ansible/utils/helpers.py +6 -2
- ansible/utils/jsonrpc.py +7 -3
- ansible/utils/plugin_docs.py +49 -38
- ansible/utils/ssh_functions.py +0 -19
- ansible/utils/unsafe_proxy.py +7 -7
- ansible/vars/clean.py +2 -3
- ansible/vars/manager.py +28 -22
- ansible/vars/plugins.py +1 -31
- {ansible_core-2.19.4rc1.dist-info → ansible_core-2.20.0.dist-info}/METADATA +4 -4
- {ansible_core-2.19.4rc1.dist-info → ansible_core-2.20.0.dist-info}/RECORD +213 -214
- ansible_test/_data/completion/docker.txt +7 -7
- ansible_test/_data/completion/network.txt +0 -1
- ansible_test/_data/completion/remote.txt +4 -4
- ansible_test/_data/requirements/ansible-test.txt +1 -1
- ansible_test/_data/requirements/ansible.txt +1 -1
- ansible_test/_data/requirements/sanity.ansible-doc.txt +2 -2
- ansible_test/_data/requirements/sanity.changelog.txt +2 -2
- ansible_test/_data/requirements/sanity.import.plugin.txt +2 -2
- ansible_test/_data/requirements/sanity.import.txt +1 -1
- ansible_test/_data/requirements/sanity.integration-aliases.txt +1 -1
- ansible_test/_data/requirements/sanity.pep8.txt +1 -1
- ansible_test/_data/requirements/sanity.pylint.txt +6 -6
- ansible_test/_data/requirements/sanity.runtime-metadata.txt +1 -1
- ansible_test/_data/requirements/sanity.validate-modules.txt +2 -2
- ansible_test/_data/requirements/sanity.yamllint.txt +1 -1
- ansible_test/_internal/cache.py +2 -5
- ansible_test/_internal/cli/compat.py +1 -1
- ansible_test/_internal/commands/coverage/combine.py +1 -3
- ansible_test/_internal/commands/integration/__init__.py +3 -7
- ansible_test/_internal/commands/integration/cloud/httptester.py +1 -1
- ansible_test/_internal/commands/integration/coverage.py +1 -3
- ansible_test/_internal/commands/integration/filters.py +5 -10
- ansible_test/_internal/commands/sanity/pylint.py +11 -0
- ansible_test/_internal/commands/sanity/validate_modules.py +1 -5
- ansible_test/_internal/commands/units/__init__.py +1 -13
- ansible_test/_internal/compat/packaging.py +2 -2
- ansible_test/_internal/compat/yaml.py +2 -2
- ansible_test/_internal/completion.py +2 -5
- ansible_test/_internal/config.py +2 -7
- ansible_test/_internal/coverage_util.py +1 -1
- ansible_test/_internal/delegation.py +2 -0
- ansible_test/_internal/docker_util.py +1 -1
- ansible_test/_internal/host_profiles.py +6 -11
- ansible_test/_internal/provider/__init__.py +2 -5
- ansible_test/_internal/provisioning.py +2 -5
- ansible_test/_internal/pypi_proxy.py +1 -1
- ansible_test/_internal/python_requirements.py +1 -1
- ansible_test/_internal/target.py +2 -6
- ansible_test/_internal/thread.py +1 -4
- ansible_test/_internal/util.py +9 -14
- ansible_test/_util/controller/sanity/code-smell/runtime-metadata.py +14 -19
- ansible_test/_util/controller/sanity/pylint/plugins/deprecated_calls.py +48 -45
- ansible_test/_util/controller/sanity/pylint/plugins/string_format.py +9 -7
- ansible_test/_util/controller/sanity/pylint/plugins/unwanted.py +51 -37
- ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py +31 -18
- ansible_test/_util/controller/sanity/validate-modules/validate_modules/module_args.py +1 -2
- ansible_test/_util/controller/sanity/validate-modules/validate_modules/schema.py +59 -71
- ansible_test/_util/controller/sanity/validate-modules/validate_modules/utils.py +1 -2
- ansible_test/_util/target/cli/ansible_test_cli_stub.py +4 -2
- ansible_test/_util/target/common/constants.py +2 -2
- ansible_test/_util/target/setup/bootstrap.sh +0 -6
- ansible/utils/py3compat.py +0 -27
- ansible_test/_data/pytest/config/legacy.ini +0 -4
- {ansible_core-2.19.4rc1.dist-info → ansible_core-2.20.0.dist-info}/WHEEL +0 -0
- {ansible_core-2.19.4rc1.dist-info → ansible_core-2.20.0.dist-info}/entry_points.txt +0 -0
- {ansible_core-2.19.4rc1.dist-info → ansible_core-2.20.0.dist-info}/licenses/COPYING +0 -0
- {ansible_core-2.19.4rc1.dist-info → ansible_core-2.20.0.dist-info}/licenses/licenses/Apache-License.txt +0 -0
- {ansible_core-2.19.4rc1.dist-info → ansible_core-2.20.0.dist-info}/licenses/licenses/BSD-3-Clause.txt +0 -0
- {ansible_core-2.19.4rc1.dist-info → ansible_core-2.20.0.dist-info}/licenses/licenses/MIT-license.txt +0 -0
- {ansible_core-2.19.4rc1.dist-info → ansible_core-2.20.0.dist-info}/licenses/licenses/PSF-license.txt +0 -0
- {ansible_core-2.19.4rc1.dist-info → ansible_core-2.20.0.dist-info}/licenses/licenses/simplified_bsd.txt +0 -0
- {ansible_core-2.19.4rc1.dist-info → ansible_core-2.20.0.dist-info}/top_level.txt +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
|
|
3
3
|
"""Collections ABC import shim.
|
|
4
4
|
|
|
5
|
-
Use `
|
|
5
|
+
Use `collections.abc` instead.
|
|
6
6
|
This module exists only for backwards compatibility.
|
|
7
7
|
"""
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ from __future__ import annotations
|
|
|
10
10
|
|
|
11
11
|
# Although this was originally intended for internal use only, it has wide adoption in collections.
|
|
12
12
|
# This is due in part to sanity tests previously recommending its use over `collections` imports.
|
|
13
|
-
from
|
|
13
|
+
from collections.abc import ( # pylint: disable=unused-import
|
|
14
14
|
MappingView,
|
|
15
15
|
ItemsView,
|
|
16
16
|
KeysView,
|
|
@@ -25,3 +25,12 @@ from ansible.module_utils.six.moves.collections_abc import ( # pylint: disable=
|
|
|
25
25
|
Iterable,
|
|
26
26
|
Iterator,
|
|
27
27
|
)
|
|
28
|
+
|
|
29
|
+
from ansible.module_utils.common import warnings as _warnings
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
_warnings.deprecate(
|
|
33
|
+
msg="The `ansible.module_utils.common._collections_compat` module is deprecated.",
|
|
34
|
+
help_text="Use `collections.abc` from the Python standard library instead.",
|
|
35
|
+
version="2.24",
|
|
36
|
+
)
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
from collections.abc import Hashable, Mapping, MutableMapping, Sequence # pylint: disable=unused-import
|
|
10
|
+
|
|
11
|
+
from ansible.module_utils._internal import _no_six
|
|
9
12
|
from ansible.module_utils.common import warnings as _warnings
|
|
10
|
-
from ansible.module_utils.six import binary_type, text_type
|
|
11
|
-
from ansible.module_utils.six.moves.collections_abc import Hashable, Mapping, MutableMapping, Sequence # pylint: disable=unused-import
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class ImmutableDict(Hashable, Mapping):
|
|
@@ -67,7 +68,7 @@ class ImmutableDict(Hashable, Mapping):
|
|
|
67
68
|
|
|
68
69
|
def is_string(seq):
|
|
69
70
|
"""Identify whether the input has a string-like type (including bytes)."""
|
|
70
|
-
return isinstance(seq, (
|
|
71
|
+
return isinstance(seq, (str, bytes))
|
|
71
72
|
|
|
72
73
|
|
|
73
74
|
def is_iterable(seq, include_strings=False):
|
|
@@ -114,3 +115,7 @@ def count(seq):
|
|
|
114
115
|
for elem in seq:
|
|
115
116
|
counters[elem] = counters.get(elem, 0) + 1
|
|
116
117
|
return counters
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def __getattr__(importable_name):
|
|
121
|
+
return _no_six.deprecate(importable_name, __name__, "binary_type", "text_type")
|
|
@@ -7,10 +7,9 @@ from __future__ import annotations
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
import re
|
|
10
|
+
from collections.abc import MutableMapping
|
|
10
11
|
from copy import deepcopy
|
|
11
12
|
|
|
12
|
-
from ansible.module_utils.six.moves.collections_abc import MutableMapping
|
|
13
|
-
|
|
14
13
|
|
|
15
14
|
def camel_dict_to_snake_dict(camel_dict, reversible=False, ignore_list=()):
|
|
16
15
|
"""
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
import re
|
|
9
|
+
|
|
10
|
+
# backward compat
|
|
11
|
+
from builtins import zip # pylint: disable=unused-import
|
|
12
|
+
|
|
9
13
|
from struct import pack
|
|
10
14
|
from socket import inet_ntoa
|
|
11
15
|
|
|
12
|
-
from ansible.module_utils.six.moves import zip
|
|
13
|
-
|
|
14
16
|
|
|
15
17
|
VALID_MASKS = [2**8 - 2**i for i in range(0, 9)]
|
|
16
18
|
|
|
@@ -9,9 +9,19 @@ import os
|
|
|
9
9
|
import typing as t
|
|
10
10
|
|
|
11
11
|
from collections import deque
|
|
12
|
-
from
|
|
12
|
+
from collections.abc import (
|
|
13
|
+
KeysView,
|
|
14
|
+
Set,
|
|
15
|
+
Sequence,
|
|
16
|
+
Mapping,
|
|
17
|
+
MutableMapping,
|
|
18
|
+
MutableSet,
|
|
19
|
+
MutableSequence,
|
|
20
|
+
)
|
|
21
|
+
from itertools import chain # pylint: disable=unused-import
|
|
13
22
|
|
|
14
23
|
from ansible.module_utils.common.collections import is_iterable
|
|
24
|
+
from ansible.module_utils._internal import _no_six
|
|
15
25
|
from ansible.module_utils._internal._datatag import AnsibleSerializable, AnsibleTagHelper
|
|
16
26
|
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
|
|
17
27
|
from ansible.module_utils.common.warnings import warn
|
|
@@ -33,26 +43,6 @@ from ansible.module_utils.errors import (
|
|
|
33
43
|
SubParameterTypeError,
|
|
34
44
|
)
|
|
35
45
|
from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE, BOOLEANS_TRUE
|
|
36
|
-
|
|
37
|
-
from ansible.module_utils.six.moves.collections_abc import (
|
|
38
|
-
KeysView,
|
|
39
|
-
Set,
|
|
40
|
-
Sequence,
|
|
41
|
-
Mapping,
|
|
42
|
-
MutableMapping,
|
|
43
|
-
MutableSet,
|
|
44
|
-
MutableSequence,
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
from ansible.module_utils.six import (
|
|
48
|
-
binary_type,
|
|
49
|
-
integer_types,
|
|
50
|
-
string_types,
|
|
51
|
-
text_type,
|
|
52
|
-
PY2,
|
|
53
|
-
PY3,
|
|
54
|
-
)
|
|
55
|
-
|
|
56
46
|
from ansible.module_utils.common.validation import (
|
|
57
47
|
check_mutually_exclusive,
|
|
58
48
|
check_required_arguments,
|
|
@@ -243,7 +233,7 @@ def _handle_aliases(argument_spec, parameters, alias_warnings=None, alias_deprec
|
|
|
243
233
|
if aliases is None:
|
|
244
234
|
continue
|
|
245
235
|
|
|
246
|
-
if not is_iterable(aliases) or isinstance(aliases, (
|
|
236
|
+
if not is_iterable(aliases) or isinstance(aliases, (bytes, str)):
|
|
247
237
|
raise TypeError('internal error: aliases must be a list or tuple')
|
|
248
238
|
|
|
249
239
|
for alias in aliases:
|
|
@@ -346,7 +336,7 @@ def _list_no_log_values(argument_spec, params):
|
|
|
346
336
|
for sub_param in sub_parameters:
|
|
347
337
|
# Validate dict fields in case they came in as strings
|
|
348
338
|
|
|
349
|
-
if isinstance(sub_param,
|
|
339
|
+
if isinstance(sub_param, str):
|
|
350
340
|
sub_param = check_type_dict(sub_param)
|
|
351
341
|
|
|
352
342
|
if not isinstance(sub_param, Mapping):
|
|
@@ -362,7 +352,7 @@ def _return_datastructure_name(obj):
|
|
|
362
352
|
""" Return native stringified values from datastructures.
|
|
363
353
|
|
|
364
354
|
For use with removing sensitive values pre-jsonification."""
|
|
365
|
-
if isinstance(obj, (
|
|
355
|
+
if isinstance(obj, (str, bytes)):
|
|
366
356
|
if obj:
|
|
367
357
|
yield to_native(obj, errors='surrogate_or_strict')
|
|
368
358
|
return
|
|
@@ -375,7 +365,7 @@ def _return_datastructure_name(obj):
|
|
|
375
365
|
elif obj is None or isinstance(obj, bool):
|
|
376
366
|
# This must come before int because bools are also ints
|
|
377
367
|
return
|
|
378
|
-
elif isinstance(obj,
|
|
368
|
+
elif isinstance(obj, (int, float)):
|
|
379
369
|
yield to_native(obj, nonstring='simplerepr')
|
|
380
370
|
else:
|
|
381
371
|
raise TypeError('Unknown parameter type: %s' % (type(obj)))
|
|
@@ -413,26 +403,23 @@ def _remove_values_conditions(value, no_log_strings, deferred_removals):
|
|
|
413
403
|
"""
|
|
414
404
|
original_value = value
|
|
415
405
|
|
|
416
|
-
if isinstance(value, (
|
|
406
|
+
if isinstance(value, (str, bytes)):
|
|
417
407
|
# Need native str type
|
|
418
408
|
native_str_value = value
|
|
419
|
-
if isinstance(value,
|
|
409
|
+
if isinstance(value, str):
|
|
420
410
|
value_is_text = True
|
|
421
|
-
|
|
422
|
-
native_str_value = to_bytes(value, errors='surrogate_or_strict')
|
|
423
|
-
elif isinstance(value, binary_type):
|
|
411
|
+
elif isinstance(value, bytes):
|
|
424
412
|
value_is_text = False
|
|
425
|
-
|
|
426
|
-
native_str_value = to_text(value, errors='surrogate_or_strict')
|
|
413
|
+
native_str_value = to_text(value, errors='surrogate_or_strict')
|
|
427
414
|
|
|
428
415
|
if native_str_value in no_log_strings:
|
|
429
416
|
return 'VALUE_SPECIFIED_IN_NO_LOG_PARAMETER'
|
|
430
417
|
for omit_me in no_log_strings:
|
|
431
418
|
native_str_value = native_str_value.replace(omit_me, '*' * 8)
|
|
432
419
|
|
|
433
|
-
if value_is_text and isinstance(native_str_value,
|
|
420
|
+
if value_is_text and isinstance(native_str_value, bytes):
|
|
434
421
|
value = to_text(native_str_value, encoding='utf-8', errors='surrogate_then_replace')
|
|
435
|
-
elif not value_is_text and isinstance(native_str_value,
|
|
422
|
+
elif not value_is_text and isinstance(native_str_value, str):
|
|
436
423
|
value = to_bytes(native_str_value, encoding='utf-8', errors='surrogate_then_replace')
|
|
437
424
|
else:
|
|
438
425
|
value = native_str_value
|
|
@@ -514,7 +501,7 @@ def _set_defaults(argument_spec, parameters, set_default=True):
|
|
|
514
501
|
|
|
515
502
|
def _sanitize_keys_conditions(value, no_log_strings, ignore_keys, deferred_removals):
|
|
516
503
|
""" Helper method to :func:`sanitize_keys` to build ``deferred_removals`` and avoid deep recursion. """
|
|
517
|
-
if isinstance(value, (
|
|
504
|
+
if isinstance(value, (str, bytes)):
|
|
518
505
|
return value
|
|
519
506
|
|
|
520
507
|
if isinstance(value, Sequence):
|
|
@@ -541,7 +528,7 @@ def _sanitize_keys_conditions(value, no_log_strings, ignore_keys, deferred_remov
|
|
|
541
528
|
deferred_removals.append((value, new_value))
|
|
542
529
|
return new_value
|
|
543
530
|
|
|
544
|
-
if isinstance(value,
|
|
531
|
+
if isinstance(value, (int, float, bool, NoneType)):
|
|
545
532
|
return value
|
|
546
533
|
|
|
547
534
|
if isinstance(value, (datetime.datetime, datetime.date, datetime.time)):
|
|
@@ -560,8 +547,8 @@ def _validate_elements(wanted_type, parameter, values, options_context=None, err
|
|
|
560
547
|
# Get param name for strings so we can later display this value in a useful error message if needed
|
|
561
548
|
# Only pass 'kwargs' to our checkers and ignore custom callable checkers
|
|
562
549
|
kwargs = {}
|
|
563
|
-
if wanted_element_type == 'str' and isinstance(wanted_type,
|
|
564
|
-
if isinstance(parameter,
|
|
550
|
+
if wanted_element_type == 'str' and isinstance(wanted_type, str):
|
|
551
|
+
if isinstance(parameter, str):
|
|
565
552
|
kwargs['param'] = parameter
|
|
566
553
|
elif isinstance(parameter, dict):
|
|
567
554
|
kwargs['param'] = list(parameter.keys())[0]
|
|
@@ -620,7 +607,7 @@ def _validate_argument_types(argument_spec, parameters, prefix='', options_conte
|
|
|
620
607
|
# Get param name for strings so we can later display this value in a useful error message if needed
|
|
621
608
|
# Only pass 'kwargs' to our checkers and ignore custom callable checkers
|
|
622
609
|
kwargs = {}
|
|
623
|
-
if wanted_name == 'str' and isinstance(wanted_type,
|
|
610
|
+
if wanted_name == 'str' and isinstance(wanted_type, str):
|
|
624
611
|
kwargs['param'] = list(parameters.keys())[0]
|
|
625
612
|
|
|
626
613
|
# Get the name of the parent key if this is a nested option
|
|
@@ -659,7 +646,7 @@ def _validate_argument_values(argument_spec, parameters, options_context=None, e
|
|
|
659
646
|
if choices is None:
|
|
660
647
|
continue
|
|
661
648
|
|
|
662
|
-
if isinstance(choices, (frozenset, KeysView, Sequence)) and not isinstance(choices, (
|
|
649
|
+
if isinstance(choices, (frozenset, KeysView, Sequence)) and not isinstance(choices, (bytes, str)):
|
|
663
650
|
if param in parameters:
|
|
664
651
|
# Allow one or more when type='list' param with choices
|
|
665
652
|
if isinstance(parameters[param], list):
|
|
@@ -745,7 +732,7 @@ def _validate_sub_spec(
|
|
|
745
732
|
options_context.append(param)
|
|
746
733
|
|
|
747
734
|
# Make sure we can iterate over the elements
|
|
748
|
-
if not isinstance(parameters[param], Sequence) or isinstance(parameters[param],
|
|
735
|
+
if not isinstance(parameters[param], Sequence) or isinstance(parameters[param], str):
|
|
749
736
|
elements = [parameters[param]]
|
|
750
737
|
else:
|
|
751
738
|
elements = parameters[param]
|
|
@@ -940,3 +927,7 @@ def remove_values(value, no_log_strings):
|
|
|
940
927
|
raise TypeError('Unknown container type encountered when removing private values from output')
|
|
941
928
|
|
|
942
929
|
return new_value
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
def __getattr__(importable_name):
|
|
933
|
+
return _no_six.deprecate(importable_name, __name__, "binary_type", "text_type", "integer_types", "string_types", "PY2", "PY3")
|
|
@@ -8,11 +8,8 @@ from __future__ import annotations
|
|
|
8
8
|
import codecs
|
|
9
9
|
import json
|
|
10
10
|
|
|
11
|
-
from ansible.module_utils.
|
|
12
|
-
|
|
13
|
-
iteritems,
|
|
14
|
-
text_type,
|
|
15
|
-
)
|
|
11
|
+
from ansible.module_utils.compat import typing as _t
|
|
12
|
+
from ansible.module_utils._internal import _no_six
|
|
16
13
|
|
|
17
14
|
try:
|
|
18
15
|
codecs.lookup_error('surrogateescape')
|
|
@@ -25,8 +22,54 @@ _COMPOSED_ERROR_HANDLERS = frozenset((None, 'surrogate_or_replace',
|
|
|
25
22
|
'surrogate_or_strict',
|
|
26
23
|
'surrogate_then_replace'))
|
|
27
24
|
|
|
25
|
+
_T = _t.TypeVar('_T')
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
_NonStringPassthru: _t.TypeAlias = _t.Literal['passthru']
|
|
28
|
+
_NonStringOther: _t.TypeAlias = _t.Literal['simplerepr', 'empty', 'strict']
|
|
29
|
+
_NonStringAll: _t.TypeAlias = _t.Union[_NonStringPassthru, _NonStringOther]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@_t.overload
|
|
33
|
+
def to_bytes(
|
|
34
|
+
obj: object,
|
|
35
|
+
encoding: str = 'utf-8',
|
|
36
|
+
errors: str | None = None,
|
|
37
|
+
) -> bytes: ...
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@_t.overload
|
|
41
|
+
def to_bytes(
|
|
42
|
+
obj: bytes | str,
|
|
43
|
+
encoding: str = 'utf-8',
|
|
44
|
+
errors: str | None = None,
|
|
45
|
+
nonstring: _NonStringPassthru = 'passthru',
|
|
46
|
+
) -> bytes: ...
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@_t.overload
|
|
50
|
+
def to_bytes(
|
|
51
|
+
obj: _T,
|
|
52
|
+
encoding: str = 'utf-8',
|
|
53
|
+
errors: str | None = None,
|
|
54
|
+
nonstring: _NonStringPassthru = 'passthru',
|
|
55
|
+
) -> _T: ...
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@_t.overload
|
|
59
|
+
def to_bytes(
|
|
60
|
+
obj: object,
|
|
61
|
+
encoding: str = 'utf-8',
|
|
62
|
+
errors: str | None = None,
|
|
63
|
+
nonstring: _NonStringOther = 'simplerepr',
|
|
64
|
+
) -> bytes: ...
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def to_bytes(
|
|
68
|
+
obj: _T,
|
|
69
|
+
encoding: str = 'utf-8',
|
|
70
|
+
errors: str | None = None,
|
|
71
|
+
nonstring: _NonStringAll = 'simplerepr'
|
|
72
|
+
) -> _T | bytes:
|
|
30
73
|
"""Make sure that a string is a byte string
|
|
31
74
|
|
|
32
75
|
:arg obj: An object to make sure is a byte string. In most cases this
|
|
@@ -84,13 +127,13 @@ def to_bytes(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
|
|
|
84
127
|
string is valid in the specified encoding. If it's important that the
|
|
85
128
|
byte string is in the specified encoding do::
|
|
86
129
|
|
|
87
|
-
encoded_string = to_bytes(to_text(input_string, 'latin-1'), 'utf-8')
|
|
130
|
+
encoded_string = to_bytes(to_text(input_string, encoding='latin-1'), encoding='utf-8')
|
|
88
131
|
|
|
89
132
|
.. version_changed:: 2.3
|
|
90
133
|
|
|
91
134
|
Added the ``surrogate_then_replace`` error handler and made it the default error handler.
|
|
92
135
|
"""
|
|
93
|
-
if isinstance(obj,
|
|
136
|
+
if isinstance(obj, bytes):
|
|
94
137
|
return obj
|
|
95
138
|
|
|
96
139
|
# We're given a text string
|
|
@@ -104,7 +147,7 @@ def to_bytes(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
|
|
|
104
147
|
else:
|
|
105
148
|
errors = 'replace'
|
|
106
149
|
|
|
107
|
-
if isinstance(obj,
|
|
150
|
+
if isinstance(obj, str):
|
|
108
151
|
try:
|
|
109
152
|
# Try this first as it's the fastest
|
|
110
153
|
return obj.encode(encoding, errors)
|
|
@@ -129,21 +172,60 @@ def to_bytes(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
|
|
|
129
172
|
value = repr(obj)
|
|
130
173
|
except UnicodeError:
|
|
131
174
|
# Giving up
|
|
132
|
-
return
|
|
175
|
+
return b''
|
|
133
176
|
elif nonstring == 'passthru':
|
|
134
177
|
return obj
|
|
135
178
|
elif nonstring == 'empty':
|
|
136
|
-
|
|
137
|
-
return to_bytes('')
|
|
179
|
+
return b''
|
|
138
180
|
elif nonstring == 'strict':
|
|
139
181
|
raise TypeError('obj must be a string type')
|
|
140
182
|
else:
|
|
141
183
|
raise TypeError('Invalid value %s for to_bytes\' nonstring parameter' % nonstring)
|
|
142
184
|
|
|
143
|
-
return to_bytes(value, encoding, errors)
|
|
185
|
+
return to_bytes(value, encoding=encoding, errors=errors)
|
|
144
186
|
|
|
145
187
|
|
|
146
|
-
|
|
188
|
+
@_t.overload
|
|
189
|
+
def to_text(
|
|
190
|
+
obj: object,
|
|
191
|
+
encoding: str = 'utf-8',
|
|
192
|
+
errors: str | None = None,
|
|
193
|
+
) -> str: ...
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
@_t.overload
|
|
197
|
+
def to_text(
|
|
198
|
+
obj: str | bytes,
|
|
199
|
+
encoding: str = 'utf-8',
|
|
200
|
+
errors: str | None = None,
|
|
201
|
+
nonstring: _NonStringPassthru = 'passthru',
|
|
202
|
+
) -> str: ...
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
@_t.overload
|
|
206
|
+
def to_text(
|
|
207
|
+
obj: _T,
|
|
208
|
+
encoding: str = 'utf-8',
|
|
209
|
+
errors: str | None = None,
|
|
210
|
+
nonstring: _NonStringPassthru = 'passthru',
|
|
211
|
+
) -> _T: ...
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
@_t.overload
|
|
215
|
+
def to_text(
|
|
216
|
+
obj: object,
|
|
217
|
+
encoding: str = 'utf-8',
|
|
218
|
+
errors: str | None = None,
|
|
219
|
+
nonstring: _NonStringOther = 'simplerepr',
|
|
220
|
+
) -> str: ...
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def to_text(
|
|
224
|
+
obj: _T,
|
|
225
|
+
encoding: str = 'utf-8',
|
|
226
|
+
errors: str | None = None,
|
|
227
|
+
nonstring: _NonStringAll = 'simplerepr'
|
|
228
|
+
) -> _T | str:
|
|
147
229
|
"""Make sure that a string is a text string
|
|
148
230
|
|
|
149
231
|
:arg obj: An object to make sure is a text string. In most cases this
|
|
@@ -194,7 +276,7 @@ def to_text(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
|
|
|
194
276
|
|
|
195
277
|
Added the surrogate_then_replace error handler and made it the default error handler.
|
|
196
278
|
"""
|
|
197
|
-
if isinstance(obj,
|
|
279
|
+
if isinstance(obj, str):
|
|
198
280
|
return obj
|
|
199
281
|
|
|
200
282
|
if errors in _COMPOSED_ERROR_HANDLERS:
|
|
@@ -205,7 +287,7 @@ def to_text(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
|
|
|
205
287
|
else:
|
|
206
288
|
errors = 'replace'
|
|
207
289
|
|
|
208
|
-
if isinstance(obj,
|
|
290
|
+
if isinstance(obj, bytes):
|
|
209
291
|
# Note: We don't need special handling for surrogate_then_replace
|
|
210
292
|
# because all bytes will either be made into surrogates or are valid
|
|
211
293
|
# to decode.
|
|
@@ -221,17 +303,17 @@ def to_text(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
|
|
|
221
303
|
value = repr(obj)
|
|
222
304
|
except UnicodeError:
|
|
223
305
|
# Giving up
|
|
224
|
-
return
|
|
306
|
+
return ''
|
|
225
307
|
elif nonstring == 'passthru':
|
|
226
308
|
return obj
|
|
227
309
|
elif nonstring == 'empty':
|
|
228
|
-
return
|
|
310
|
+
return ''
|
|
229
311
|
elif nonstring == 'strict':
|
|
230
312
|
raise TypeError('obj must be a string type')
|
|
231
313
|
else:
|
|
232
314
|
raise TypeError('Invalid value %s for to_text\'s nonstring parameter' % nonstring)
|
|
233
315
|
|
|
234
|
-
return to_text(value, encoding, errors)
|
|
316
|
+
return to_text(value, encoding=encoding, errors=errors)
|
|
235
317
|
|
|
236
318
|
|
|
237
319
|
to_native = to_text
|
|
@@ -259,10 +341,10 @@ def container_to_bytes(d, encoding='utf-8', errors='surrogate_or_strict'):
|
|
|
259
341
|
"""
|
|
260
342
|
# DTFIX-FUTURE: deprecate
|
|
261
343
|
|
|
262
|
-
if isinstance(d,
|
|
344
|
+
if isinstance(d, str):
|
|
263
345
|
return to_bytes(d, encoding=encoding, errors=errors)
|
|
264
346
|
elif isinstance(d, dict):
|
|
265
|
-
return dict(container_to_bytes(o, encoding, errors) for o in
|
|
347
|
+
return dict(container_to_bytes(o, encoding, errors) for o in d.items())
|
|
266
348
|
elif isinstance(d, list):
|
|
267
349
|
return [container_to_bytes(o, encoding, errors) for o in d]
|
|
268
350
|
elif isinstance(d, tuple):
|
|
@@ -279,14 +361,18 @@ def container_to_text(d, encoding='utf-8', errors='surrogate_or_strict'):
|
|
|
279
361
|
"""
|
|
280
362
|
# DTFIX-FUTURE: deprecate
|
|
281
363
|
|
|
282
|
-
if isinstance(d,
|
|
364
|
+
if isinstance(d, bytes):
|
|
283
365
|
# Warning, can traceback
|
|
284
366
|
return to_text(d, encoding=encoding, errors=errors)
|
|
285
367
|
elif isinstance(d, dict):
|
|
286
|
-
return dict(container_to_text(o, encoding, errors) for o in
|
|
368
|
+
return dict(container_to_text(o, encoding, errors) for o in d.items())
|
|
287
369
|
elif isinstance(d, list):
|
|
288
370
|
return [container_to_text(o, encoding, errors) for o in d]
|
|
289
371
|
elif isinstance(d, tuple):
|
|
290
372
|
return tuple(container_to_text(o, encoding, errors) for o in d)
|
|
291
373
|
else:
|
|
292
374
|
return d
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
def __getattr__(importable_name):
|
|
378
|
+
return _no_six.deprecate(importable_name, __name__, "binary_type", "text_type", "iteritems")
|
|
@@ -6,7 +6,7 @@ from __future__ import annotations
|
|
|
6
6
|
|
|
7
7
|
import re
|
|
8
8
|
|
|
9
|
-
from ansible.module_utils.
|
|
9
|
+
from ansible.module_utils._internal import _no_six
|
|
10
10
|
|
|
11
11
|
SIZE_RANGES = {
|
|
12
12
|
'Y': 1 << 80,
|
|
@@ -117,7 +117,7 @@ def bytes_to_human(size, isbits=False, unit=None):
|
|
|
117
117
|
base = 'bits'
|
|
118
118
|
suffix = ''
|
|
119
119
|
|
|
120
|
-
for suffix, limit in sorted(
|
|
120
|
+
for suffix, limit in sorted(SIZE_RANGES.items(), key=lambda item: -item[1]):
|
|
121
121
|
if (unit is None and size >= limit) or unit is not None and unit.upper() == suffix[0]:
|
|
122
122
|
break
|
|
123
123
|
|
|
@@ -127,3 +127,7 @@ def bytes_to_human(size, isbits=False, unit=None):
|
|
|
127
127
|
suffix = base
|
|
128
128
|
|
|
129
129
|
return '%.2f %s' % (size / limit, suffix)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def __getattr__(importable_name):
|
|
133
|
+
return _no_six.deprecate(importable_name, __name__, "iteritems")
|
|
@@ -10,15 +10,13 @@ import os
|
|
|
10
10
|
import re
|
|
11
11
|
|
|
12
12
|
from ast import literal_eval
|
|
13
|
+
from ansible.module_utils._internal import _no_six
|
|
13
14
|
from ansible.module_utils.common import json as _common_json
|
|
14
15
|
from ansible.module_utils.common.text.converters import to_native
|
|
15
16
|
from ansible.module_utils.common.collections import is_iterable
|
|
16
17
|
from ansible.module_utils.common.text.formatters import human_to_bytes
|
|
17
18
|
from ansible.module_utils.common.warnings import deprecate
|
|
18
19
|
from ansible.module_utils.parsing.convert_bool import boolean
|
|
19
|
-
from ansible.module_utils.six import (
|
|
20
|
-
string_types,
|
|
21
|
-
)
|
|
22
20
|
|
|
23
21
|
|
|
24
22
|
def count_terms(terms, parameters):
|
|
@@ -43,7 +41,7 @@ def safe_eval(value, locals=None, include_exceptions=False):
|
|
|
43
41
|
version="2.21",
|
|
44
42
|
)
|
|
45
43
|
# do not allow method calls to modules
|
|
46
|
-
if not isinstance(value,
|
|
44
|
+
if not isinstance(value, str):
|
|
47
45
|
# already templated to a datavaluestructure, perhaps?
|
|
48
46
|
if include_exceptions:
|
|
49
47
|
return (value, None)
|
|
@@ -194,7 +192,7 @@ def check_required_by(requirements, parameters, options_context=None):
|
|
|
194
192
|
if key not in parameters or parameters[key] is None:
|
|
195
193
|
continue
|
|
196
194
|
# Support strings (single-item lists)
|
|
197
|
-
if isinstance(value,
|
|
195
|
+
if isinstance(value, str):
|
|
198
196
|
value = [value]
|
|
199
197
|
|
|
200
198
|
if missing := [required for required in value if required not in parameters or parameters[required] is None]:
|
|
@@ -373,7 +371,7 @@ def check_type_str(value, allow_conversion=True, param=None, prefix=''):
|
|
|
373
371
|
:returns: Original value if it is a string, the value converted to a string
|
|
374
372
|
if allow_conversion=True, or raises a TypeError if allow_conversion=False.
|
|
375
373
|
"""
|
|
376
|
-
if isinstance(value,
|
|
374
|
+
if isinstance(value, str):
|
|
377
375
|
return value
|
|
378
376
|
|
|
379
377
|
if value is None:
|
|
@@ -406,7 +404,7 @@ def check_type_list(value):
|
|
|
406
404
|
return value
|
|
407
405
|
|
|
408
406
|
# DTFIX-FUTURE: deprecate legacy comma split functionality, eventually replace with `_check_type_list_strict`
|
|
409
|
-
if isinstance(value,
|
|
407
|
+
if isinstance(value, str):
|
|
410
408
|
return value.split(",")
|
|
411
409
|
elif isinstance(value, int) or isinstance(value, float):
|
|
412
410
|
return [str(value)]
|
|
@@ -434,7 +432,7 @@ def check_type_dict(value):
|
|
|
434
432
|
if isinstance(value, dict):
|
|
435
433
|
return value
|
|
436
434
|
|
|
437
|
-
if isinstance(value,
|
|
435
|
+
if isinstance(value, str):
|
|
438
436
|
if value.startswith("{"):
|
|
439
437
|
try:
|
|
440
438
|
return json.loads(value)
|
|
@@ -497,7 +495,7 @@ def check_type_bool(value):
|
|
|
497
495
|
if isinstance(value, bool):
|
|
498
496
|
return value
|
|
499
497
|
|
|
500
|
-
if isinstance(value,
|
|
498
|
+
if isinstance(value, str) or isinstance(value, (int, float)):
|
|
501
499
|
return boolean(value)
|
|
502
500
|
|
|
503
501
|
raise TypeError('%s cannot be converted to a bool' % type(value))
|
|
@@ -597,3 +595,7 @@ def check_type_jsonarg(value):
|
|
|
597
595
|
return json.dumps(value, cls=_common_json._get_legacy_encoder(), _decode_bytes=True)
|
|
598
596
|
|
|
599
597
|
raise TypeError('%s cannot be converted to a json string' % type(value))
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
def __getattr__(importable_name):
|
|
601
|
+
return _no_six.deprecate(importable_name, __name__, "string_types")
|
|
@@ -36,9 +36,10 @@ import struct
|
|
|
36
36
|
import uuid
|
|
37
37
|
|
|
38
38
|
from functools import partial
|
|
39
|
+
|
|
40
|
+
from ansible.module_utils._internal import _no_six
|
|
39
41
|
from ansible.module_utils.common.text.converters import to_bytes, to_text
|
|
40
42
|
from ansible.module_utils.common.json import _get_legacy_encoder
|
|
41
|
-
from ansible.module_utils.six import iteritems
|
|
42
43
|
|
|
43
44
|
|
|
44
45
|
def write_to_stream(stream, obj):
|
|
@@ -95,7 +96,7 @@ class ConnectionError(Exception):
|
|
|
95
96
|
|
|
96
97
|
def __init__(self, message, *args, **kwargs):
|
|
97
98
|
super(ConnectionError, self).__init__(message)
|
|
98
|
-
for k, v in
|
|
99
|
+
for k, v in kwargs.items():
|
|
99
100
|
setattr(self, k, v)
|
|
100
101
|
|
|
101
102
|
|
|
@@ -149,7 +150,7 @@ class Connection(object):
|
|
|
149
150
|
raise ConnectionError(
|
|
150
151
|
"Unable to decode JSON from response to {0}. Received '{1}'.".format(name, out)
|
|
151
152
|
)
|
|
152
|
-
params = [repr(arg) for arg in args] + ['{0}={1!r}'.format(k, v) for k, v in
|
|
153
|
+
params = [repr(arg) for arg in args] + ['{0}={1!r}'.format(k, v) for k, v in kwargs.items()]
|
|
153
154
|
params = ', '.join(params)
|
|
154
155
|
raise ConnectionError(
|
|
155
156
|
"Unable to decode JSON from response to {0}({1}). Received '{2}'.".format(name, params, out)
|
|
@@ -200,3 +201,7 @@ class Connection(object):
|
|
|
200
201
|
sf.close()
|
|
201
202
|
|
|
202
203
|
return to_text(response, errors='surrogate_or_strict')
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def __getattr__(importable_name):
|
|
207
|
+
return _no_six.deprecate(importable_name, __name__, "iteritems")
|