Ensure the labels in all selectors are same label. Note this method assumes that the selector is valid.
(context_type, selector)
| 793 | |
| 794 | |
| 795 | def _ensure_consistent_label(context_type, selector): |
| 796 | """Ensure the labels in all selectors are same label. |
| 797 | Note this method assumes that the selector is valid. |
| 798 | """ |
| 799 | if context_type in ("vertex_data", "vertex_property"): |
| 800 | return True |
| 801 | if context_type in ("labeled_vertex_data", "labeled_vertex_property"): |
| 802 | label_set = set() |
| 803 | for _, value in selector.items(): |
| 804 | # The format is x:y or x:y.z |
| 805 | label = value.split(":")[1].split(".")[0] |
| 806 | if label_set and label not in label_set: |
| 807 | raise SyntaxError( |
| 808 | f"Found different labels: {label_set.pop()} and {label}." |
| 809 | ) |
| 810 | else: |
| 811 | label_set.add(label) |
| 812 | return True |
no test coverage detected