def __read_vocabulary(self, vocabularyRoot): # Create a CtrlVocab instance if 'id' in vocabularyRoot.attrib: idvocab = vocabularyRoot.attrib['id'] else: # XRA < 1.2 idvocab = vocabularyRoot.attrib['ID'] ctrlvocab = CtrlVocab(idvocab) # Description if "description" in vocabularyRoot.attrib: ctrlvocab.desc = vocabularyRoot.attrib['description'] # Add the list of entries for entryNode in vocabularyRoot.findall('Entry'): entrytext = entryNode.text entrydesc = "" if "description" in entryNode.attrib: entrydesc = entryNode.attrib['description'] ctrlvocab.Append( entrytext,entrydesc ) # link to tiers for tierNode in vocabularyRoot.findall('Tier'): if 'id' in tierNode.attrib: idtier = tierNode.attrib['id'] else: # XRA < 1.2 idtier = tierNode.attrib['ID'] tier = self.__id_tier_map[idtier] tier.SetCtrlVocab( ctrlvocab )
def __read_ctrl_vocab(self, vocabularyRoot, root): # Create a CtrlVocab instance idvocab = vocabularyRoot.attrib['CV_ID'] ctrlvocab = CtrlVocab(idvocab) # Description if "DESCRIPTION" in vocabularyRoot.attrib: ctrlvocab.desc = vocabularyRoot.attrib['DESCRIPTION'] # Add the list of entries for entryNode in vocabularyRoot.findall('CV_ENTRY'): entrytext = entryNode.text entrydesc = "" if "DESCRIPTION" in entryNode.attrib: entrydesc = entryNode.attrib['DESCRIPTION'] ctrlvocab.Append( entrytext,entrydesc ) # if Elan eaf format = 2.8 for entryNode in vocabularyRoot.findall('CV_ENTRY_ML'): entryValueNode = entryNode.find('CVE_VALUE') entrytext = entryValueNode.text entrydesc = "" if "DESCRIPTION" in entryValueNode.attrib: entrydesc = entryValueNode.attrib['DESCRIPTION'] ctrlvocab.Append( entrytext,entrydesc ) self.AddCtrlVocab( ctrlvocab )