From 5ba1e4b1e41eee6e4a6c31e62ca3e6468e5a369e Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 15 Apr 2013 02:09:23 -0500 Subject: [PATCH] timeside/analyzer/core.py: remove hack on xml, always use repr() and eval() --- timeside/analyzer/core.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/timeside/analyzer/core.py b/timeside/analyzer/core.py index ac21d44..fd5357d 100644 --- a/timeside/analyzer/core.py +++ b/timeside/analyzer/core.py @@ -89,10 +89,9 @@ class AnalyzerResultContainer(object): doc.appendChild(root) for data in data_list: node = doc.createElement('data') - for a in ['name', 'id', 'unit', 'value']: + for a in ['name', 'id', 'unit']: node.setAttribute(a, str(data[a]) ) - if type(data['value']) != type(str()) and type(data['value']) != type(unicode()): - node.setAttribute('str', '0') + node.setAttribute('value', repr(data['value']) ) root.appendChild(node) return xml.dom.minidom.Document.toprettyxml(doc) @@ -106,11 +105,7 @@ class AnalyzerResultContainer(object): child_dict = {} for a in ['name', 'id', 'unit', 'value']: child_dict[a] = str(child.getAttribute(a)) - if child.getAttribute('str') == '0': - try: - child_dict['value'] = eval(child_dict['value']) - except Exception, e: - print e + child_dict['value'] = eval(child_dict['value']) results.append(child_dict) return results -- 2.39.5