Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tools/metrics/common/models.py

Issue 1058333002: Multi-dimension rappor metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup and add xml support Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/rappor/rappor_service_unittest.cc ('k') | tools/metrics/rappor/pretty_print.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Model types for describing description xml models.""" 5 """Model types for describing description xml models."""
6 6
7 from xml.dom import minidom 7 from xml.dom import minidom
8 8
9 import sys 9 import sys
10 import os 10 import os
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 else: 151 else:
152 obj[child.attr] = child.node_type.Unmarshall(nodes[0]) 152 obj[child.attr] = child.node_type.Unmarshall(nodes[0])
153 return obj 153 return obj
154 154
155 def Marshall(self, doc, obj): 155 def Marshall(self, doc, obj):
156 node = doc.createElement(self.tag) 156 node = doc.createElement(self.tag)
157 attributes = (self.int_attributes + 157 attributes = (self.int_attributes +
158 self.float_attributes + 158 self.float_attributes +
159 self.string_attributes) 159 self.string_attributes)
160 for attr in attributes: 160 for attr in attributes:
161 node.setAttribute(attr, str(obj[attr])) 161 if obj[attr]:
162 node.setAttribute(attr, str(obj[attr]))
162 163
163 PutComments(node, obj['comments']) 164 PutComments(node, obj['comments'])
164 165
165 for child in self.children: 166 for child in self.children:
166 if child.multiple: 167 if child.multiple:
167 for o in obj[child.attr]: 168 for o in obj[child.attr]:
168 node.appendChild(child.node_type.Marshall(doc, o)) 169 node.appendChild(child.node_type.Marshall(doc, o))
169 else: 170 else:
170 node.appendChild(child.node_type.Marshall(doc, obj[child.attr])) 171 node.appendChild(child.node_type.Marshall(doc, obj[child.attr]))
171 return node 172 return node
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 206
206 def ToXML(self, comments, obj): 207 def ToXML(self, comments, obj):
207 doc = minidom.Document() 208 doc = minidom.Document()
208 for comment in comments: 209 for comment in comments:
209 doc.appendChild(comment) 210 doc.appendChild(comment)
210 doc.appendChild(self.root_type.Marshall(doc, obj)) 211 doc.appendChild(self.root_type.Marshall(doc, obj))
211 return doc 212 return doc
212 213
213 def PrettyPrint(self, comments, obj): 214 def PrettyPrint(self, comments, obj):
214 return self.GetPrintStyle().PrettyPrintNode(self.ToXML(comments, obj)) 215 return self.GetPrintStyle().PrettyPrintNode(self.ToXML(comments, obj))
OLDNEW
« no previous file with comments | « components/rappor/rappor_service_unittest.cc ('k') | tools/metrics/rappor/pretty_print.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698