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

Unified Diff: tools/metrics/common/models.py

Issue 2769223005: Create a UKM descriptions XML file (Closed)
Patch Set: Incorporate feedback Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/ukm/OWNERS » ('j') | tools/metrics/ukm/pretty_print.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/metrics/common/models.py
diff --git a/tools/metrics/common/models.py b/tools/metrics/common/models.py
index dfae14e263181046d09186e256c6a7577e3d9357..70cf90bccc6479e0a0c534859c60f1ad734690d0 100644
--- a/tools/metrics/common/models.py
+++ b/tools/metrics/common/models.py
@@ -76,17 +76,22 @@ class NodeType(object):
extra_newlines: None or a triple of integers describing the number of
newlines that should be printed (after_open, before_close, after_close)
single_line: True iff this node may be squashed into a single line.
+ alphabetization: A (tag, keyfn) pair, which specifies the tag of the
+ children that should be sorted, and a function to get the sort key from
+ the xml node.
"""
__metaclass__ = abc.ABCMeta
def __init__(self, tag,
indent=True,
extra_newlines=None,
- single_line=False):
+ single_line=False,
+ alphabetization=None):
self.tag = tag
self.indent = indent
self.extra_newlines = extra_newlines
self.single_line = single_line
+ self.alphabetization = alphabetization
@abc.abstractmethod
def Unmarshall(self, node):
@@ -369,7 +374,8 @@ class DocumentType(object):
if types[t].extra_newlines},
tags_that_dont_indent=[t for t in types if not types[t].indent],
tags_that_allow_single_line=[t for t in types if types[t].single_line],
- tags_alphabetization_rules={})
+ tags_alphabetization_rules={t: types[t].alphabetization for t in types
+ if types[t].alphabetization})
def _ToXML(self, obj):
"""Converts an object into an XML document.
@@ -393,4 +399,4 @@ class DocumentType(object):
Returns:
A string containing pretty printed XML.
"""
- return self.GetPrintStyle().PrettyPrintNode(self._ToXML(obj))
+ return self.GetPrintStyle().PrettyPrintXml(self._ToXML(obj))
« no previous file with comments | « no previous file | tools/metrics/ukm/OWNERS » ('j') | tools/metrics/ukm/pretty_print.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698