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

Side by Side Diff: tools/metrics/actions/print_style.py

Issue 2894833005: Make histogram_suffixes separators and enum labels required. (Closed)
Patch Set: Rebase, and improve the error reporting logic Created 3 years, 7 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 | « no previous file | tools/metrics/common/pretty_print_xml.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 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 actions.xml.""" 5 """Holds the constants for pretty printing actions.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 'action': ['name', 'not_user_triggered'], 18 'action': ['name', 'not_user_triggered'],
19 'action-suffix': ['separator', 'ordering'], 19 'action-suffix': ['separator', 'ordering'],
20 'actions': [], 20 'actions': [],
21 'actions-suffixes': [], 21 'actions-suffixes': [],
22 'affected-action': ['name'], 22 'affected-action': ['name'],
23 'description': [], 23 'description': [],
24 'obsolete': [], 24 'obsolete': [],
25 'owner': [], 25 'owner': [],
26 'suffix': ['name', 'label'], 26 'suffix': ['name', 'label'],
27 'with-suffix': ['name'], 27 'with-suffix': ['name'],
28 } 28 }
29 29
30 # Attribute names that must be explicitly specified on nodes that support them.
31 REQUIRED_ATTRIBUTES = [
32 'label',
33 'name',
34 'separator',
35 ]
36
30 # Tag names for top-level nodes whose children we don't want to indent. 37 # Tag names for top-level nodes whose children we don't want to indent.
31 TAGS_THAT_DONT_INDENT = [ 38 TAGS_THAT_DONT_INDENT = [
32 'actions', 39 'actions',
33 'actions-suffixes', 40 'actions-suffixes',
34 ] 41 ]
35 42
36 # Extra vertical spacing rules for special tag names. 43 # Extra vertical spacing rules for special tag names.
37 # {tag_name: (newlines_after_open, newlines_before_close, newlines_after_close)} 44 # {tag_name: (newlines_after_open, newlines_before_close, newlines_after_close)}
38 TAGS_THAT_HAVE_EXTRA_NEWLINE = { 45 TAGS_THAT_HAVE_EXTRA_NEWLINE = {
39 'actions': (2, 1, 1), 46 'actions': (2, 1, 1),
(...skipping 12 matching lines...) Expand all
52 # and a key function that maps each child node to the desired sort key. 59 # and a key function that maps each child node to the desired sort key.
53 TAGS_ALPHABETIZATION_RULES = { 60 TAGS_ALPHABETIZATION_RULES = {
54 'actions': ('action', LOWERCASE_NAME_FN), 61 'actions': ('action', LOWERCASE_NAME_FN),
55 'action-suffix': ('affected-action', LOWERCASE_NAME_FN), 62 'action-suffix': ('affected-action', LOWERCASE_NAME_FN),
56 } 63 }
57 64
58 65
59 def GetPrintStyle(): 66 def GetPrintStyle():
60 """Returns an XmlStyle object for pretty printing actions.""" 67 """Returns an XmlStyle object for pretty printing actions."""
61 return pretty_print_xml.XmlStyle(ATTRIBUTE_ORDER, 68 return pretty_print_xml.XmlStyle(ATTRIBUTE_ORDER,
69 REQUIRED_ATTRIBUTES,
62 TAGS_THAT_HAVE_EXTRA_NEWLINE, 70 TAGS_THAT_HAVE_EXTRA_NEWLINE,
63 TAGS_THAT_DONT_INDENT, 71 TAGS_THAT_DONT_INDENT,
64 TAGS_THAT_ALLOW_SINGLE_LINE, 72 TAGS_THAT_ALLOW_SINGLE_LINE,
65 TAGS_ALPHABETIZATION_RULES) 73 TAGS_ALPHABETIZATION_RULES)
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/common/pretty_print_xml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698