def __delitem__(self, key): key = str(key) old_value = accessors.getitem(objects.itemsof(self), key, None) if old_value is not None: old_value.data_changed.unsubscribe(_notify) accessors.delitem(objects.itemsof(self), key)
def __setitem__(self, key, value): def _notify(obj, key_, value_): self.data_changed(self, (key,) + key_, value_) old_value, new_value = accessors.getitem(objects.itemsof(self), key, None), value if old_value is not None: old_value.data_changed.unsubscribe(_notify) accessors.setitem(objects.itemsof(self), key, value) if new_value is not None: new_value.data_changed.subscribe(_notify)
def iter_paths_where(obj, predicate, path=None): path = [] if path is None else path for key, value in objects.itemsof(obj).items(): sub_path = path + [key] if predicate(value): yield sub_path yield from iter_paths_where(value, predicate, sub_path)
def __getitem__(self, key): return accessors.getitem(objects.itemsof(self), key)
def increment_angular(self): items = objects.itemsof(self) angular_count = sum(item.angular for item in items.values()) angular_count = (angular_count + 1) % len(items) for i, item in enumerate(items.values()): item.angular = i < angular_count