Exemplo n.º 1
0
 def retrieve(self,index):
     if index in self.indextable:
         return self.indextable[index]
     else:
         msg = ('Unable to retrieve item ' + str(index) + ' from table ' + self.name
                   + ' (size: ' + str(self.size()) + ')')
         raise IT.IndexedTableError(msg + '\n' + self.name + ', size: ' + str(self.size()))
Exemplo n.º 2
0
 def add(self,s):
     if s is None:
         raise  IT.IndexedTableError(self.name + ': Attempt to index None')
     if s in self.stringtable:
         return self.stringtable[s]
     else:
         index = self.next
         self.stringtable[s] = index
         self.indextable[index] = s
         self.next += 1
         return index
Exemplo n.º 3
0
 def read_xml(self,node):
     if node is None:
         print('Xml node not present in string table')
         raise IT.IndexedTableError('Xml node not present in string table')
     for snode in node.findall('n'):
         index = int(snode.get('ix'))
         ishex = snode.get('hex','no') == 'yes'
         s = decode(ishex,snode.get('v'))
         self.stringtable[s] = index
         self.indextable[index] = s
         if index >= self.next:
             self.next = index + 1
Exemplo n.º 4
0
 def read_xml(self, node: Optional[ET.Element]) -> None:
     if node is None:
         print('Xml node not present in string table')
         raise IT.IndexedTableError('Xml node not present in string table')
     for snode in node.findall('n'):
         ix = snode.get("ix")
         if ix is None:
             raise UF.CHBError("StringIndexTable: index is missing")
         index = int(ix)
         ishex = snode.get('hex', 'no') == 'y'
         v = snode.get("v")
         if v is None:
             raise UF.CHBError(
                 "StringIndexTable: value is missing for index " +
                 str(index))
         s = decode(ishex, v)
         self.stringtable[s] = index
         self.indextable[index] = s
         if index >= self.next:
             self.next = index + 1