Beispiel #1
0
 async def get_annotation(self, context, annotation_index, create=True):
     annotation_name = self.get_annotation_name(annotation_index)
     annotations_container = IAnnotations(context)
     annotation = annotations_container.get(annotation_name, _default)
     if annotation is _default:
         annotation = await annotations_container.async_get(
             annotation_name, _default)
     if annotation is _default:
         if not create:
             return
         # create
         annotation = AnnotationData()
         annotation.update({'items': []})
         await annotations_container.async_set(annotation_name, annotation)
     if annotation_index not in self.annotations_metadata:
         self.annotations_metadata[annotation_index] = {}
     return annotation
Beispiel #2
0
 async def get_annotation(self, context, annotation_index, create=True):
     annotation_name = self.get_annotation_name(annotation_index)
     annotations_container = IAnnotations(context)
     annotation = annotations_container.get(annotation_name, _default)
     if annotation is _default:
         annotation = await annotations_container.async_get(
             annotation_name, _default)
     if annotation is _default:
         if not create:
             return
         # create
         annotation = AnnotationData()
         annotation.update({
             'items': []
         })
         await annotations_container.async_set(annotation_name, annotation)
     if annotation_index not in self.annotations_metadata:
         self.annotations_metadata[annotation_index] = {}
     return annotation
Beispiel #3
0
 async def get_annotation(self,
                          context: IBaseObject,
                          annotation_index: int,
                          create: bool = True) -> Optional[IAnnotationData]:
     annotation_name = self.get_annotation_name(annotation_index)
     annotations_container = IAnnotations(context)
     annotation = annotations_container.get(annotation_name, _default)
     if annotation is _default:
         annotation = await annotations_container.async_get(
             annotation_name, _default)
     if annotation is _default:
         if not create:
             return None
         # create
         annotation = AnnotationData()
         annotation.update({"items": []})
         await annotations_container.async_set(annotation_name, annotation)
     if annotation_index not in self.annotations_metadata:
         self.annotations_metadata[annotation_index] = {}
     return annotation