Completed
Push — develop ( e01780...be665b )
by Kale
01:10
created

isiterable()   A

Complexity

Conditions 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
from __future__ import absolute_import, division, print_function
3
from itertools import chain
4
import collections
5
6
try:
7
    from collections import OrderedDict as odict  # NOQA
8
except ImportError:
9
    from ordereddict import OrderedDict as odict  # NOQA
10
11
from ._vendor.five import with_metaclass, WhateverIO as StringIO  # NOQA
12
from ._vendor.six import (string_types, text_type, integer_types, iteritems, itervalues,  # NOQA
13
                          iterkeys, wraps, PY2, PY3)  # NOQA
14
15
NoneType = type(None)
16
primitive_types = tuple(chain(string_types, integer_types, (float, complex, bool, NoneType)))
17
18
19
def isiterable(obj):
20
    # and not a string
21
    if PY2:
22
        return hasattr(obj, '__iter__') and not isinstance(obj, string_types)
23
    else:
24
        return not isinstance(obj, string_types) and isinstance(obj, collections.Iterable)
25