1
0
Fork 0

xmlparser: Implement update method, as in dict

This commit is contained in:
nemunaire 2017-07-14 12:20:04 +02:00
parent 6b4a9a2e4a
commit 4e8504bd1d
1 changed files with 8 additions and 1 deletions

View File

@ -124,9 +124,12 @@ class ModuleState:
def setIndex(self, fieldname="name", tagname=None):
"""Defines an hash table to accelerate childs search.
You have just to define a common attribute"""
self.index = self.tmpIndex(fieldname, tagname)
self.index_fieldname = fieldname
self.index_tagname = tagname
self._updateIndex()
def _updateIndex(self):
self.index = self.tmpIndex(self.index_fieldname, self.index_tagname)
def __contains__(self, i):
"""Return true if i is found in the index"""
@ -135,6 +138,10 @@ class ModuleState:
else:
return self.hasAttribute(i)
def update(self, *args, **kwargs):
self.attributes.update(*args, **kwargs)
self._updateIndex()
def hasAttribute(self, name):
"""DOM like method"""
return (name in self.attributes)