Get the length of a grouping. The length equal to the number of scalar values contained in the grouping, which is equivalent to the length of the list that would result from calling flatten_grouping on the grouping value. :param grouping: The grouping value to calculate the length
(grouping)
| 61 | |
| 62 | |
| 63 | def grouping_len(grouping): |
| 64 | """ |
| 65 | Get the length of a grouping. The length equal to the number of scalar values |
| 66 | contained in the grouping, which is equivalent to the length of the list that would |
| 67 | result from calling flatten_grouping on the grouping value. |
| 68 | |
| 69 | :param grouping: The grouping value to calculate the length of |
| 70 | :return: non-negative integer |
| 71 | """ |
| 72 | if isinstance(grouping, (tuple, list)): |
| 73 | return sum([grouping_len(group_el) for group_el in grouping]) |
| 74 | |
| 75 | if isinstance(grouping, dict): |
| 76 | return sum([grouping_len(group_el) for group_el in grouping.values()]) |
| 77 | |
| 78 | return 1 |
| 79 | |
| 80 | |
| 81 | def make_grouping_by_index(schema, flat_values): |
no outgoing calls
searching dependent graphs…