Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def post_register(self, datamanager):
if self.source is not None:
self.sourcedw = datamanager.get_data_wrapper_by_name(self.source)
if self.sourcedw is None:
raise Exception('ImageInnotation named {} not found but specified as source attribute for BoundingBoxInnotation'.format(self.source))
if not isinstance(self.sourcedw, ImageInnotation):
raise Exception('Innotation named {} is not an ImageInnotation but is specified as source attribute for BoundingBoxInnotation'.format(self.source))
else:
# Find by type
dws = datamanager.get_data_wrappers_by_type(ImageInnotation)
if len(dws) != 1:
# Raises exception if 0 or >1 of these is found
raise Exception('ImageInnotation not found uniquely')
self.sourcedw = dws[0]
super().post_register(datamanager)
def post_register(self, datamanager):
if self.source is not None:
self.sourcedw = datamanager.get_data_wrapper_by_name(self.source)
if self.sourcedw is None:
raise Exception('ImageInnotation named {} not found but specified as source attribute for BoundingBoxInnotation'.format(self.source))
if not isinstance(self.sourcedw, ImageInnotation):
raise Exception('Innotation named {} is not an ImageInnotation but is specified as source attribute for BoundingBoxInnotation'.format(self.source))
else:
# Find by type
dws = datamanager.get_data_wrappers_by_type(ImageInnotation)
if len(dws) != 1:
# Raises exception if 0 or >1 of these is found
raise Exception('ImageInnotation not found uniquely')
self.sourcedw = dws[0]
super().post_register(datamanager)