diff --git a/nemubot/tools/xmlparser/node.py b/nemubot/tools/xmlparser/node.py index 7df255e..8523771 100644 --- a/nemubot/tools/xmlparser/node.py +++ b/nemubot/tools/xmlparser/node.py @@ -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)