Passed
Push — master ( 7d6f78...eb825e )
by Konstantin
11:20
created

get_AllIndexed   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 10
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A get_AllIndexed() 0 16 5
1
# pylint: disable=invalid-name,missing-module-docstring,line-too-long
2
def get_AllIndexed(self, classes=None, index_sort=True):
3
    """
4
    Get all indexed children sorted by their ``@index``.
5
6
    Arguments:
7
        classes (list): Type of children to return. Default: ['RegionRef', 'OrderedGroup', 'UnorderedGroup']
8
        index_sort (boolean): Whether to sort by ``@index``
9
    """
10
    if not classes:
11
        classes = ['RegionRef', 'OrderedGroup', 'UnorderedGroup']
12
    ret = []
13
    for class_ in classes:
14
        ret += getattr(self, 'get_{}Indexed'.format(class_))()
15
    if index_sort:
16
        return sorted(ret, key=lambda x: x.index)
17
    return ret
18