Beispiel #1
0
 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)
Beispiel #2
0
 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)
Beispiel #3
0
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)
Beispiel #4
0
 def __getitem__(self, key):
     return accessors.getitem(objects.itemsof(self), key)
Beispiel #5
0
 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