From: Paul Brossier Date: Mon, 15 Apr 2013 07:09:23 +0000 (-0500) Subject: timeside/analyzer/core.py: remove hack on xml, always use repr() and eval() X-Git-Tag: 0.5.0~115^2~27 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=5ba1e4b1e41eee6e4a6c31e62ca3e6468e5a369e;p=timeside.git timeside/analyzer/core.py: remove hack on xml, always use repr() and eval() --- 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