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

Side by Side Diff: tools/metrics/rappor/pretty_print.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 | « tools/metrics/common/models.py ('k') | tools/metrics/rappor/pretty_print_test.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import logging 6 import logging
7 import sys 7 import sys
8 import os 8 import os
9 9
10 # Import the metrics/common module for pretty print xml. 10 # Import the metrics/common module for pretty print xml.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 extra_newlines=(1, 1, 1), 44 extra_newlines=(1, 1, 1),
45 dont_indent=True, 45 dont_indent=True,
46 children=[ 46 children=[
47 models.ChildType('types', _RAPPOR_PARAMETERS_TYPE, True), 47 models.ChildType('types', _RAPPOR_PARAMETERS_TYPE, True),
48 ]) 48 ])
49 49
50 _OWNER_TYPE = models.TextNodeType('owner', single_line=True) 50 _OWNER_TYPE = models.TextNodeType('owner', single_line=True)
51 51
52 _RAPPOR_METRIC_TYPE = models.ObjectNodeType('rappor-metric', 52 _RAPPOR_METRIC_TYPE = models.ObjectNodeType('rappor-metric',
53 extra_newlines=(1, 1, 1), 53 extra_newlines=(1, 1, 1),
54 string_attributes=['name', 'type'], 54 string_attributes=['name', 'type', 'flags'],
55 children=[ 55 children=[
56 models.ChildType('owners', _OWNER_TYPE, True), 56 models.ChildType('owners', _OWNER_TYPE, True),
57 models.ChildType('summary', _SUMMARY_TYPE, False), 57 models.ChildType('summary', _SUMMARY_TYPE, False),
58 ]) 58 ])
59 59
60 _RAPPOR_METRICS_TYPE = models.ObjectNodeType('rappor-metrics', 60 _RAPPOR_METRICS_TYPE = models.ObjectNodeType('rappor-metrics',
61 extra_newlines=(1, 1, 1), 61 extra_newlines=(1, 1, 1),
62 dont_indent=True, 62 dont_indent=True,
63 children=[ 63 children=[
64 models.ChildType('metrics', _RAPPOR_METRIC_TYPE, True), 64 models.ChildType('metrics', _RAPPOR_METRIC_TYPE, True),
65 ]) 65 ])
66 66
67 _FLAG_TYPE = models.ObjectNodeType('flag',
68 extra_newlines=(1, 1, 0),
69 string_attributes=['name', 'description'])
70
71 _FLAG_SET_TYPE = models.ObjectNodeType('flag-set',
72 extra_newlines=(1, 1, 1),
73 string_attributes=['name'],
74 children=[
75 models.ChildType('flags', _FLAG_TYPE, True),
76 ])
77
78 _FLAG_SETS_TYPE = models.ObjectNodeType('flag-sets',
79 extra_newlines=(1, 1, 1),
80 dont_indent=True,
81 children=[
82 models.ChildType('flagSets', _FLAG_SET_TYPE, True),
83 ]
84 )
85
67 _RAPPOR_CONFIGURATION_TYPE = models.ObjectNodeType('rappor-configuration', 86 _RAPPOR_CONFIGURATION_TYPE = models.ObjectNodeType('rappor-configuration',
68 extra_newlines=(1, 1, 1), 87 extra_newlines=(1, 1, 1),
69 dont_indent=True, 88 dont_indent=True,
70 children=[ 89 children=[
71 models.ChildType('parameterTypes', _RAPPOR_PARAMETERS_TYPES_TYPE, False), 90 models.ChildType('parameterTypes', _RAPPOR_PARAMETERS_TYPES_TYPE, False),
91 models.ChildType('flagSets', _FLAG_SETS_TYPE, True),
72 models.ChildType('metrics', _RAPPOR_METRICS_TYPE, False), 92 models.ChildType('metrics', _RAPPOR_METRICS_TYPE, False),
73 ]) 93 ])
74 94
75 RAPPOR_XML_TYPE = models.DocumentType(_RAPPOR_CONFIGURATION_TYPE) 95 RAPPOR_XML_TYPE = models.DocumentType(_RAPPOR_CONFIGURATION_TYPE)
76 96
77 97
78 def GetTypeNames(config): 98 def GetTypeNames(config):
79 return set(p['name'] for p in config['parameterTypes']['types']) 99 return set(p['name'] for p in config['parameterTypes']['types'])
80 100
81 101
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 return RAPPOR_XML_TYPE.PrettyPrint(comments, config) 178 return RAPPOR_XML_TYPE.PrettyPrint(comments, config)
159 179
160 180
161 def main(argv): 181 def main(argv):
162 presubmit_util.DoPresubmitMain(argv, 'rappor.xml', 'rappor.old.xml', 182 presubmit_util.DoPresubmitMain(argv, 'rappor.xml', 'rappor.old.xml',
163 'pretty_print.py', UpdateXML) 183 'pretty_print.py', UpdateXML)
164 184
165 185
166 if '__main__' == __name__: 186 if '__main__' == __name__:
167 sys.exit(main(sys.argv)) 187 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « tools/metrics/common/models.py ('k') | tools/metrics/rappor/pretty_print_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698