mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 10:51:24 -07:00
Move collections abc shim to _collections_compat
This commit is contained in:
parent
912bd25a4e
commit
eb209e92c9
2 changed files with 40 additions and 10 deletions
|
@ -81,8 +81,6 @@ import pwd
|
|||
import platform
|
||||
import errno
|
||||
import datetime
|
||||
from collections import deque
|
||||
from collections import Mapping, MutableMapping, Sequence, MutableSequence, Set, MutableSet
|
||||
from itertools import chain, repeat
|
||||
|
||||
try:
|
||||
|
@ -107,14 +105,6 @@ except ImportError:
|
|||
# Python2 & 3 way to get NoneType
|
||||
NoneType = type(None)
|
||||
|
||||
# Note: When getting Sequence from collections, it matches with strings. If
|
||||
# this matters, make sure to check for strings before checking for sequencetype
|
||||
try:
|
||||
from collections.abc import KeysView
|
||||
SEQUENCETYPE = (Sequence, frozenset, KeysView)
|
||||
except ImportError:
|
||||
SEQUENCETYPE = (Sequence, frozenset)
|
||||
|
||||
try:
|
||||
import json
|
||||
# Detect the python-json library which is incompatible
|
||||
|
@ -162,6 +152,13 @@ except ImportError:
|
|||
except ImportError:
|
||||
pass
|
||||
|
||||
from ansible.module_utils.common._collections_compat import (
|
||||
deque,
|
||||
KeysView,
|
||||
Mapping, MutableMapping,
|
||||
Sequence, MutableSequence,
|
||||
Set, MutableSet,
|
||||
)
|
||||
from ansible.module_utils.pycompat24 import get_exception, literal_eval
|
||||
from ansible.module_utils.six import (
|
||||
PY2,
|
||||
|
@ -178,6 +175,10 @@ from ansible.module_utils._text import to_native, to_bytes, to_text
|
|||
from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE, BOOLEANS_TRUE, boolean
|
||||
|
||||
|
||||
# Note: When getting Sequence from collections, it matches with strings. If
|
||||
# this matters, make sure to check for strings before checking for sequencetype
|
||||
SEQUENCETYPE = frozenset, KeysView, Sequence
|
||||
|
||||
PASSWORD_MATCH = re.compile(r'^(?:.+[-_\s])?pass(?:[-_\s]?(?:word|phrase|wrd|wd)?)(?:[-_\s].+)?$', re.I)
|
||||
|
||||
_NUMBERTYPES = tuple(list(integer_types) + [float])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue