summaryrefslogtreecommitdiffstats
path: root/lib/ansible/module_utils/common/_collections_compat.py
blob: 3412408f74e5824e115babc319500bbf4e88eb3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Copyright (c), Sviatoslav Sydorenko <ssydoren@redhat.com> 2018
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
"""Collections ABC import shim.

This module is intended only for internal use.
It will go away once the bundled copy of six includes equivalent functionality.
Third parties should not use this.
"""

from __future__ import absolute_import, division, print_function
__metaclass__ = type

try:
    """Python 3.3+ branch."""
    from collections.abc import (
        MappingView,
        ItemsView,
        KeysView,
        ValuesView,
        Mapping, MutableMapping,
        Sequence, MutableSequence,
        Set, MutableSet,
        Container,
        Hashable,
        Sized,
        Callable,
        Iterable,
        Iterator,
    )
except ImportError:
    """Use old lib location under 2.6-3.2."""
    from collections import (  # type: ignore[no-redef,attr-defined]  # pylint: disable=deprecated-class
        MappingView,
        ItemsView,
        KeysView,
        ValuesView,
        Mapping, MutableMapping,
        Sequence, MutableSequence,
        Set, MutableSet,
        Container,
        Hashable,
        Sized,
        Callable,
        Iterable,
        Iterator,
    )