Scripts: Fix gathering of xml tag content

If content was read partially the script stored only
the last read part instead of the whole content.

Change-Id: I331eacbd3a7321fabd32b8addec67ad01a722ed3
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Christian Stenger
2015-01-26 15:26:30 +01:00
parent 8e83b6cf01
commit 7193f932d1

View File

@@ -86,11 +86,11 @@ class Generator(handler.ContentHandler):
def endElement(self, name): def endElement(self, name):
if name == 'name': if name == 'name':
if self._context == '': if self._context == '':
self._context = self._chars self._context = self._chars.strip()
self._chars = '' self._chars = ''
elif name == 'source': elif name == 'source':
if self._chars: if self._chars:
self._msg = self._chars self._msg = self._chars.strip()
self._chars = '' self._chars = ''
elif name == 'message': elif name == 'message':
if self._msg: if self._msg:
@@ -106,7 +106,7 @@ class Generator(handler.ContentHandler):
self._context = '' self._context = ''
def characters(self, content): def characters(self, content):
self._chars = content self._chars += content
def tree(self): def tree(self):
return self._tree return self._tree
@@ -185,15 +185,19 @@ def diffContext(ctx, old, new):
# --- The main program # --- The main program
generator = Generator() oldGenerator = Generator()
parser = make_parser() oldParser = make_parser()
parser.setContentHandler(generator) oldParser.setContentHandler(oldGenerator)
parser.parse(sys.argv[1]) oldParser.parse(sys.argv[1])
oldTree = generator.tree() oldTree = oldGenerator.tree()
parser.parse(sys.argv[2]) newGenerator = Generator()
newTree = generator.tree() newParser = make_parser()
newParser.setContentHandler(newGenerator)
newParser.parse(sys.argv[2])
newTree = newGenerator.tree()
oldContextSet = set(oldTree.keys()) oldContextSet = set(oldTree.keys())
newContextSet = set(newTree.keys()) newContextSet = set(newTree.keys())