OLD | NEW |
1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 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 # """Model objects for ukm.xml contents.""" | 4 # """Model objects for ukm.xml contents.""" |
5 | 5 |
6 import os | 6 import os |
7 import sys | 7 import sys |
8 | 8 |
9 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) | 9 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) |
10 import models | 10 import models |
(...skipping 10 matching lines...) Expand all Loading... |
21 attributes=[('name', unicode)], | 21 attributes=[('name', unicode)], |
22 children=[ | 22 children=[ |
23 models.ChildType('obsolete', _OBSOLETE_TYPE, False), | 23 models.ChildType('obsolete', _OBSOLETE_TYPE, False), |
24 models.ChildType('owners', _OWNER_TYPE, True), | 24 models.ChildType('owners', _OWNER_TYPE, True), |
25 models.ChildType('summary', _SUMMARY_TYPE, False), | 25 models.ChildType('summary', _SUMMARY_TYPE, False), |
26 ]) | 26 ]) |
27 | 27 |
28 _EVENT_TYPE = models.ObjectNodeType( | 28 _EVENT_TYPE = models.ObjectNodeType( |
29 'event', | 29 'event', |
30 alphabetization=('metric', _LOWERCASE_NAME_FN), | 30 alphabetization=('metric', _LOWERCASE_NAME_FN), |
31 attributes=[('name', unicode)], | 31 attributes=[('name', unicode), ('singular', bool)], |
32 extra_newlines=(1, 1, 1), | 32 extra_newlines=(1, 1, 1), |
33 children=[ | 33 children=[ |
34 models.ChildType('obsolete', _OBSOLETE_TYPE, False), | 34 models.ChildType('obsolete', _OBSOLETE_TYPE, False), |
35 models.ChildType('owners', _OWNER_TYPE, True), | 35 models.ChildType('owners', _OWNER_TYPE, True), |
36 models.ChildType('summary', _SUMMARY_TYPE, False), | 36 models.ChildType('summary', _SUMMARY_TYPE, False), |
37 models.ChildType('metrics', _METRIC_TYPE, True), | 37 models.ChildType('metrics', _METRIC_TYPE, True), |
38 ]) | 38 ]) |
39 | 39 |
40 _UKM_CONFIGURATION_TYPE = models.ObjectNodeType( | 40 _UKM_CONFIGURATION_TYPE = models.ObjectNodeType( |
41 'ukm-configuration', | 41 'ukm-configuration', |
(...skipping 10 matching lines...) Expand all Loading... |
52 | 52 |
53 Args: | 53 Args: |
54 original_xml: A string containing the original xml file contents. | 54 original_xml: A string containing the original xml file contents. |
55 | 55 |
56 Returns: | 56 Returns: |
57 A pretty-printed xml string, or None if the config contains errors. | 57 A pretty-printed xml string, or None if the config contains errors. |
58 """ | 58 """ |
59 config = UKM_XML_TYPE.Parse(original_xml) | 59 config = UKM_XML_TYPE.Parse(original_xml) |
60 | 60 |
61 return UKM_XML_TYPE.PrettyPrint(config) | 61 return UKM_XML_TYPE.PrettyPrint(config) |
OLD | NEW |