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

get_AllIndexed.get_AllIndexed()   A

Complexity

Conditions 5

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 16
rs 9.3333
c 0
b 0
f 0
cc 5
nop 3
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