Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def contains_widget(self, widget):
for innot in self.childinnotations:
if innot.contains_widget(widget):
return True
return False
def list_innotations_tree(self):
return [self, *self.childinnotations]
def __len__(self):
if len(self.childinnotations) > 0:
return len(self.childinnotations[0])
return 0
class RepeatInnotation(Innotation, ChildrenChangeNotifierMixin):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.rows_count = 0
self.childinnotationconfigs = args
self.childinnotations = []
self.min_repeats = kwargs.get('min_repeats', 0)
self.max_repeats = kwargs.get('max_repeats', 10)
if self.max_repeats < self.min_repeats:
raise Exception("min_repeats is greater than max_repeats")
def _observe_targets(self, targets):
for dw in targets:
dw.widget_observe(self.update_data, names='value')
if isinstance(dw, ChildrenChangeNotifierMixin):
dw.on_children_changed(self.new_children_handler)
if isinstance(dw, DataChangeNotifierMixin):
dw.on_data_changed(self.updated_data_handler)