1from more_itertools import always_iterable 2 3 4class Union: 5 _union_type = "" 6 7 def __init__(self, name, sub_types): 8 self.name = name 9 self.sub_types = list(always_iterable(sub_types)) 10 11 def __iter__(self): 12 yield from self.sub_types 13 14 def __repr__(self): 15 return "{} Union: '{}' composed of: {}".format( 16 self._union_type.capitalize(), self.name, self.sub_types 17 ) 18 19 20class MeshUnion(Union): 21 _union_type = "mesh" 22 23 def __init__(self, name, sub_types): 24 super().__init__(name, sub_types) 25