From c60fa456b50a6dff1bc0b552216383b922892b78 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Sat, 12 Sep 2009 10:19:30 +0100 Subject: [PATCH] Correctly handle arrays. --- xml2txt.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/xml2txt.py b/xml2txt.py index 5d51367..a6563e5 100755 --- a/xml2txt.py +++ b/xml2txt.py @@ -316,15 +316,21 @@ class TraceParser(XmlParser): elems = [self.parse_elem()] while self.token.type != ELEMENT_END: elems.append(self.parse_elem()) - return '{' + ', '.join([name + ' = ' + value for name, value in elems]) + '}' + return '{' + ', '.join(elems) + '}' def parse_elem(self): attrs = self.element_start('elem') - name = attrs['name'] value = self.parse_value() self.element_end('elem') - return name, value + try: + name = attrs['name'] + except KeyError: + pass + else: + value = name + ' = ' + value + + return value def parse_ref(self): attrs = self.element_start('ref') @@ -339,8 +345,8 @@ class TraceParser(XmlParser): def handle_call(self, name, args, ret, duration): s = '' - if duration is not None: - s += '%8u ' % (duration) + #if duration is not None: + # s += '%8u ' % (duration) s += self.formatter.function(name) s += '(' + ', '.join([self.formatter.variable(name) + ' = ' + value for name, value in args]) + ')' -- 2.7.4