OLD | NEW |
| (Empty) |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 """Holds the constants for pretty printing actions.xml.""" | |
6 | |
7 import os | |
8 import sys | |
9 | |
10 # Import the metrics/common module for pretty print xml. | |
11 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) | |
12 import pretty_print_xml | |
13 | |
14 # Desired order for tag and tag attributes. | |
15 # { tag_name: [attribute_name, ...] } | |
16 ATTRIBUTE_ORDER = { | |
17 'action': ['name'], | |
18 'owner': [], | |
19 'description': [], | |
20 'obsolete': [], | |
21 } | |
22 | |
23 # Tag names for top-level nodes whose children we don't want to indent. | |
24 TAGS_THAT_DONT_INDENT = ['actions'] | |
25 | |
26 # Extra vertical spacing rules for special tag names. | |
27 # {tag_name: (newlines_after_open, newlines_before_close, newlines_after_close)} | |
28 TAGS_THAT_HAVE_EXTRA_NEWLINE = { | |
29 'actions': (2, 1, 1), | |
30 'action': (1, 1, 1), | |
31 } | |
32 | |
33 # Tags that we allow to be squished into a single line for brevity. | |
34 TAGS_THAT_ALLOW_SINGLE_LINE = ['owner', 'description', 'obsolete'] | |
35 | |
36 def GetPrintStyle(): | |
37 """Returns an XmlStyle object for pretty printing actions.""" | |
38 return pretty_print_xml.XmlStyle(ATTRIBUTE_ORDER, | |
39 TAGS_THAT_HAVE_EXTRA_NEWLINE, | |
40 TAGS_THAT_DONT_INDENT, | |
41 TAGS_THAT_ALLOW_SINGLE_LINE) | |
OLD | NEW |