Completed
Pull Request — develop (#5)
by Kale
56s
created

auxlib.NonStringIterable   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 13
Duplicated Lines 0 %
Metric Value
dl 0
loc 13
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __iter__() 0 4 2
A __subclasshook__() 0 6 4
1
# -*- coding: utf-8 -*-
2
from __future__ import print_function, division, absolute_import
3
from abc import ABCMeta, abstractmethod
4
from logging import getLogger
5
from textwrap import dedent
6
7
from auxlib._vendor.five import with_metaclass
8
9
log = getLogger(__name__)
10
11
12
def dals(string):
13
    """dedent and left-strip"""
14
    return dedent(string).lstrip()
15
16
17
@with_metaclass(ABCMeta)
18
class NonStringIterable(object):
19
    @abstractmethod
20
    def __iter__(self):
21
        while False:
22
            yield None
23
24
    @classmethod
25
    def __subclasshook__(cls, C):
26
        if cls is NonStringIterable:
27
            if any("__iter__" in B.__dict__ for B in C.__mro__):
28
                return True
29
        return NotImplemented
30