OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Holds the constants for pretty printing histograms.xml.""" | 5 """Holds the constants for pretty printing histograms.xml.""" |
6 | 6 |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 | 9 |
10 # Import the metrics/common module for pretty print xml. | 10 # Import the metrics/common module for pretty print xml. |
(...skipping 14 matching lines...) Expand all Loading... |
25 'histogram_suffixes_list': [], | 25 'histogram_suffixes_list': [], |
26 'histograms': [], | 26 'histograms': [], |
27 'int': ['value', 'label'], | 27 'int': ['value', 'label'], |
28 'obsolete': [], | 28 'obsolete': [], |
29 'owner': [], | 29 'owner': [], |
30 'suffix': ['base', 'name', 'label'], | 30 'suffix': ['base', 'name', 'label'], |
31 'summary': [], | 31 'summary': [], |
32 'with-suffix': ['name'], | 32 'with-suffix': ['name'], |
33 } | 33 } |
34 | 34 |
| 35 # Attribute names that must be explicitly specified on nodes that support them. |
| 36 REQUIRED_ATTRIBUTES = [ |
| 37 # TODO(isherman): Make the 'label' attribute required as well. This requires |
| 38 # fixing up existing suffixes that omit a label. |
| 39 'name', |
| 40 'separator', |
| 41 'value', |
| 42 ] |
| 43 |
35 # Tag names for top-level nodes whose children we don't want to indent. | 44 # Tag names for top-level nodes whose children we don't want to indent. |
36 TAGS_THAT_DONT_INDENT = [ | 45 TAGS_THAT_DONT_INDENT = [ |
37 'histogram-configuration', | 46 'histogram-configuration', |
38 'histograms', | 47 'histograms', |
39 'histogram_suffixes_list', | 48 'histogram_suffixes_list', |
40 'enums', | 49 'enums', |
41 ] | 50 ] |
42 | 51 |
43 # Extra vertical spacing rules for special tag names. | 52 # Extra vertical spacing rules for special tag names. |
44 # {tag_name: (newlines_after_open, newlines_before_close, newlines_after_close)} | 53 # {tag_name: (newlines_after_open, newlines_before_close, newlines_after_close)} |
(...skipping 20 matching lines...) Expand all Loading... |
65 'enums': ('enum', LOWERCASE_NAME_FN), | 74 'enums': ('enum', LOWERCASE_NAME_FN), |
66 'enum': ('int', lambda n: int(n.attributes['value'].value)), | 75 'enum': ('int', lambda n: int(n.attributes['value'].value)), |
67 'histogram_suffixes_list': ('histogram_suffixes', LOWERCASE_NAME_FN), | 76 'histogram_suffixes_list': ('histogram_suffixes', LOWERCASE_NAME_FN), |
68 'histogram_suffixes': ('affected-histogram', LOWERCASE_NAME_FN), | 77 'histogram_suffixes': ('affected-histogram', LOWERCASE_NAME_FN), |
69 } | 78 } |
70 | 79 |
71 | 80 |
72 def GetPrintStyle(): | 81 def GetPrintStyle(): |
73 """Returns an XmlStyle object for pretty printing histograms.""" | 82 """Returns an XmlStyle object for pretty printing histograms.""" |
74 return pretty_print_xml.XmlStyle(ATTRIBUTE_ORDER, | 83 return pretty_print_xml.XmlStyle(ATTRIBUTE_ORDER, |
| 84 REQUIRED_ATTRIBUTES, |
75 TAGS_THAT_HAVE_EXTRA_NEWLINE, | 85 TAGS_THAT_HAVE_EXTRA_NEWLINE, |
76 TAGS_THAT_DONT_INDENT, | 86 TAGS_THAT_DONT_INDENT, |
77 TAGS_THAT_ALLOW_SINGLE_LINE, | 87 TAGS_THAT_ALLOW_SINGLE_LINE, |
78 TAGS_ALPHABETIZATION_RULES) | 88 TAGS_ALPHABETIZATION_RULES) |
OLD | NEW |