collections
xsdata.utils.collections
is_array(value)
Return whether the value is a list style type.
Source code in xsdata/utils/collections.py
13 14 15 16 17 18 |
|
unique_sequence(items, key=None)
Return a new unique list, preserving the original order.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
items | Iterable[T] | The iterable to filter | required |
key | Optional[str] | An optional callable to generate the unique keys | None |
Returns:
Type | Description |
---|---|
list[T] | A new unique list. |
Source code in xsdata/utils/collections.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
remove(items, predicate)
Return a new list without the items that match the predicate.
Source code in xsdata/utils/collections.py
46 47 48 |
|
group_by(items, key)
Group the items of an iterable object by the result of the callable.
Source code in xsdata/utils/collections.py
51 52 53 54 55 56 |
|
apply(items, func)
Apply the given function to each item of the iterable object.
Source code in xsdata/utils/collections.py
59 60 61 62 |
|
find(items, value)
Return the index of the value in the given sequence.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
items | Sequence | The sequence to search in | required |
value | Any | The value to search for | required |
Returns:
Type | Description |
---|---|
int | The index in the sequence or -1 if the value is not found. |
Source code in xsdata/utils/collections.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
first(items)
Return the first item of the iterator.
Source code in xsdata/utils/collections.py
81 82 83 |
|
prepend(target, *args)
Prepend items to the target list.
Source code in xsdata/utils/collections.py
86 87 88 |
|
connected_components(lists)
Merge lists of lists that share common elements.
Source code in xsdata/utils/collections.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
find_connected_component(groups, value)
Find the list index that contains the given value.
Source code in xsdata/utils/collections.py
112 113 114 115 116 117 118 |
|