Compare variants by type first, and then by value.
(s1, s2)
| 117 | |
| 118 | |
| 119 | def vtkVariantStrictWeakOrder(s1, s2): |
| 120 | """ |
| 121 | Compare variants by type first, and then by value. |
| 122 | """ |
| 123 | s1 = vtkCommonCore.vtkVariant(s1) |
| 124 | s2 = vtkCommonCore.vtkVariant(s2) |
| 125 | |
| 126 | t1 = s1.GetType() |
| 127 | t2 = s2.GetType() |
| 128 | |
| 129 | # check based on type |
| 130 | if t1 != t2: |
| 131 | return t1 < t2 |
| 132 | |
| 133 | v1 = s1.IsValid() |
| 134 | v2 = s2.IsValid() |
| 135 | |
| 136 | # check based on validity |
| 137 | if (not v1) or (not v2): |
| 138 | return v1 < v2 |
| 139 | |
| 140 | # extract and compare the values |
| 141 | r1 = getattr(s1, _variant_method_map[t1])() |
| 142 | r2 = getattr(s2, _variant_method_map[t2])() |
| 143 | |
| 144 | # compare vtk objects by classname, then address |
| 145 | if t1 == vtkCommonCore.VTK_OBJECT: |
| 146 | c1 = r1.GetClassName() |
| 147 | c2 = r2.GetClassName() |
| 148 | if c1 != c2: |
| 149 | return c1 < c2 |
| 150 | else: |
| 151 | return r1.__this__ < r2.__this__ |
| 152 | |
| 153 | return r1 < r2 |
| 154 | |
| 155 | |
| 156 | class vtkVariantStrictWeakOrderKey: |