22import define_object
33
44
5- """ Note: Comments have not yet been implemented in the template """
65class Comments (define_object .DefineObject ):
76 """ create a Define-XML v2.1 CommentDef element template """
87 def __init__ (self ):
@@ -17,13 +16,14 @@ def create_define_objects(self, template, define_objects, lang, acrf):
1716 :param define_objects: dictionary of odmlib define_objects updated by this method
1817 :param lang: xml:lang setting for TranslatedText
1918 """
20- self .logger .info ("in Comments..." )
2119 self .lang = lang
22- define_objects ["CommentDef" ] = []
2320 for comment in template :
24- com_oid = self .generate_oid (["COM" , comment .Name ])
25- comment = self ._create_commentdef_object (com_oid , comment )
26- define_objects ["CommentDef" ].append (comment )
21+ name = self .require_key (comment , "name" , "CommentDef" )
22+ com_oid = comment .get ("OID" ) or self .generate_oid (["COM" , name ])
23+ if self .find_object (define_objects ["CommentDef" ], com_oid ) is not None :
24+ continue
25+ com_def = self ._create_commentdef_object (com_oid , comment )
26+ define_objects ["CommentDef" ].append (com_def )
2727
2828 def _create_commentdef_object (self , com_oid , comment ):
2929 """
@@ -32,11 +32,12 @@ def _create_commentdef_object(self, com_oid, comment):
3232 :param comment: comment dictionary from the DDS JSON
3333 :return: a CommentDef odmlib template
3434 """
35- com = DEFINE .CommentDef (OID = com_oid , CommentType = "FreeText" )
36- tt = DEFINE .TranslatedText (_content = comment ["Description" ], lang = self .lang )
35+ com = DEFINE .CommentDef (OID = com_oid )
36+ description = self .require_key (comment , "description" , f"CommentDef { com_oid } " )
37+ tt = DEFINE .TranslatedText (_content = description , lang = self .lang )
3738 com .Description = DEFINE .Description ()
3839 com .Description .TranslatedText .append (tt )
39- if comment .get ("Document " ):
40+ if comment .get ("document " ):
4041 self ._add_document (comment , com )
4142 return com
4243
@@ -47,8 +48,8 @@ def _add_document(comment, com):
4748 :param comment: comment dictionary from the DDS JSON
4849 :param com: define comment template
4950 """
50- dr = DEFINE .DocumentRef (leafID = comment ["Document " ])
51- if comment .get ("Pages " ):
52- pdf = DEFINE .PDFPageRef (PageRefs = comment ["Pages " ], Type = "NamedDestination" )
51+ dr = DEFINE .DocumentRef (leafID = comment ["document " ])
52+ if comment .get ("pages " ):
53+ pdf = DEFINE .PDFPageRef (PageRefs = comment ["pages " ], Type = "NamedDestination" )
5354 dr .PDFPageRef .append (pdf )
5455 com .DocumentRef .append (dr )
0 commit comments