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. |
11 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) | 11 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) |
12 import pretty_print_xml | 12 import pretty_print_xml |
13 | 13 |
14 # Desired order for tag and tag attributes. The *_ATTRIBUTE_ORDER maps are also | 14 # Desired order for tag and tag attributes. The *_ATTRIBUTE_ORDER maps are also |
15 # used to determine the validity of tag names. | 15 # used to determine the validity of tag names. |
16 # { tag_name: [attribute_name, ...] } | 16 # { tag_name: [attribute_name, ...] } |
17 ATTRIBUTE_ORDER = { | 17 ATTRIBUTE_ORDER = { |
18 'affected-histogram': ['name'], | 18 'affected-histogram': ['name'], |
19 'detail': [], | |
20 'details': [], | 19 'details': [], |
21 'enum': ['name', 'type'], | 20 'enum': ['name', 'type'], |
22 'enums': [], | 21 'enums': [], |
23 # TODO(yiyaoliu): Remove fieldtrial related pieces when it is not used. | |
24 'fieldtrial': ['name', 'separator', 'ordering'], | |
25 'histogram': ['base', 'name', 'enum', 'units'], | 22 'histogram': ['base', 'name', 'enum', 'units'], |
26 'histogram-configuration': ['logsource'], | 23 'histogram-configuration': ['logsource'], |
27 'histogram_suffixes': ['name', 'separator', 'ordering'], | 24 'histogram_suffixes': ['name', 'separator', 'ordering'], |
28 'histogram_suffixes_list': [], | 25 'histogram_suffixes_list': [], |
29 'histograms': [], | 26 'histograms': [], |
30 'int': ['value', 'label'], | 27 'int': ['value', 'label'], |
31 'group': ['name', 'label'], | |
32 'obsolete': [], | 28 'obsolete': [], |
33 'owner': [], | 29 'owner': [], |
34 'suffix': ['base', 'name', 'label'], | 30 'suffix': ['base', 'name', 'label'], |
35 'summary': [], | 31 'summary': [], |
36 'with-group': ['name'], | |
37 'with-suffix': ['name'], | 32 'with-suffix': ['name'], |
38 } | 33 } |
39 | 34 |
40 # Tag names for top-level nodes whose children we don't want to indent. | 35 # Tag names for top-level nodes whose children we don't want to indent. |
41 TAGS_THAT_DONT_INDENT = [ | 36 TAGS_THAT_DONT_INDENT = [ |
42 'histogram-configuration', | 37 'histogram-configuration', |
43 'histograms', | 38 'histograms', |
44 'histogram_suffixes_list', | 39 'histogram_suffixes_list', |
45 'enums', | 40 'enums', |
46 ] | 41 ] |
(...skipping 27 matching lines...) Expand all Loading... |
74 } | 69 } |
75 | 70 |
76 | 71 |
77 def GetPrintStyle(): | 72 def GetPrintStyle(): |
78 """Returns an XmlStyle object for pretty printing histograms.""" | 73 """Returns an XmlStyle object for pretty printing histograms.""" |
79 return pretty_print_xml.XmlStyle(ATTRIBUTE_ORDER, | 74 return pretty_print_xml.XmlStyle(ATTRIBUTE_ORDER, |
80 TAGS_THAT_HAVE_EXTRA_NEWLINE, | 75 TAGS_THAT_HAVE_EXTRA_NEWLINE, |
81 TAGS_THAT_DONT_INDENT, | 76 TAGS_THAT_DONT_INDENT, |
82 TAGS_THAT_ALLOW_SINGLE_LINE, | 77 TAGS_THAT_ALLOW_SINGLE_LINE, |
83 TAGS_ALPHABETIZATION_RULES) | 78 TAGS_ALPHABETIZATION_RULES) |
OLD | NEW |